From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id ABC06385780F for ; Mon, 27 Jun 2022 08:04:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ABC06385780F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=deneb.enyo.de Received: from [172.17.203.2] (port=46675 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) id 1o5jj2-002syH-SO; Mon, 27 Jun 2022 08:04:04 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.94.2) (envelope-from ) id 1o5jj2-0004jW-GX; Mon, 27 Jun 2022 10:04:04 +0200 From: Florian Weimer To: Fangrui Song Cc: Fangrui Song via Libc-alpha Subject: Re: [PATCH] Makerules: Remove no-op -Wl,-d when linking libc_pic.os References: <20220626184025.553459-1-maskray@google.com> <87tu87nn4y.fsf@mid.deneb.enyo.de> <20220626222936.56qfdvvtbv4u7gz2@google.com> Date: Mon, 27 Jun 2022 10:04:04 +0200 In-Reply-To: <20220626222936.56qfdvvtbv4u7gz2@google.com> (Fangrui Song's message of "Sun, 26 Jun 2022 15:29:36 -0700") Message-ID: <871qva353f.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, 27 Jun 2022 08:04:10 -0000 * Fangrui Song: >>Do you know what the .gnu.glibc-stub.* processing processing refers >>to? > > [a] Just few lines below, there is > > # Generate a list of -R options to excise .gnu.glibc-stub.* sections. > > The idea is to create libc_pic.os from libc_pic.a, strip .gnu.glibc-stub.*, then link libc_pic.os.clean into libc.so. > > Technically the relocatable link can be omitted. We can change `build-shlib` > to link -Wl,--whole-archive libc_pic.a -Wl,--no-whole-archive instead. objcopy -R works on an archive for > a long time. I am unsure whether the 1990+ objcopy supports archives. > But at a first glance I do not find a good place to insert -Wl,--whole-archive into build-shlib... For linking libc.so, we can list the objects directly, then we don't need -Wl,--whole-archive. For linking ld.so, we do not use -Wl,--whole-archive because we actually want to link a subset. I was under the impression that we rebuild objects for inclusion into ld.so, so I'm rather puzzled that we need this. > [b] Around $(objpfx)stubs: $(objs-for-stubs), we can see that > .gnu.glibc-stub.* is to generate */stubs files and finally testroot.root/$prefix/include/gnu/stubs-64.h > > % cat testroot.root/tmp/glibc/lld/include/gnu/stubs-64.h > /* This file is automatically generated. > It defines a symbol `__stub_FUNCTION' for each function > in the C library which is a stub, meaning it will fail > every time called, usually setting errno to ENOSYS. */ > > #ifdef _LIBC > #error Applications may not define the macro _LIBC > #endif > > #define __stub___compat_bdflush > #define __stub_chflags > #define __stub_fchflags > #define __stub_gtty > #define __stub_revoke > #define __stub_setlogin > #define __stub_sigreturn > #define __stub_stty Those warning sections must propagate into libc.so, so I think we could parse that and the generate header from it.