Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 380 by [email protected]: link error when LDFLAGS has -Wl,--no-undefined
https://code.google.com/p/address-sanitizer/issues/detail?id=380

What steps will reproduce the problem?
1.
The following is libtest.cpp
        #include <stdio.h>
        void print(int *pBuf, int size) {
                for (int i = 0; i < size; ++i)
                {
                        printf("%d ", pBuf[i]);
                }
                printf("\n");
        }
2.Run the following build.sh
#!/bin/sh
set -x
#PASS
clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so
#PASS
clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address
#FAIL
clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address -Wl,--no-undefined

#PASS
g++-4.9 -shared -fPIC libtest.cpp -o libtest.so
#PASS
g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address
#FAIL
g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address -Wl,--no-undefined


What is the expected output? What do you see instead?
If the two link flags are set, "-fsanitize=address -Wl,--no-undefined", the linker will fail always. I hope it should work with both.

+ clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so
+ clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address
+ clang++-3.6 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address -Wl,--no-undefined
/tmp/libtest-ecd182.o: In function `print(int*, int)':
libtest.cpp:(.text+0x16): undefined reference to `__asan_option_detect_stack_use_after_return'
libtest.cpp:(.text+0x55): undefined reference to `__asan_stack_malloc_1'
libtest.cpp:(.text+0x133): undefined reference to `__asan_report_store8'
libtest.cpp:(.text+0x18b): undefined reference to `__asan_report_store4'
libtest.cpp:(.text+0x1e1): undefined reference to `__asan_report_store4'
libtest.cpp:(.text+0x231): undefined reference to `__asan_report_load4'
libtest.cpp:(.text+0x284): undefined reference to `__asan_report_load4'
libtest.cpp:(.text+0x2da): undefined reference to `__asan_report_load4'
libtest.cpp:(.text+0x307): undefined reference to `__asan_report_load8'
libtest.cpp:(.text+0x363): undefined reference to `__asan_report_load4'
libtest.cpp:(.text+0x3c1): undefined reference to `__asan_report_load4'
/tmp/libtest-ecd182.o: In function `asan.module_ctor':
libtest.cpp:(.text+0x455): undefined reference to `__asan_init_v5'
libtest.cpp:(.text+0x468): undefined reference to `__asan_register_globals'
/tmp/libtest-ecd182.o: In function `asan.module_dtor':
libtest.cpp:(.text+0x483): undefined reference to `__asan_unregister_globals' clang: error: linker command failed with exit code 1 (use -v to see invocation)
+ g++-4.9 -shared -fPIC libtest.cpp -o libtest.so
+ g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address
+ g++-4.9 -shared -fPIC libtest.cpp -o libtest.so -fsanitize=address -Wl,--no-undefined
/tmp/ccRlkbkY.o: In function `print(int*, int)':
libtest.cpp:(.text+0x60): undefined reference to `__asan_report_load4'
/tmp/ccRlkbkY.o: In function `_GLOBAL__sub_D_00099_0_libtest.cpp':
libtest.cpp:(.text+0xa2): undefined reference to `__asan_unregister_globals'
/tmp/ccRlkbkY.o: In function `_GLOBAL__sub_I_00099_1_libtest.cpp':
libtest.cpp:(.text+0xad): undefined reference to `__asan_init_v3'
libtest.cpp:(.text+0xbe): undefined reference to `__asan_register_globals'
collect2: error: ld returned 1 exit status

What version of the product are you using? On what operating system?
Ubuntu 12.04 X86-64 LTS, clang 3.6(http://llvm.org/apt/) / gcc 4.9.2(https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=precise)

Please provide any additional information below.



Attachments:
        libtest.cpp  144 bytes
        build.sh  468 bytes

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to