* libc.so, Bsymbolic no longer necessary?
@ 2019-12-02 4:23 Jon Chesterfield
2019-12-02 4:39 ` Fangrui Song
0 siblings, 1 reply; 3+ messages in thread
From: Jon Chesterfield @ 2019-12-02 4:23 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
Hey,
The early design notes for musl mention linking with Bsymbolic, which
seemed reasonable. I don't see that in the current Makefile, or the
equivalent protected visibility.
This seems to suggest that LD_PRELOAD can override calls to libc from
within libc. That seems dubious. Is there a use case for this? Or is it
avoided by the control flow in the loader itself?
I'm thinking of building the musl loader/libc elf with protected visibility
on the exported symbols and wondered whether I'm missing something.
Thanks,
Jon
[-- Attachment #2: Type: text/html, Size: 794 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libc.so, Bsymbolic no longer necessary?
2019-12-02 4:23 libc.so, Bsymbolic no longer necessary? Jon Chesterfield
@ 2019-12-02 4:39 ` Fangrui Song
2019-12-02 4:44 ` Jon Chesterfield
0 siblings, 1 reply; 3+ messages in thread
From: Fangrui Song @ 2019-12-02 4:39 UTC (permalink / raw)
To: Jon Chesterfield; +Cc: musl
On 2019-12-02, Jon Chesterfield wrote:
>Hey,
>
>The early design notes for musl mention linking with Bsymbolic, which seemed
>reasonable. I don't see that in the current Makefile, or the equivalent
>protected visibility.
>
>This seems to suggest that LD_PRELOAD can override calls to libc from within
>libc. That seems dubious. Is there a use case for this? Or is it avoided by the
>control flow in the loader itself?
>
>I'm thinking of building the musl loader/libc elf with protected visibility on
>the exported symbols and wondered whether I'm missing something.
-Bsymbolic-functions was changed to --dynamic-list in commit
b9410061e2ad6fe91bb3910c3adc7d4a315b7ce9 (2018-04).
The file dynamic.list lists the symbols that can be interposed.
Among the list you can find allocator functions (malloc and its
friends) See commit c9f415d7ea2dace5bf77f6518b6afc36bb7a5732
Some notes:
An empty --dynamic-list is identical to -Bsymbolic.
--dynamic-list with a list that specifies all STT_OBJECT symbols is
similar to -Bsymbolic-function. Specifying STT_OBJECT symbols (e.g.
stdin/stdout/environ) is to support COPY relocations.
// lld/ELF/Writer.cpp
static bool computeIsPreemptible(const Symbol &b) {
assert(!b.isLocal());
// Only symbols that appear in dynsym can be preempted.
if (!b.includeInDynsym())
return false;
// Only default visibility symbols can be preempted.
if (b.visibility != STV_DEFAULT)
return false;
// At this point copy relocations have not been created yet, so any
// symbol that is not defined locally is preemptible.
if (!b.isDefined())
return true;
if (!config->shared)
return false;
// If the dynamic list is present, it specifies preemptable symbols in a DSO.
if (config->hasDynamicList)
return b.inDynamicList;
// -Bsymbolic means that definitions are not preempted.
if (config->bsymbolic || (config->bsymbolicFunctions && b.isFunc()))
return false;
return true;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libc.so, Bsymbolic no longer necessary?
2019-12-02 4:39 ` Fangrui Song
@ 2019-12-02 4:44 ` Jon Chesterfield
0 siblings, 0 replies; 3+ messages in thread
From: Jon Chesterfield @ 2019-12-02 4:44 UTC (permalink / raw)
To: Fangrui Song; +Cc: musl
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
>
> -Bsymbolic-functions was changed to --dynamic-list in commit
> b9410061e2ad6fe91bb3910c3adc7d4a315b7ce9 (2018-04).
>
Nice! Thanks
>
[-- Attachment #2: Type: text/html, Size: 533 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-02 4:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 4:23 libc.so, Bsymbolic no longer necessary? Jon Chesterfield
2019-12-02 4:39 ` Fangrui Song
2019-12-02 4:44 ` Jon Chesterfield
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).