-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. #796
Comments
|
when I use -static-libasan to generate an .so file ,and dlopen it failed: |
This happens because with -static-libasan linker still does not inject ASan runtime into .so files. You need link your binary with ASan (add -fsanitize=address -static-libasan to linkage flags) to make it work. |
I have add -fsanitize=address -static-libasan to LD_FLAGS ,then I get the error up |
Q: I've built my shared library with ASan. Can I run it with unsanitized executable? A: Yes! You'll need to build your library with dynamic version of ASan and then run executable with LD_PRELOAD=path/to/asan/runtime/lib. |
I found this in https://github.com/google/sanitizers/wiki/AddressSanitizer |
My code is gen an executable which would dlopen some shared library cam.so etc ,I ues same version of gcc 6.3 and same sanitizer flags -lasan , |
There is no
As @kcc mentioned,
It seems that your build is just broken -- cam.so seems to be built with GCC 4.9.
I guess using |
I found the LD_PRELOAD trick in FAQ is useful for running unsanitized executable with sanitized lib. |
Using LD_PRELOAD with -static-libasan is completely pointless. It's not suprising that this doesn't work.
Ok, could you do following things:
|
Of course,I have done 1 and 2 first of all. All of my words and error depends on building my executable and shared library with -fsanitize=address flag.
++++++++++++++++++++++ |
Please don't use |
1&2:
5 Dynamic section at offset 0x85ea0 contains 26 entries:
I would try install my gcc 6.3 again |
And LD_PRELOAD=<path_to_libasan/libasan.so> ./a.out doesn't work? |
it works as before, |
Again, please check |
and add libasan.so to /etc/ld.so.preload file,it works!!! |
then I get this waring when run others command |
Try to add full path to |
But note that adding |
As an alternative for |
- prevents error discussed here: google/sanitizers#796
- prevents error discussed here: google/sanitizers#796
- prevents error discussed here: google/sanitizers#796
- prevents error discussed here: google/sanitizers#796
- prevents error discussed here: google/sanitizers#796
- prevents error discussed here: google/sanitizers#796
Editing /etc/ld.so.preload broke my all ssh sessions. DO NOT EDIT THIS FILE. |
Before doing |
Just mentioning another hack to solve this issue:
I have a C++ program using |
try export ASAN_OPTIONS=verify_asan_link_order=0 I solve this issue by using above command。 And I am using gcc11 |
… we do use LD_PRELOAD in sthread See google/sanitizers#796 for more info
…in initial library list" Workaround for "ASan runtime does not come first in initial library list": added a task to disable ASAN link order verification by setting the `ASAN_OPTIONS` variable to `verify_asan_link_order=0`. See google/sanitizers#796
I work ASAN with GCC6.3, for later libFuzzer test.
But I got error as :
==48458==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
I can fix it by export LD_PRELOAD=/path/libasan.so.3
But I still confused,my code is ok with GCC4.9 and ASAN libasan.so.1.
So I try force link libasan.so by -lasan in the first place, it don't work.
Then I add -v to link command ,I found something
/usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/collect2 -plugin /usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/liblto_plugin.so -plugin-opt=/usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccVmBBY4.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lasan
gcc 6.3 use collect2 to do link instead of ld ,and it link ld-linux-x86-64.so.2 before libasan.so.
Do I get the real reason?
Any help will be appreciated.
The text was updated successfully, but these errors were encountered: