-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export
__global_pointer$
from executable
RISC-V psABI requires that symbol to be exported from an executable if there's a GP-relative reference. For simplicity, we always export it from executable as long as it has a .dynamic section. #1222
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
. $(dirname $0)/common.inc | ||
|
||
cat <<EOF | $CC -o $t/a.o -c -xc - -fPIC | ||
#include <stdio.h> | ||
int main() { | ||
printf("Hello world\n"); | ||
} | ||
EOF | ||
|
||
$CC -B. -o $t/exe1 $t/a.o -fno-PIE | ||
readelf -W --dyn-syms $t/exe1 | grep -Fq '__global_pointer$' | ||
|
||
$CC -B. -o $t/exe2 $t/a.o -fPIE | ||
readelf -W --dyn-syms $t/exe2 | grep -Fq '__global_pointer$' | ||
|
||
|
||
cat <<EOF | $CC -o $t/b.o -c -xc - -fPIC | ||
#include <stdio.h> | ||
int hello() { | ||
printf("Hello world\n"); | ||
} | ||
EOF | ||
|
||
$CC -B. -o $t/c.so $t/b.o -shared | ||
readelf -W --dyn-syms $t/c.so > $t/log1 | ||
! grep -Fq '__global_pointer$' $t/log1 || false |