On 31.10.2017 19:45, Jakub Jelinek wrote: > On Tue, Oct 31, 2017 at 07:28:23PM +0100, Kamil Rytarowski wrote: >> I'm giving it a try. I took the asan part and skipped >> "%{!shared:libasan_preinit%O%s} ". If I understand this correctly, it >> attempts to use the ELF section with preinit property in order to >> bootstrap asan quickly. The preinit sections are not enabled on >> NetBSD/amd64. From my understanding, there is a design choice in NetBSD >> to not include extensional sections unless they are requested by ABI. > > ?? SHT_PREINIT_ARRAY/DT_PREINIT_ARRAY/DT_PREINIT_ARRAYSZ is not any > kind of extension, it is an integral part of the ELF gABI: > http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#dynamic_section > And that is quite essential for proper asan behavior, because the library > interposes a lot of functions and if they are invoked before the library > is initialized, they crash (of course better would be to fix the library > not to rely on that and initialize the minimal stuff needed for > interposition if they are called before the initialization, but that is > unlikely to happen upstream). > > Jakub > Right now this is only Linux-specific at least in asan/LLVM. // We can use .preinit_array section on Linux to call sanitizer initialization // functions very early in the process startup (unless PIC macro is defined). // FIXME: do we have anything like this on Mac? #if SANITIZER_LINUX && !SANITIZER_ANDROID && !defined(PIC) # define SANITIZER_CAN_USE_PREINIT_ARRAY 1 #else # define SANITIZER_CAN_USE_PREINIT_ARRAY 0 #endif -- lib/sanitizer_common/sanitizer_internal_defs.h NetBSD needs to use different ways to initialize, like through interception of a call and during this stage bootstrap initialization bits. The tricky part is that we cannot initialize a sanitizer before sufficient libc+libpthread bootstrap and this is my current obstacle with tsan. Specifying new LIBASAN_EARLY_SPEC does not fix the "AddressSanitizer can not provide additional info." problem.