[lld] r352325 - [COFF] Add support for the new relocation IMAGE_REL_ARM{, 64}_REL32
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 27 11:57:50 PST 2019
Author: mstorsjo
Date: Sun Jan 27 11:57:50 2019
New Revision: 352325
URL: http://llvm.org/viewvc/llvm-project?rev=352325&view=rev
Log:
[COFF] Add support for the new relocation IMAGE_REL_ARM{,64}_REL32
Differential Revision: https://reviews.llvm.org/D57292
Added:
lld/trunk/test/COFF/armnt-rel32.yaml
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/test/COFF/arm64-relocs-imports.test
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=352325&r1=352324&r2=352325&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Sun Jan 27 11:57:50 2019
@@ -198,6 +198,7 @@ void SectionChunk::applyRelARM(uint8_t *
case IMAGE_REL_ARM_BLX23T: applyBranch24T(Off, SX - P - 4); break;
case IMAGE_REL_ARM_SECTION: applySecIdx(Off, OS); break;
case IMAGE_REL_ARM_SECREL: applySecRel(this, Off, OS, S); break;
+ case IMAGE_REL_ARM_REL32: add32(Off, SX - P - 4); break;
default:
error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " +
toString(File));
@@ -309,6 +310,7 @@ void SectionChunk::applyRelARM64(uint8_t
case IMAGE_REL_ARM64_SECREL_HIGH12A: applySecRelHigh12A(this, Off, OS, S); break;
case IMAGE_REL_ARM64_SECREL_LOW12L: applySecRelLdr(this, Off, OS, S); break;
case IMAGE_REL_ARM64_SECTION: applySecIdx(Off, OS); break;
+ case IMAGE_REL_ARM64_REL32: add32(Off, S - P - 4); break;
default:
error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " +
toString(File));
Modified: lld/trunk/test/COFF/arm64-relocs-imports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/arm64-relocs-imports.test?rev=352325&r1=352324&r2=352325&view=diff
==============================================================================
--- lld/trunk/test/COFF/arm64-relocs-imports.test (original)
+++ lld/trunk/test/COFF/arm64-relocs-imports.test Sun Jan 27 11:57:50 2019
@@ -45,12 +45,13 @@
# BEFORE: 90: 20 1a 09 30 adr x0, #74565
# BEFORE: 94: 01 00 00 54 b.ne #0
# BEFORE: 98: 00 00 00 36 tbz w0, #0, #0
+# BEFORE: 9c: 01 00 00 00 udf #1
# AFTER: Disassembly of section .text:
# AFTER: 140001000: fe 0f 1f f8 str x30, [sp, #-16]!
# AFTER: 140001004: 00 00 00 b0 adrp x0, #4096
# AFTER: 140001008: 00 18 00 91 add x0, x0, #6
-# AFTER: 14000100c: 24 00 00 94 bl #144
+# AFTER: 14000100c: 25 00 00 94 bl #148
# AFTER: 140001010: 00 21 40 39 ldrb w0, [x8, #8]
# AFTER: 140001014: 00 11 40 79 ldrh w0, [x8, #8]
# AFTER: 140001018: 00 09 40 b9 ldr w0, [x8, #8]
@@ -84,11 +85,12 @@
# AFTER: 140001088: 00 c4 41 f9 ldr x0, [x0, #904]
# AFTER: 14000108c: 03 00 00 00 udf #3
# AFTER: 140001090: e0 95 09 30 adr x0, #78525
-# AFTER: 140001094: 41 00 00 54 b.ne #8
-# AFTER: 140001098: 20 00 00 36 tbz w0, #0, #4
-# AFTER: 14000109c: 10 00 00 b0 adrp x16, #4096
-# AFTER: 1400010a0: 10 2a 40 f9 ldr x16, [x16, #80]
-# AFTER: 1400010a4: 00 02 1f d6 br x16
+# AFTER: 140001094: 61 00 00 54 b.ne #12
+# AFTER: 140001098: 40 00 00 36 tbz w0, #0, #8
+# AFTER: 14000109c: 61 ff ff ff <unknown>
+# AFTER: 1400010a0: 10 00 00 b0 adrp x16, #4096
+# AFTER: 1400010a4: 10 2a 40 f9 ldr x16, [x16, #80]
+# AFTER: 1400010a8: 00 02 1f d6 br x16
--- !COFF
header:
@@ -98,7 +100,7 @@ sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 4
- SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F90001003900010079000100B9000100F90001403D0001407D000140BD000140FD0001C03D0001003D0001007D000100BD000100FD0001803D000540F9201A01B000FC4FF9E0031F2AFE0741F8C0035FD6080000000000000001000000010000000000009100004091000040f901000000201a09300100005400000036
+ SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F90001003900010079000100B9000100F90001403D0001407D000140BD000140FD0001C03D0001003D0001007D000100BD000100FD0001803D000540F9201A01B000FC4FF9E0031F2AFE0741F8C0035FD6080000000000000001000000010000000000009100004091000040f901000000201a0930010000540000003601000000
Relocations:
- VirtualAddress: 4
SymbolName: .Lstr
@@ -202,6 +204,9 @@ sections:
- VirtualAddress: 152
SymbolName: function
Type: IMAGE_REL_ARM64_BRANCH14
+ - VirtualAddress: 156
+ SymbolName: main
+ Type: IMAGE_REL_ARM64_REL32
- Name: .data
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
Alignment: 4
Added: lld/trunk/test/COFF/armnt-rel32.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/armnt-rel32.yaml?rev=352325&view=auto
==============================================================================
--- lld/trunk/test/COFF/armnt-rel32.yaml (added)
+++ lld/trunk/test/COFF/armnt-rel32.yaml Sun Jan 27 11:57:50 2019
@@ -0,0 +1,47 @@
+# REQUIRES: arm
+
+# RUN: yaml2obj < %s > %t.obj
+# RUN: llvm-objdump -s %t.obj | FileCheck %s -check-prefix BEFORE
+# RUN: lld-link /entry:function /subsystem:console /out:%t.exe %t.obj
+# RUN: llvm-objdump -s %t.exe | FileCheck %s -check-prefix AFTER
+
+# BEFORE: Contents of section .text:
+# BEFORE: 0000 704700bf 01000000 01000000
+
+# AFTER: Contents of section .text:
+# AFTER: 401000 704700bf faffffff f50f0000
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_ARMNT
+ Characteristics: []
+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: 4
+ SectionData: 704700BF0100000001000000
+ Relocations:
+ - VirtualAddress: 4
+ SymbolName: function
+ Type: IMAGE_REL_ARM_REL32
+ - VirtualAddress: 8
+ SymbolName: data
+ Type: IMAGE_REL_ARM_REL32
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 00
+symbols:
+ - Name: function
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: data
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
More information about the llvm-commits
mailing list