public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* LD_PRELOAD doesn't work with dynamic object built with `-static-pie`
@ 2019-05-20 22:56 Baojun Wang
  2019-05-21  6:02 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Baojun Wang @ 2019-05-20 22:56 UTC (permalink / raw)
  To: libc-help

Hi libc,

I tried to build a shared object with `-static-pie`, and then used it as
`LD_PRELOAD`, but it didn't work, do you know why it failed? I put more
details in a gist:
https://gist.github.com/wangbj/3fb7356286ee38755005cbde26ca84ae

The reason I'm using this is to hope to create a shared object (.so)
without dependencies on any other libraries, but the shared object itself
can use library such as glibc.

Thanks
Baojun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LD_PRELOAD doesn't work with dynamic object built with `-static-pie`
  2019-05-20 22:56 LD_PRELOAD doesn't work with dynamic object built with `-static-pie` Baojun Wang
@ 2019-05-21  6:02 ` Florian Weimer
  2019-06-17 18:08   ` Baojun Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2019-05-21  6:02 UTC (permalink / raw)
  To: Baojun Wang; +Cc: libc-help

* Baojun Wang:

> I tried to build a shared object with `-static-pie`, and then used it as
> `LD_PRELOAD`, but it didn't work, do you know why it failed?

This will not work for multiple reasons.  The static PIE object will not
have a dynamic symbol table, so no interposition takes place.  It also
uses relocations which are not supported in ELF shared objects.

glibc 2.30 will provide a clearer diagnostic for this, rejecting loading
the object outright.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LD_PRELOAD doesn't work with dynamic object built with `-static-pie`
  2019-05-21  6:02 ` Florian Weimer
@ 2019-06-17 18:08   ` Baojun Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Baojun Wang @ 2019-06-17 18:08 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-help

Thank you for the clarification. I did turn on `LD_DEBUG` and was surprised
it didn't work.

On Tue, May 21, 2019 at 2:02 AM Florian Weimer <fweimer@redhat.com> wrote:

> * Baojun Wang:
>
> > I tried to build a shared object with `-static-pie`, and then used it as
> > `LD_PRELOAD`, but it didn't work, do you know why it failed?
>
> This will not work for multiple reasons.  The static PIE object will not
> have a dynamic symbol table, so no interposition takes place.  It also
> uses relocations which are not supported in ELF shared objects.
>
> glibc 2.30 will provide a clearer diagnostic for this, rejecting loading
> the object outright.
>
> Thanks,
> Florian
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-17 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 22:56 LD_PRELOAD doesn't work with dynamic object built with `-static-pie` Baojun Wang
2019-05-21  6:02 ` Florian Weimer
2019-06-17 18:08   ` Baojun Wang

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 read-only IMAP folder(s) and NNTP newsgroup(s).