mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: musl-gcc with default-pie toolchains
Date: Wed, 1 Aug 2018 12:44:20 -0400	[thread overview]
Message-ID: <20180801164420.GH1392@brightrain.aerifal.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

A number of users have hit problems with the musl-gcc wrapper and
underlying gccs built for default-pie, due to the specfile assuming
non-pie is the default. The attached patch should fix that by using
the pic-compatible versions of the crt files regardless of whether the
output is pie or not. There's really no reason for the
non-pic-compatible files to ever be used except saving (likely a
single-digit number of) bytes of text.

For static-pie, where a special rcrt1.o file is needed in place of the
normal crt1, this will not work, but as far as I know all deployed gcc
toolchains with default-pie do not honor the default-pie with -static
and don't even support -static -pie (only -static-pie if anything)
since glibc didn't support it until very recently. We could probably
make -static-pie (and maybe -static -pie?) work with musl-gcc on such
toolchains if we wanted as a separate patch, but right now I just want
to fix the defaults that are breaking things for users..

Let me know if there's anything wrong with this or if it doesn't fix
the problem.

Rich

[-- Attachment #2: gccwrapper.diff --]
[-- Type: text/plain, Size: 590 bytes --]

diff --git a/tools/musl-gcc.specs.sh b/tools/musl-gcc.specs.sh
index 294e24f..3049257 100644
--- a/tools/musl-gcc.specs.sh
+++ b/tools/musl-gcc.specs.sh
@@ -17,10 +17,10 @@ cat <<EOF
 libgcc.a%s %:if-exists(libgcc_eh.a%s)
 
 *startfile:
-%{!shared: $libdir/%{pie:S}crt1.o} $libdir/crti.o %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}
+%{!shared: $libdir/Scrt1.o} $libdir/crti.o crtbeginS.o%s
 
 *endfile:
-%{shared|pie:crtendS.o%s;:crtend.o%s} $libdir/crtn.o
+crtendS.o%s $libdir/crtn.o
 
 *link:
 -dynamic-linker $ldso -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic}

                 reply	other threads:[~2018-08-01 16:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180801164420.GH1392@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).