mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: harald@redhat.com, Fangrui Song <i@maskray.me>
Subject: Re: [musl] [PATCH] V2 Enable linking to a static position independent executable
Date: Tue, 7 Apr 2020 10:42:14 +0200	[thread overview]
Message-ID: <20200407084214.GC13749@port70.net> (raw)
In-Reply-To: <20200406220403.3moghw2llo34e6gh@gmail.com>

* Fangrui Song <i@maskray.me> [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 <<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
> > 

  reply	other threads:[~2020-04-07  8:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 18:07 harald
2020-04-06 22:04 ` Fangrui Song
2020-04-07  8:42   ` Szabolcs Nagy [this message]
2020-04-07 13:17   ` [musl] [PATCH] " harald
2020-04-23 11:59     ` Harald Hoyer
2020-04-24 15:08     ` Rich Felker
2020-04-27 12:24       ` Harald Hoyer
2020-04-27 12:32         ` harald
2020-05-08  9:05           ` Harald Hoyer
2020-08-25 10:52           ` Harald Hoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200407084214.GC13749@port70.net \
    --to=nsz@port70.net \
    --cc=harald@redhat.com \
    --cc=i@maskray.me \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).