[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2022-11-11 Thread mkh199740 at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

--- Comment #8 from lo1ol  ---
https://www.youtube.com/watch?v=Ua3TiOSwVTI

[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2022-07-18 Thread boris at kolpackov dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

Boris Kolpackov  changed:

   What|Removed |Added

 CC||boris at kolpackov dot net

--- Comment #7 from Boris Kolpackov  ---
> But why do you want to use -static-libasan ?  Just link it dynamically...

Another reason is shared linking clobbers executable's RUNPATH:
https://github.com/google/sanitizers/issues/1219

[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2022-05-31 Thread mkh199740 at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

lo1ol  changed:

   What|Removed |Added

 CC||mkh199740 at mail dot ru

--- Comment #6 from lo1ol  ---
I've the same problem when try to link at runtime shared library compiled with
static asan. Here is minimal example:

echo '
#include 
#include 

void f(){
int* x = new int;
printf("kek\n");
}' > lib.cpp

echo '
#include 
#include 
int main() {
printf("lol\n");
void* handler = dlopen("./libkek.so", RTLD_NOW);
if (!handler)
return 1;

void (* func)() = reinterpret_cast(dlsym(handler, "_Z1fv"));
printf("kek\n");
func();
printf("cheburek\n");
}' > main.cpp


g++ -fsanitize=address -static-libasan -static-libstdc++ -static-libgcc -fPIC
-shared lib.cpp -o libkek.so
g++ -fsanitize=address -static-libasan -static-libstdc++ -static-libgcc -ldl
main.cpp
LD_DEBUG=libs ./a.out; echo $?

Part of the output:
...
347802: initialize program: ./a.out
347802:
347802:
347802: transferring control: ./a.out
347802:
lol
347802: ./libkek.so: error: symbol lookup error: undefined symbol:
__asan_unregister_globals (fatal)
347802:
347802: calling fini: ./a.out [0]
347802:
347802:
347802: calling fini: /lib/x86_64-linux-gnu/libm.so.6 [0]
347802:


With clang everything is ok

GCC version 12.1
System: Ubuntu 21.10

[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2017-10-31 Thread ygribov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

Yury Gribov  changed:

   What|Removed |Added

 CC||ygribov at gcc dot gnu.org

--- Comment #5 from Yury Gribov  ---
Few workarounds for this are listed in
https://stackoverflow.com/questions/46682210/undefined-symbol-error-with-static-libasan/46684596#46684596

[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2014-12-09 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

--- Comment #1 from Jakub Jelinek jakub at gcc dot gnu.org ---
I think we can only recommend not to do that, or suggest users to consider
-Wl,-E.  The linker automatically makes symbols mentioned in dependent
libraries exported from binaries, but e.g. implying -Wl,-E from -static-libasan
is IMNSHO undesirable, it doesn't make just the selected few symbols dynamic,
but all, and that really should be users decision whether it is desirable or
not.


[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2014-12-09 Thread y.gribov at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

--- Comment #2 from Yury Gribov y.gribov at samsung dot com ---
(In reply to Jakub Jelinek from comment #1)
 I think we can only recommend not to do that

For legacy codebase (e.g. when sanitizing full distributions) you often don't
have a choice.

 implying -Wl,-E from -static-libasan is IMNSHO undesirable,
 it doesn't make just the selected few symbols dynamic, but all,

Right, -Wl,-E would be an overkill.  AFAIK Clang automatically appends
--dynamic-list=something.syms when it compiles sanitized executable.  Perhaps
we could do this as well?


[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2014-12-09 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

--- Comment #3 from Jakub Jelinek jakub at gcc dot gnu.org ---
But why do you want to use -static-libasan ?  Just link it dynamically...
--dynamic-list is hard to maintain, aren't there hundreds of symbols that are
exported from libasan?


[Bug sanitizer/64234] Statically sanitized executable does not export ASan symbols

2014-12-09 Thread y.gribov at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64234

--- Comment #4 from Yury Gribov y.gribov at samsung dot com ---
(In reply to Jakub Jelinek from comment #3)
 But why do you want to use -static-libasan ?  Just link it dynamically...

For one thing it can speed up code by avoiding PLT calls.  

 --dynamic-list is hard to maintain, aren't there hundreds of symbols that
 are exported from libasan?

Indeed there are, upstream has a special script to autogenerate file with
symbols.