From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id EBDB7384B826 for ; Mon, 11 Jan 2021 20:06:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EBDB7384B826 Received: by mail-pl1-x636.google.com with SMTP id 4so82234plk.5 for ; Mon, 11 Jan 2021 12:06:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=erBK4ucKDJY2HtUH95oZHm0/M2O3ik9iraxUfA3lMQI=; b=P/hZkt5/LleY2CXUyn+dpggEzDBd4UuIsXtFHoOwHQtmgiQ4/zHgOOfg7ArGt/8UZs mm6rYT27mDfUfypZzFdg6kp+nBwmyd0+hrSAZGhWaqq6kh/wmZs2kRVDDnP2V9CfasCr uPQhdKXU1RiaE0r1/xkzYcpZsAEH1dtd8QH3VyLPOzXxZucBAYIIDjOj2T28NFoQX4nq Zts07owCjX1hqq1OEaTgfeJg8OSshchCX1eTlJkQkIM3fQPI1YRsq1zxEMV/JXIEiafU rHNxQt3sSN1+gxKI33LIbsKBy+Ma5UfQZTv/Nr9bIOKgsrM9IadyeDWdHw1bFlO/49+Z RK+Q== X-Gm-Message-State: AOAM531r/JPWe3UblYZGIu/y9ru5o6PWecdD49bwQCfNMBc6onEhA5q/ Rz9Y/SyJxAHoqF0HXB0jNT2Quq7rVEpg4UB/LzWd8e3Zxmk= X-Google-Smtp-Source: ABdhPJxXdJDCjpMWljN/7+gXCht2jPG2zA7nkLoDq91uNFstetLKvUNWnqlkzuGtS3w5CD3lsO0CVwxY2cU7KcZVhKg= X-Received: by 2002:a17:90a:da02:: with SMTP id e2mr48659pjv.173.1610395575553; Mon, 11 Jan 2021 12:06:15 -0800 (PST) MIME-Version: 1.0 References: <20201228194855.510315-1-maskray@google.com> <20201228194855.510315-3-maskray@google.com> In-Reply-To: <20201228194855.510315-3-maskray@google.com> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Mon, 11 Jan 2021 12:06:04 -0800 Message-ID: Subject: Re: [PATCH 2/3] elf: Replace a --defsym trick with an object file to be compatible with lld To: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-19.1 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jan 2021 20:06:18 -0000 On Mon, Dec 28, 2020 at 11:49 AM Fangrui Song wrote: > > The existing code specifies -Wl,--defsym=malloc=0 and other malloc.os > definitions before libc_pic.a so that libc_pic.a(malloc.os) is not > fetched. This trick is used to avoid multiple definition errors which > would happen as a chain result: > > dl-allobjs.os has an undefined __libc_scratch_buffer_set_array_size > __libc_scratch_buffer_set_array_size fetches libc_pic.a(scratch_buffer_set_array_size.os) > libc_pic.a(scratch_buffer_set_array_size.os) has an undefined free > free fetches libc_pic.a(malloc.os) > libc_pic.a(malloc.os) has an undefined __libc_message > __libc_message fetches libc_pic.a(libc_fatal.os) > > libc_fatal.os will cause a multiple definition error (__GI___libc_fatal) > >>> defined at dl-fxstatat64.c > >>> /tmp/p/glibc/Release/elf/dl-allobjs.os:(__GI___libc_fatal) > >>> defined at libc_fatal.c > >>> libc_fatal.os:(.text+0x240) in archive /tmp/p/glibc/Release/libc_pic.a > > lld processes --defsym after all input files, so this trick does not > suppress multiple definition errors with lld. Split the step into two > and use an object file to make the intention more obvious and make lld > work. > > This is conceptually more appropriate because --defsym defines a SHN_ABS > symbol while a normal definition is relative to the image base. > > See https://sourceware.org/pipermail/libc-alpha/2020-March/111910.html > for discussions about the --defsym semantics. > --- > elf/Makefile | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) Ping on this