-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld-macho] Check address ranges when applying relocations
This diff required fixing `getEmbeddedAddend` to apply sign extension to 32-bit values. We were previously passing around wrong 64-bit addend values that became "right" after being truncated back to 32-bit. I've also made `getEmbeddedAddend` return a signed int, which is similar to what LLD-ELF does for its `getImplicitAddend`. `reportRangeError`, `checkUInt`, and `checkInt` are counterparts of similar functions in LLD-ELF. Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D98387
- Loading branch information
Showing
7 changed files
with
139 additions
and
34 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
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,32 @@ | ||
# REQUIRES: x86 | ||
|
||
# RUN: split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o | ||
# RUN: %lld -dylib %t/bar.o -o %t/libbar.dylib | ||
# RUN: not %lld -lSystem -o /dev/null %t/libbar.dylib %t/test.o 2>&1 | FileCheck %s | ||
|
||
# CHECK: error: relocation UNSIGNED is out of range: 8589942792 is not in [0, 4294967295]; references _foo | ||
# CHECK: error: relocation GOT_LOAD is out of range: 4294974033 is not in [-2147483648, 2147483647]; references _foo | ||
# CHECK: error: stub is out of range: 4294974006 is not in [-2147483648, 2147483647]; references _bar | ||
# CHECK: error: stub helper header is out of range: 4294974005 is not in [-2147483648, 2147483647] | ||
# CHECK: error: stub helper header is out of range: 4294969893 is not in [-2147483648, 2147483647] | ||
|
||
#--- bar.s | ||
.globl _bar | ||
_bar: | ||
|
||
#--- test.s | ||
.globl _main, _foo | ||
|
||
_main: | ||
movq _foo@GOTPCREL(%rip), %rax | ||
callq _bar | ||
ret | ||
|
||
.int _foo | ||
.zerofill __TEXT,bss,_zero,0xffffffff | ||
|
||
.data | ||
_foo: | ||
.space 0 |