-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Milestone
Description
We do not emit _GLOBAL_OFFSET_TABLE_ symbol for x86-64 target. This symbol is required for enabling GOT-relative addressing that is used for large code model.
Reproducer:
#!/usr/bin/env bash
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 x86_64-pc-linux-gnu 1.c -c -ffunction-sections -fPIC
LDs=(ld.eld)
SFs=(eld)
for i in "${!SFs[@]}"; do
${LDs[$i]} -o lib1.${SFs[$i]}.so 1.o -shared
${LDs[$i]} -o 1.${SFs[$i]}.out 1.o
doneeld errors out with the below error, instead of implicitly providing the _GLOBAL_OFFSET_TABLE_ symbol.
Error: 1.o(.data+0x0): undefined reference to `_GLOBAL_OFFSET_TABLE_'
bhoumik03