~alpine/users

3 3

Why is static linking not quite entirely static?

Benson Margulies <bimargulies@google.com>
Details
Message ID
<CAMfBnm-bbqWeKeVV12QMCOFcZkO+qM5DHLXrTKN6rkfj8awG9A@mail.gmail.com>
DKIM signature
missing
Download raw message
Executables built with (e.g.) g++ -static still show a runtime dependency
on /lib/ld-musl-x86_64.so.1. My recollection from the past was that it was
possible to achieve a completely static a.out. Is there a way?
Konstantin Kulikov <k.kulikov2@gmail.com>
Details
Message ID
<b75869bb-311a-7f9e-0df1-2e0cda29e7b5@gmail.com>
In-Reply-To
<CAMfBnm-bbqWeKeVV12QMCOFcZkO+qM5DHLXrTKN6rkfj8awG9A@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
On 3/6/20 9:12 AM, Benson Margulies wrote:
> Executables built with (e.g.) g++ -static still show a runtime 
> dependency on /lib/ld-musl-x86_64.so.1. My recollection from the past 
> was that it was possible to achieve a completely static a.out. Is there 
> a way?
> 

It is not possible to run PIE binary without dynamic linker - it needs 
to do relocations at runtime.

I don't know if it's possible to bundle dynamic linker with your binary.
Benson Margulies <bimargulies@google.com>
Details
Message ID
<CAMfBnm9QoWmxXrJiUCSNefoJSryEkhxmu935FffbFZ3echUTdw@mail.gmail.com>
In-Reply-To
<b75869bb-311a-7f9e-0df1-2e0cda29e7b5@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thank you.

Is it possible to turn off the PIE?

I may be able to ship the linker along with, but I just want to understand
the options.

On Fri, Mar 6, 2020 at 12:42 AM Konstantin Kulikov <k.kulikov2@gmail.com>
wrote:

> On 3/6/20 9:12 AM, Benson Margulies wrote:
> > Executables built with (e.g.) g++ -static still show a runtime
> > dependency on /lib/ld-musl-x86_64.so.1. My recollection from the past
> > was that it was possible to achieve a completely static a.out. Is there
> > a way?
> >
>
> It is not possible to run PIE binary without dynamic linker - it needs
> to do relocations at runtime.
>
> I don't know if it's possible to bundle dynamic linker with your binary.
>
Marco Dickert <marco@misterunknown.de>
Details
Message ID
<20200309091814.GA9992@marco.themis.pinknet.de>
In-Reply-To
<CAMfBnm9QoWmxXrJiUCSNefoJSryEkhxmu935FffbFZ3echUTdw@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
On 2020-03-06 08:06:47, Benson Margulies wrote:
> Thank you.
> 
> Is it possible to turn off the PIE?

I wouldn't recommend that. As far as I understand one should be able to
compile static PIE binaries, at least with gcc [1]. See also the
documentation [2] for `--static-pie` (ctrl-f static-pie).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81498
[2] https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

-- 
Marco Dickert
marco@misterunknown.de
https://misterunknown.de
Reply to thread Export thread (mbox)