-Bsymbolic-functions is incompatible with ASan

Bug #2052954 reported by Max
This bug affects 1 person
Affects Status Importance Assigned to Milestone
clang (Ubuntu)

Bug Description

The linker flag -Bsymbolic-functions is default on Ubuntu (see `dpkg-buildflags --get LDFLAGS`). It is not default on Debian.

On Debian the `libclang_rt.asan-x86_64.so` exports `__asan_region_is_poisoned` as dynamic relocatable. On Ubuntu it is not relocatable. This is because of the linker flag just mentioend.
The impact is that on Debian, ASan will use the stub `__asan_region_is_poisoned` defined by the main binary.
On Ubuntu, ASan will use the `__asan_region_is_poisoned` from ASan, because it is statically referenced.

This can be checked using the following command:

$ objdump --dynamic-reloc $(clang -print-file-name=libclang_rt.asan-x86_64.so) | grep __asan_region_is_poisoned
# Debian: 00000000001091c0 R_X86_64_JUMP_SLOT __asan_region_is_poisoned@@Base
# Ubuntu: not found

This is problematic for the symbol `__asan_default_options`. Users can implement this function to configure ASan. This only works on Debian and not on Ubuntu, because Ubuntu's __asan_default_options is not relocatable. This bug was reported here: https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1964487

I'd suggest the following patch to the LLVM/Clang package:

ifneq (,$(LDFLAGS))
  LDFLAGS := $(filter-out %-Bsymbolic-functions,$(LDFLAGS))

Here is the related bug report for the LLVM project: https://github.com/llvm/llvm-project/issues/62431

Revision history for this message
Max (maxammann) wrote :

Another solution might be to allow-list certain functions using --dynamic-list

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.