Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200407084214.GC13749@port70.net>
Date: Tue, 7 Apr 2020 10:42:14 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Cc: harald@...hat.com, Fangrui Song <i@...kray.me>
Subject: Re: [PATCH] V2 Enable linking to a static position
 independent executable

* Fangrui Song <i@...kray.me> [2020-04-06 15:04:03 -0700]:
> On 2020-04-06, harald@...hat.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 <<EOF
> > 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
> > 

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.