From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stravinsky.debian.org (stravinsky.debian.org [IPv6:2001:41b8:202:deb::311:108]) by sourceware.org (Postfix) with ESMTPS id D487C3858C53 for ; Sat, 22 Oct 2022 14:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D487C3858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=debian.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description; bh=qX9k8pHHD7GDGIMETLbpUZmoUFfhWqNcP4Oie3YXPS8=; b=h/loZ/26+pqiFOFefrdIOtje+k bjhY33JimnfVWFL2mswdV+RkG+2OSxGOuEb2ICbT9ORFeD45+vXNaWWk9tZIIwF7V6cf3d+Lv3mCr LdczzrBEU4k4xIjDwssCIWxTs0ySd6XfbMgPlf+++/t6Q7y3yMSNyycF10+fac3a5iNoSBtyQcvYW jLUh2wX2raz0zZcP2m0xqLcfJKFlMhSdT5+tB7Tg6gFZCOxm4QuHyKOlg63BRj7WheTw/XYSkXDSb /q3PA/g63we8QRqFGEDvLPVk3Qfdv+EgwdvLgQaMcjuwtK/fqyykJ/I67dS59C6AoaaAi5heA4slQ eoHA5z0Q==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1omFl0-000UrI-7S; Sat, 22 Oct 2022 14:45:49 +0000 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1omFky-0002i6-13; Sat, 22 Oct 2022 16:45:48 +0200 Date: Sat, 22 Oct 2022 16:45:48 +0200 From: Samuel Thibault To: Xi Ruoyao Cc: libc-alpha@sourceware.org, glibc@packages.debian.org Subject: Re: static pie: confusion between _DYNAMIC, crt1.o, Scrt1.o Message-ID: <20221022144548.u5rq3ffgietk4zft@begin> References: <20221022140614.rnfd4d4nefjmizzi@begin> <6ba3b8ba096fadec66822e2e1f712777b524f66c.camel@xry111.site> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6ba3b8ba096fadec66822e2e1f712777b524f66c.camel@xry111.site> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Debian-User: sthibault X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, Xi Ruoyao, le sam. 22 oct. 2022 22:25:42 +0800, a ecrit: > On Sat, 2022-10-22 at 16:06 +0200, Samuel Thibault wrote: > > https://buildd.debian.org/status/fetch.php?pkg=gnupg2&arch=hurd-i386&ver=2.2.40-1&stamp=1666261690&raw=0 > > > > which is leaving me completely confused. > > > > > > gcc -I/usr/include  -I/usr/include  -Wall -Wno-format-zero-length - > > Wno-pointer-sign -Wpointer-arith -g -O2 -ffile-prefix- > > map=/<>=. -fstack-protector-strong -Wformat - > > Werror=format-security  -Wl,-z,relro -Wl,-z,now -pie -static -o gpgv > > gpgv.o build-packet.o compress.o  free-packet.o getkey.o keydb.o > > keyring.o seskey.o kbnode.o mainproc.o armor.o mdfilter.o textfilter.o > > progress.o misc.o rmd160.o openfile.o keyid.o parse-packet.o cpr.o > > plaintext.o sig-check.o keylist.o pkglue.o ecdh.o verify.o > > ../kbx/libkeybox.a ../common/libcommon.a ../regexp/libregexp.a > > ../common/libgpgrl.a -lz   -L/usr/lib/i386-gnu -lgcrypt - > > L/usr/lib/i386-gnu -lgpg-error > > > > So this is static pie (-pie -static) > > No it's not. The GCC option for static PIE is -static-pie (no > whitespace between -static and -pie), not -pie -static. Oh. Is it not possible to make -static -pie get the same behavior? That'd be way more orthogonal for people to understand. As the gnupg example shows, people seem to be expecting it to be static-pie, and I don't think documentation will manage to fix that. > > So this is using Scrt1.o > > A static PIE should use rcrt1.o. If you pass the correct -static-pie > option to GCC, GCC will use it. Ok. $ gcc test.o -o test -static-pie -v [...] /usr/lib/gcc/i686-gnu/12/collect2 -plugin /usr/lib/gcc/i686-gnu/12/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i686-gnu/12/lto-wrapper -plugin-opt=-fresolution=/tmp/cclPHnby.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu --as-needed -static -pie --no-dynamic-linker -z text -pie -o test /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crt1.o /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crti.o /usr/lib/gcc/i686-gnu/12/crtbegin.o -L/usr/lib/gcc/i686-gnu/12 -L/usr/lib/gcc/i686-gnu/12/../../../i386-gnu -L/usr/lib/gcc/i686-gnu/12/../../.. -L/lib/i386-gnu -L/usr/lib/i386-gnu test.o --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i686-gnu/12/crtendS.o /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crtn.o That doesn't seem to have been fixed for the hurd case, I will have a look (and that will most probably point me to the piece that makes -static -pie use crt1.o on Linux). Samuel