From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 31625386F83E for ; Mon, 18 Jan 2021 22:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 31625386F83E Received: by mail-pg1-x52a.google.com with SMTP id c132so11786049pga.3 for ; Mon, 18 Jan 2021 14:08:58 -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:content-transfer-encoding; bh=sOckabGS3nyvhlc7x9CcBfcWHnGVwPp/cDK9ZpHxD1A=; b=SX2pzVcghSMNsQElIpe0mJBlCuRGkvd2ro9jUviQEaFwRGMl+W5BywlOU34YjCL5N0 fz0b7gMR8zCpHmmFEq/fuYZkUzd8+39K+Mo9DigJAa5zMrs1P4hm7wCOTB0bRE7d/1U5 Wq3iifHNVsEWRvOWjx6aAzTTLxmKPOG4x3XcR9PR09PUEpWdSrFYBKxVudKfFccXRoLC O0yLkWMvHIlDkXlQJdD3tBb62+iJrtbuiyBdN2UtRl5Conas9/OyS7g8fS4u5kOndMnK tZ0DbvHYYHrv4DJ+g/5vF4mFK/mef1HIwY6WQKEirsTAvVU4gqwJg3oJO0w+KvroIEdv Ghew== X-Gm-Message-State: AOAM533bkUnyM8VDnpnm1EBS8BE7lGNEDj+8QGT3qwt2VfjZ5s0ThB75 Hq4yBP+pRr7TErWoNTYnoxlkt77gqnrgGcrHWnVgF6HpwBndoA== X-Google-Smtp-Source: ABdhPJw40WOvNkevO4Fp//vv+8ADN5l2ldsW5pApdF//XiKPPlbWozLAjcp8vuG7PF8mfChjZ1fAG/41uw/2+356ewk= X-Received: by 2002:a62:5ec5:0:b029:1ae:6847:fa02 with SMTP id s188-20020a625ec50000b02901ae6847fa02mr1427312pfb.61.1611007736810; Mon, 18 Jan 2021 14:08:56 -0800 (PST) MIME-Version: 1.0 References: <20201228194855.510315-1-maskray@google.com> <20201228194855.510315-3-maskray@google.com> In-Reply-To: From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Mon, 18 Jan 2021 14:08:46 -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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-19.3 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, 18 Jan 2021 22:09:00 -0000 On Mon, Jan 11, 2021 at 12:06 PM F=C4=81ng-ru=C3=AC S=C3=B2ng wrote: > > On Mon, Dec 28, 2020 at 11:49 AM Fangrui Song wrote: > > > > The existing code specifies -Wl,--defsym=3Dmalloc=3D0 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_buffe= r_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_fat= al) > > >>> defined at dl-fxstatat64.c > > >>> /tmp/p/glibc/Release/elf/dl-allobjs.os:(__GI___libc_fa= tal) > > >>> defined at libc_fatal.c > > >>> libc_fatal.os:(.text+0x240) in archive /tmp/p/glibc/Re= lease/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_AB= S > > 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 PING^2 https://sourceware.org/pipermail/libc-alpha/2020-December/121144.html You can also find the commit in https://sourceware.org/git/?p=3Dglibc.git;a=3Dshortlog;h=3Drefs/heads/maskr= ay/lld