mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] Static linking is broken after creation of DT_TEXTREL segment
Date: Sun, 2 Feb 2020 23:40:37 -0500	[thread overview]
Message-ID: <20200203044037.GN1663@brightrain.aerifal.cx> (raw)
In-Reply-To: <20200203043251.GM2020@voyager>

On Mon, Feb 03, 2020 at 05:32:51AM +0100, Markus Wichmann wrote:
> On Sun, Feb 02, 2020 at 10:10:36PM -0500, Rich Felker wrote:
> > I'll probably end up having mcm pass --with-pic to GCC's top-level
> > configure, but I see this will be picked up by some other libs like
> > libcc1, which oddly aren't failing for the same reason. Any idea why?
> 
> I'd guess they don't use assembly, or at least their assembly does not
> try to access global symbols. I haven't looked at the source though. And
> I won't until the afternoon at least.
> 
> > Is this the right fix for mcm? What could/should be done to unbreak
> > gmp with default-pie toolchains? Is it a bug in the version of libtool
> > they're using or a bug in gmp?
> >
> > Rich
> 
> The problem is with the assumptions of GMP. And I really don't know how
> to fix those. GMP's build system generates a dynamic and a static
> library, and assumes that the static library does not need to be PIC.
> With the advent of static-pie, this assumption is subverted. But how to

Even before static-pie it was wrong. If you're making a dynamic-linked
PIE executable but want to static link libgmp, it will be wrong.

> deal with this generally? Many libraries assume the static one does not
> need PIC.

Everything else honors the compiler's default. If $(CC) was built for
default-pie, or if you set CC="gcc -fPIE -pie" or something similar,
you'd get a static library that's PIE-compatible. Only gmp is broken
because its asm is wrongly poking at some libtool vars rather than
__PIC__ from the compiler.

> In case of GMP, I would argue they can add a test to determine if the
> toolchain generates static-pie, and turn on PIC by default if so. No
> clue if upstream will like that, though.

All they need to do is look at __PIC__ in place of whatever wrong test
they're doing now. The question is just how easy this is to patch.

Rich

  reply	other threads:[~2020-02-03  4:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 18:41 Андрей Аладьев
2020-01-29 19:19 ` Markus Wichmann
2020-01-29 19:38   ` Markus Wichmann
2020-01-29 20:48     ` Rich Felker
2020-01-29 20:08   ` Андрей Аладьев
2020-01-30 17:02     ` Markus Wichmann
2020-01-31  4:24       ` Rich Felker
2020-01-31 14:47         ` Markus Wichmann
2020-01-31 16:35           ` Rich Felker
2020-01-31 15:16       ` Андрей Аладьев
2020-01-31 16:40         ` Rich Felker
2020-01-31 17:51           ` Андрей Аладьев
2020-01-31 18:01             ` Rich Felker
2020-01-31 19:11               ` Андрей Аладьев
2020-02-03  3:10       ` Rich Felker
2020-02-03  4:05         ` Rich Felker
2020-02-03  4:32         ` Markus Wichmann
2020-02-03  4:40           ` Rich Felker [this message]
2020-01-29 20:53 ` Rich Felker
2020-01-29 21:10   ` Szabolcs Nagy
2020-01-29 21:35     ` Андрей Аладьев
2020-01-29 21:46       ` Rich Felker
2020-01-29 23:10         ` Андрей Аладьев
2020-01-29 23:20       ` Szabolcs Nagy
2020-01-29 21:14   ` Андрей Аладьев
2020-01-29 21:43     ` Rich Felker

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=20200203044037.GN1663@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).