-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Report an error for an unrepresentable reloc against abs symbol
PC-relative relocations against absolute symbols are not representable in position-independent code. In order to support such relocations, someone has to compute `S + A - P` or subtract `B` as a base relocation, but such dynamic relocations don't exist. This is contrary to non-PC-relative relocations against non-absolute symbols. In this case, we can simply use the base relocation (e.g. R_X86_64_RELATIVE). #348
- Loading branch information
Showing
5 changed files
with
84 additions
and
19 deletions.
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
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
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,26 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
CC="${CC:-cc}" | ||
CXX="${CXX:-c++}" | ||
testname=$(basename "$0" .sh) | ||
echo -n "Testing $testname ... " | ||
cd "$(dirname "$0")"/../.. | ||
mold="$(pwd)/mold" | ||
t=out/test/elf/$testname | ||
mkdir -p $t | ||
|
||
cat <<EOF | $CC -o $t/a.o -c -x assembler - | ||
.globl foo | ||
foo = 0x800000 | ||
EOF | ||
|
||
cat <<EOF | $CC -o $t/b.o -c -fPIC -xc - | ||
void foo(); | ||
int main() { foo(); } | ||
EOF | ||
|
||
! $CC -B. -o $t/exe -pie $t/a.o $t/b.o >& $t/log | ||
grep -q 'recompile with -fno-PIC' $t/log | ||
|
||
echo OK |