From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 31073 invoked from network); 7 Apr 2020 08:42:29 -0000 Received-SPF: pass (mother.openwall.net: domain of lists.openwall.com designates 195.42.179.200 as permitted sender) receiver=inbox.vuxu.org; client-ip=195.42.179.200 envelope-from= Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 7 Apr 2020 08:42:29 -0000 Received: (qmail 3397 invoked by uid 550); 7 Apr 2020 08:42:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3379 invoked from network); 7 Apr 2020 08:42:26 -0000 Date: Tue, 7 Apr 2020 10:42:14 +0200 From: Szabolcs Nagy To: musl@lists.openwall.com Cc: harald@redhat.com, Fangrui Song Message-ID: <20200407084214.GC13749@port70.net> Mail-Followup-To: musl@lists.openwall.com, harald@redhat.com, Fangrui Song References: <20200406180738.946894-1-harald@redhat.com> <20200406220403.3moghw2llo34e6gh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200406220403.3moghw2llo34e6gh@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [musl] [PATCH] V2 Enable linking to a static position independent executable * Fangrui Song [2020-04-06 15:04:03 -0700]: > On 2020-04-06, harald@redhat.com wrote: > > > > *cc1: > > -%(cc1_cpu) -nostdinc -isystem $incdir -isystem include%s > > +%(cc1_cpu) %{static-pie:-fPIE} -nostdinc -isystem $incdir -isystem include%s > > The intention of the compiler driver option -static-pie is that it only > affects linking options (-static -pie --no-dynamic-linker -z text), not compile options (-fPIE). yes. the spec file cannot be reliable because the default toolchain config is not visible to the spec file logic, so for non-basic use we recommend to build a musl based cross toolchain. > > (I don't know why -z text (which is not too relevant) ended up in GCC's default specs. > Anyway, I followed suit for clang: https://reviews.llvm.org/D62606) because it's easy to get text relocs by mistake (compiling without -fPIE but linking static pie) and text relocs are always wrong for static pie (neither glibc nor musl plans to support them). > > *link_libgcc: > > -L$libdir -L .%s > > @@ -17,13 +17,13 @@ cat < > libgcc.a%s %:if-exists(libgcc_eh.a%s) > > > > *startfile: > > -%{!shared: $libdir/Scrt1.o} $libdir/crti.o crtbeginS.o%s > > +%{shared:;static:$libdir/crt1.o%s; static-pie:$libdir/rcrt1.o%s; pie:$libdir/Scrt1.o%s; :$libdir/crt1.o%s} $libdir/crti.o%s %{static:crtbeginT.o%s; shared|static-pie|pie:crtbeginS.o%s; :crtbegin.o%s} > > > > *endfile: > > -crtendS.o%s $libdir/crtn.o > > +%{static:crtend.o%s; shared|static-pie|pie:crtendS.o%s; :crtend.o%s} $libdir/crtn.o%s > > > > *link: > > --dynamic-linker $ldso -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic} > > +%{!r:--build-id} --no-add-needed %{!static|static-pie:--eh-frame-hdr} --hash-style=gnu %{shared:-shared} %{!shared:%{!static:%{!static-pie:%{rdynamic:-export-dynamic} -dynamic-linker $ldso}} %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}} > > > > *esp_link: > > > > -- > > 2.25.2 > >