Skip to content

Commit b181c22

Browse files
authored
[lldb][RISCV] Fixed TestSymbolFileJSON for RISC-V (llvm#161497)
This test failed during testing on the RISC-V target because we couldn't strip the main label from the binary. main is dynamically linked when the -fPIC flag is enabled. The RISC-V ABI requires that executables support loading at arbitrary addresses to enable shared libraries and secure loading (ASLR). In PIC mode, function addresses cannot be hardcoded in the code. Instead, code is generated to load addresses from the GOT/PLT tables, which are initialized by the dynamic loader. The reference to main thus ends up in .dynsym and is dynamically bound. We cannot strip main or any other dynamically linked functions because these functions are referenced indirectly via dynamic linking tables (.plt and .got). Removing these symbols would break the dynamic linking mechanism needed to resolve function addresses at runtime, causing the executable to fail to correctly call them.
1 parent 11a4b2d commit b181c22

File tree

1 file changed

+1
-0
lines changed
  • lldb/test/API/functionalities/json/symbol-file

1 file changed

+1
-0
lines changed

lldb/test/API/functionalities/json/symbol-file/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
C_SOURCES := main.c
2+
CFLAGS_EXTRAS := -no-pie
23

34
all: stripped.out
45

0 commit comments

Comments
 (0)