diff options
author | Nelson Chu <nelson@rivosinc.com> | 2025-02-08 16:33:37 +0800 |
---|---|---|
committer | Nelson Chu <nelson@rivosinc.com> | 2025-03-07 10:51:08 +0800 |
commit | 4295841be4392fcff33a1efee6d4345063021e6b (patch) | |
tree | b7678e24660ef74d27ca6bc74617005187e36fad /ld/testsuite/ld-discard | |
parent | d07a59a5ca830bf74705471f6bea6db1a47da2b5 (diff) | |
download | binutils-master.zip binutils-master.tar.gz binutils-master.tar.bz2 |
I got an request about the undefined behaviors, considering the following case,
$ cat test.c
void main ()
{
foo();
}
$ cat lib.h
void foo(void);
$ riscv64-unknown-linux-gnu-gcc test.c
riscv64-unknown-linux-gnu/bin/ld: /tmp/ccRO8fJl.o: in function `main':
test.c:(.text+0x8): undefined reference to `foo'
collect2: error: ld returned 1 exit status
$ riscv64-unknown-linux-gnu-gcc test.c -Wl,--unresolved-symbols=ignore-in-object-files
$ qemu-riscv64 a.out
Segmentation fault (core dumped)
Testing with x86 and aarch64, they won't get the segfault since they go plt
for the undefined foo symbol. So, after applying this patch, I can get the
following too,
$ qemu-riscv64 a.out
a.out: symbol lookup error: a.out: undefined symbol: foo
The change of this patch should only affect the call behavior, which refer
to an undefined (weak) symbol, when building an dynamic executable. I think
the pic/pie behavior won't be affected as usual.
Diffstat (limited to 'ld/testsuite/ld-discard')
0 files changed, 0 insertions, 0 deletions