Update patches for lld 3.9
The previously existing patch needed some modifications to fit on top of lld 3.9. Patch 2 makes sure that one still can use the lld built in this way for linking in MSVC mode. Patch 3 fixes linking binaries larger than 4 MB or so (previously the binaries linked fine but didn't work). Patch 4 makes sure to error out if the relocations are too far away (instead of producing a broken binary), which happens after 16 MB. Patch 5 fixes relocations that have an offset, which probably happens in hand-written assembly (in libav).
This commit is contained in:
1 parent
3eb63bea3d
commit
93a77a441a
5 files changed
+341
-65
No files matched your search
@@ -0,0 +1,82 @@
|
||||
From 2f3ad0343836886143c1f8ac83552c6734e05205 Mon Sep 17 00:00:00 2001
|
||||
From: Saleem Abdulrasool <compnerd@compnerd.org>
|
||||
Date: Fri, 5 Aug 2016 17:28:21 +0000
|
||||
Subject: [PATCH 3/5] COFF ARM: Clear the J1 and J2 bits when applying
|
||||
relocations to 24 bit branches
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The opcode for the bl branches can initially be F000 F800, i.e.
|
||||
the J1 and J2 bits are already set. Therefore mask these bits out
|
||||
before or'ing in the new bits.
|
||||
|
||||
Patch by Martin Storsjö!
|
||||
|
||||
Cherry-picked from SVN trunk commit 277836, git mirror commit
|
||||
7b7d94e63a.
|
||||
---
|
||||
COFF/Chunks.cpp | 3 ++-
|
||||
test/COFF/reloc-arm.test | 13 +++++++++++--
|
||||
2 files changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/COFF/Chunks.cpp b/COFF/Chunks.cpp
|
||||
index 1c1b181..2e6f535 100644
|
||||
--- a/COFF/Chunks.cpp
|
||||
+++ b/COFF/Chunks.cpp
|
||||
@@ -103,7 +103,8 @@ static void applyBranch24T(uint8_t *Off, int32_t V) {
|
||||
uint32_t J1 = ((~V >> 23) & 1) ^ S;
|
||||
uint32_t J2 = ((~V >> 22) & 1) ^ S;
|
||||
or16(Off, (S << 10) | ((V >> 12) & 0x3ff));
|
||||
- or16(Off + 2, (J1 << 13) | (J2 << 11) | ((V >> 1) & 0x7ff));
|
||||
+ // Clear out the J1 and J2 bits which may be set.
|
||||
+ write16le(Off + 2, (read16le(Off + 2) & 0xd000) | (J1 << 13) | (J2 << 11) | ((V >> 1) & 0x7ff));
|
||||
}
|
||||
|
||||
void SectionChunk::applyRelARM(uint8_t *Off, uint16_t Type, Defined *Sym,
|
||||
diff --git a/test/COFF/reloc-arm.test b/test/COFF/reloc-arm.test
|
||||
index 11b863d..f7656e7 100644
|
||||
--- a/test/COFF/reloc-arm.test
|
||||
+++ b/test/COFF/reloc-arm.test
|
||||
@@ -9,7 +9,7 @@
|
||||
# CHECK: 402030 fe07e62f 00000000 00000000 00000000
|
||||
# CHECK: 402040 3e04de2f 00000000 00000000 00000000
|
||||
# CHECK: 402050 fe07d62f 00000000 00000000 00000000
|
||||
-# CHECK: 402060 00000000 00000000 00000000 00000000
|
||||
+# CHECK: 402060 fef0cef7 00000000 00000000 00000000
|
||||
|
||||
--- !COFF
|
||||
header:
|
||||
@@ -23,7 +23,7 @@ sections:
|
||||
- Name: .text
|
||||
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_16BIT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
|
||||
Alignment: 4096
|
||||
- SectionData: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
+ SectionData: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f000f8000000000000000000000000
|
||||
Relocations:
|
||||
- VirtualAddress: 0
|
||||
SymbolName: foo
|
||||
@@ -43,6 +43,9 @@ sections:
|
||||
- VirtualAddress: 80
|
||||
SymbolName: foo
|
||||
Type: 21 # IMAGE_REL_AMD64_BLX23T
|
||||
+ - VirtualAddress: 96
|
||||
+ SymbolName: bar
|
||||
+ Type: 20 # IMAGE_REL_ARM_BRANCH24T
|
||||
symbols:
|
||||
- Name: .aaa
|
||||
Value: 0
|
||||
@@ -68,4 +71,10 @@ symbols:
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
+ - Name: bar
|
||||
+ Value: 0x500000
|
||||
+ SectionNumber: 1
|
||||
+ SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
+ ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
...
|
||||
--
|
||||
2.7.4
|
||||
|
||||
Reference in new issue
Block a user