Open appujee opened 1 year ago
Could you please try 16 or main
branch?
@llvm/issue-subscribers-lld-elf
Crashed with LLD 16.0.2 as well. With the same command line as attached in the rep.tar file.
Repro steps taken from https://github.com/android/ndk/issues/1817:
Use this entry.s
:
.data
.global _start
_start:
.long _start(GOT_PREL)
And this linker script test.ld
:
ENTRY(_start)
SECTIONS {
.data : { *(.data) }
.shstrtab : { *(.shstrtab) }
/DISCARD/ : { *(*) }
}
And use the following command line. Using LLD 16 should crash all the same.
$ ~/aosp-master-with-phones/prebuilts/clang/host/linux-x86/clang-r450784d1/bin/clang ~/g/bugs/ndk-1817/entry.s -c -o entry.o -target armv7-linux-android33 --sysroot ~/llvm-toolchain/toolchain/prebuilts/ndk/r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot
$ ~/aosp-master-with-phones/prebuilts/clang/host/linux-x86/clang-r450784d1/bin/clang -nostartfiles -nodefaultlibs -nostdlib -Wl,-T,test.ld entry.o -o test.elf -fuse-ld=lld -target armv7-linux-android33
This is crash on invalid input.
This -pie
use case is questionable. The output has GOT relocations, therefore .got
is needed. The linker script uses /DISCARD/ : { *(*) }
to discard .got
. At the minimum .got : { *(.got) }
is needed.
The experimental support for partitions requires in.got
to be live (partition != 0
). To fix the crash on invalid input, we can add a check to Relocations.cpp:addGotEntry
, but I feel bad to add the code for the invalid use case. GOT relocations are not at a performance bottleneck, so it may not be that bad.