ELD does not emit GLOBAL_OFFSET_TABLE symbol for RISCV targets. This symbol is required for enabling GOT-relative addressing.
Reproducer:
cat >1.c <<\EOF
extern int _GLOBAL_OFFSET_TABLE_;
int *v = &_GLOBAL_OFFSET_TABLE_;
int a;
int foo() { return a; }
EOF
clang -o 1.o -target riscv64 1.c -c -ffunction-sections -fPIC
ld.eld -o 1.eld.out 1.o -mtriple riscv64-unknown-elf
Error:
Error: 1.o(.data+0x0): undefined reference to `_GLOBAL_OFFSET_TABLE_'
Fatal: Linking had errors.
ELD does not emit GLOBAL_OFFSET_TABLE symbol for RISCV targets. This symbol is required for enabling GOT-relative addressing.
Reproducer:
Error: