This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use ld to tell the full library path?


On 5/5/19 10:02 PM, Jeffrey Walton wrote:
Hi Everyone,

My apologies if this is the wrong approach to a problem...

I'm trying to test OpenSSL with Address Sanitizer (Asan). OpenSSL uses
their own practices in their build system, so the compiler/linker
cannot place Asan libraries first in the list (apparently this is an
Asan requirement).

The recommended workaround is to use LD_PRELOAD on Linux. Which leads
me to... is there a way to have ld tell me which Asan library will be
used when I use an option like -fsanitize=address or -lasan?

In Bash I was thinking something like:

     ASAN_LIB=$(ld -lasan)
     LD_PRELOAD="$ASAN_LIB:LD_PRELOAD" make check

(1) We're talking about ld.so (dynamic linker) not ld (static linker).

LD_PRELOAD is an environment variable that controls the behaviour of
the dynamic linker, and is not related to the manner in which the static
linker (ld) operates.

I'm adding libc-help to the CC, since this is a glibc issue.

(2) Linking everything with -fsanitize=address.

You really must link everything -fsanitize=address.

You cannot just preload the sanitization libraries.

Once you have everything properly linked then Asan should just work.

Granted I haven't looked at your particularly problem with OpenSSL,
but if you need more assitance you'll have to explain more detail
the exact nature of the problem with their build infrastructure.

Yes, Asan uses ELF interposition to replace system library functions
with santized versions, and this requires their libraries are first
in the symbol lookup path e.g. interpose the system versions.

(3) Enabling Asan

Why can't you enable Asan?

CC="gcc -fsanitize=address" ? That way you get CC down to all the
executables and libraries.

--
Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]