llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

lld ignores symbols declared as EXTERN in linker script

Open ihalip opened this issue 7 years ago • 2 comments

Bugzilla Link 42329
Resolution WONTFIX
Resolved on Apr 11, 2020 12:02
Version unspecified
OS Linux
CC @MaskRay,@smithp35

Extended Description

ld.lld has a different behavior compared to GNU ld when it comes to adding undefined symbols from a linker script. Here's a simple test case:

$ touch a.c $ clang -c a.c -o a.o $ echo "EXTERN(test)" > a.lds $ ld.lld -T a.lds a.o -o a.out $ objdump -t a.out | grep test $

The resulting file doesn't contain the "test" symbol, which was added through the linker script. With GNU ld on the other hand:

$ ld -T a.lds a.o -o a.out $ objdump -t a.out | grep test 0000000000000000 UND 0000000000000000 test

ihalip avatar Jun 19 '19 16:06 ihalip

https://git.kernel.org/linus/7273ad2b08f8ac9563579d16a3cf528857b26f49 "kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"

removed reliance on the behavior! Read more on https://github.com/ClangBuiltLinux/linux/issues/515

MaskRay avatar Apr 11 '20 19:04 MaskRay

https://reviews.llvm.org/D63564

ihalip avatar Jun 19 '19 17:06 ihalip