[PATCH v2] rtld: make ldd show relative addresses and add option for aligned output
Szabolcs Nagy
szabolcs.nagy@arm.com
Fri May 14 12:24:17 GMT 2021
The 05/14/2021 18:56, Michael Clark via Libc-alpha wrote:
> This change increases `ldd` readability:
>
> - modifies trace output to use relative addresses by default.
> - add alternative trace output mode with left-justified addresses.
>
> The relative addresses are composed by subtracting the ELF ehdr address
> which makes the output constant under address space layout randomization.
> This should be a safe change because the default format is preserved.
why would the numbers be constant?
the patch seems to subtract the *rtld* ehdr address from
the dso start addresses. aslr may not guarantee fixed
offset between dsos (even if linux does that now).
so if you want stable output just have an option to print 0.
> The intention is to make `ldd` easier to cross reference with objdump.
why is this easier wrt objdump?
> Also, log files including `ldd` output will contain less differences.
> The vdso is the only address that changes when using relative addresses.
...
> + /* base address (ld.so ehdr) used for relative display addresses */
> + size_t disp_addr, base_addr = (size_t) rtld_ehdr;
...
> + /* Subtract and negate base from load address if requested */
> + disp_addr = (size_t) l->l_map_start;
> + if (trace_addr_relative) disp_addr -= base_addr;
> + if (trace_addr_negate) disp_addr = -disp_addr;
More information about the Libc-alpha
mailing list