diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-01-21 10:20:50 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-02-10 09:16:13 -0300 |
commit | d7703d3176d225d5743b21811d888619eba39e82 (patch) | |
tree | 5a4586f8fe3459d45319cac801366dd92510d5b2 /elf | |
parent | 6628c742b2c16e785d3c884d9deeda5adb30ca12 (diff) | |
download | glibc-d7703d3176d225d5743b21811d888619eba39e82.zip glibc-d7703d3176d225d5743b21811d888619eba39e82.tar.gz glibc-d7703d3176d225d5743b21811d888619eba39e82.tar.bz2 |
malloc: Remove LD_TRACE_PRELINKING usage from mtrace
The fix for BZ#22716 replacde LD_TRACE_LOADED_OBJECTS with
LD_TRACE_PRELINKING so mtrace could record executable address
position.
To provide the same information, LD_TRACE_LOADED_OBJECTS is
extended where a value or '2' also prints the executable address
as well. It avoid adding another loader environment variable
to be used solely for mtrace. The vDSO will be printed as
a default library (with '=>' pointing the same name), which is
ok since both mtrace and ldd already handles it.
The mtrace script is changed to also parse the new format. To
correctly support PIE and non-PIE executables, both the default
mtrace address and the one calculated as used (it fixes mtrace
for non-PIE exectuable as for BZ#22716 for PIE).
Checked on x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-main.h | 3 | ||||
-rw-r--r-- | elf/rtld.c | 22 |
2 files changed, 16 insertions, 9 deletions
diff --git a/elf/dl-main.h b/elf/dl-main.h index 3e32f25..e4fa19e 100644 --- a/elf/dl-main.h +++ b/elf/dl-main.h @@ -94,6 +94,9 @@ struct dl_main_state enum rtld_mode mode; + /* True if program should be also printed for rtld_mode_trace. */ + bool mode_trace_program; + /* True if any of the debugging options is enabled. */ bool any_debug; @@ -2104,18 +2104,18 @@ dl_main (const ElfW(Phdr) *phdr, _dl_printf ("\tstatically linked\n"); else { - for (l = main_map->l_next; l; l = l->l_next) + for (l = state.mode_trace_program ? main_map : main_map->l_next; + l; l = l->l_next) { if (l->l_faked) /* The library was not found. */ - _dl_printf ("\t%s => not found\n", l->l_libname->name); - else if (strcmp (l->l_libname->name, l->l_name) == 0) - _dl_printf ("\t%s (0x%0*Zx)\n", l->l_libname->name, - (int) sizeof l->l_map_start * 2, - (size_t) l->l_map_start); + _dl_printf ("\t%s => not found\n", l->l_libname->name); else - _dl_printf ("\t%s => %s (0x%0*Zx)\n", l->l_libname->name, - l->l_name, (int) sizeof l->l_map_start * 2, + _dl_printf ("\t%s => %s (0x%0*Zx)\n", + DSO_FILENAME (l->l_libname->name), + DSO_FILENAME (l->l_name), + (int) sizeof l->l_map_start * 2, (size_t) l->l_map_start); + } } if (__glibc_unlikely (state.mode != rtld_mode_trace)) @@ -2676,7 +2676,11 @@ process_envvars (struct dl_main_state *state) case 20: /* The mode of the dynamic linker can be set. */ if (memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0) - state->mode = rtld_mode_trace; + { + state->mode = rtld_mode_trace; + state->mode_trace_program + = _dl_strtoul (&envline[21], NULL) > 1; + } break; /* We might have some extra environment variable to handle. This |