Switches to dynamorio_static_unhide for configuring static DR so that DR's symbols are visible when building static binaries.
Various symbols in dynamorio_static, like d_r_safe_read and
safe_read_if_fast in core/unix/os.c are non-weak symbols, but
they are not exported by the static DR library because we use
--localize_hidden
during build.
$ nm --defined ../../lib64/debug/libdynamorio_static.a | grep d_r_safe_read 00000000002962e8 t d_r_safe_read $ nm --defined ../../lib64/debug/libdynamorio_static.a | grep safe_read_if_fast 0000000000296272 t safe_read_if_fast
This causes drlibc code to use the wrong routines in is_elf_so_header. The same would happen for other weakly linked routines in drlibc which are actually supposed to be suppressed by their respective DR definitions.
There's an existing version of static DR, libdynamorio_static_nohide,
which does not use --localize_hidden
. Now, we use that instead
while configuring static DR.
This issue revealed itself on the recent Ubuntu 20 update which has a non-readable vsyscall entry in maps. When drlibc tries to read it, it crashes, and our main_signal_handler isn't able to recognize it as a safe_read crash because the incorrect d_r_safe read is used. After this fix, the correct one is used, which helps the DR signal handler to recover as intended.
Some cleanup will follow in the next PR: renaming the nohide version to make it clear that it is the default, evaluating whether we still need the static_nohide_api tests.
Issue: #5570 (closed)