diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-02-08 19:58:43 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-02-15 11:01:23 +0100 |
commit | 3a0ecccb599a6b1ad4b149dc569c0080e92d057b (patch) | |
tree | e1c4c0e5f2e80221054d6bb6260b4038e27567b4 /elf/rtld.c | |
parent | 2efa52c880d46ee89523c8ed8102ceeb02043926 (diff) | |
download | glibc-3a0ecccb599a6b1ad4b149dc569c0080e92d057b.zip glibc-3a0ecccb599a6b1ad4b149dc569c0080e92d057b.tar.gz glibc-3a0ecccb599a6b1ad4b149dc569c0080e92d057b.tar.bz2 |
ld.so: Do not export free/calloc/malloc/realloc functions [BZ #25486]
Exporting functions and relying on symbol interposition from libc.so
makes the choice of implementation dependent on DT_NEEDED order, which
is not what some compiler drivers expect.
This commit replaces one magic mechanism (symbol interposition) with
another one (preprocessor-/compiler-based redirection). This makes
the hand-over from the minimal malloc to the full malloc more
explicit.
Removing the ABI symbols is backwards-compatible because libc.so is
always in scope, and the dynamic loader will find the malloc-related
symbols there since commit f0b2132b35248c1f4a80f62a2c38cddcc802aa8c
("ld.so: Support moving versioned symbols between sonames
[BZ #24741]").
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'elf/rtld.c')
-rw-r--r-- | elf/rtld.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -534,6 +534,9 @@ _dl_start (void *arg) header table in core. Put the rest of _dl_start into a separate function, that way the compiler cannot put accesses to the GOT before ELF_DYNAMIC_RELOCATE. */ + + __rtld_malloc_init_stubs (); + { #ifdef DONT_USE_BOOTSTRAP_MAP ElfW(Addr) entry = _dl_start_final (arg); @@ -2210,6 +2213,10 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]); rtld_timer_stop (&relocate_time, start); } + /* The library defining malloc has already been relocated due to + prelinking. Resolve the malloc symbols for the dynamic + loader. */ + __rtld_malloc_init_real (main_map); /* Mark all the objects so we know they have been already relocated. */ for (struct link_map *l = main_map; l != NULL; l = l->l_next) @@ -2310,6 +2317,11 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]); re-relocation, we might call a user-supplied function (e.g. calloc from _dl_relocate_object) that uses TLS data. */ + /* The malloc implementation has been relocated, so resolving + its symbols (and potentially calling IFUNC resolvers) is safe + at this point. */ + __rtld_malloc_init_real (main_map); + RTLD_TIMING_VAR (start); rtld_timer_start (&start); |