diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp index c99015275b63..04ab7ab8327a 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp @@ -81,7 +81,10 @@ static Reference::Addend readAddend(const uint8_t *location, Reference::KindValue kindValue) { switch (kindValue) { case R_ARM_ABS32: + case R_ARM_REL32: return (int32_t)read32le(location); + case R_ARM_PREL31: + return (int32_t)(read32le(location) & 0x7FFFFFFF); case R_ARM_THM_CALL: case R_ARM_THM_JUMP24: return readAddend_THM_CALL(location); diff --git a/lld/test/elf/ARM/rel-arm-prel31.test b/lld/test/elf/ARM/rel-arm-prel31.test index b5313164cc19..1effc4eceb0e 100644 --- a/lld/test/elf/ARM/rel-arm-prel31.test +++ b/lld/test/elf/ARM/rel-arm-prel31.test @@ -5,10 +5,9 @@ # RUN: llvm-objdump -s -t %t | FileCheck %s # CHECK: Contents of section .ARM.extab: -# CHECK: 4000a4 b1ffff7f +# CHECK: 4000a4 b1fffe7f # CHECK: SYMBOL TABLE: -# CHECK: 00000000 *UND* 00000000 -# CHECK: 00400054 g F .text 00000050 __gxx_personality_v0 +# CHECK: 00400054 g F .text {{[0-9a-f]+}} __gxx_personality_v0 --- FileHeader: @@ -22,7 +21,7 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] AddressAlign: 0x4 - Content: 0000000084019701B0B0B008FFFF01080E2432003A040000 + Content: 0000FF7F84019701B0B0B008FFFF01080E2432003A040000 - Name: .rel.ARM.extab Type: SHT_REL Link: .symtab diff --git a/lld/test/elf/ARM/rel-rel32.test b/lld/test/elf/ARM/rel-rel32.test index 389927862483..47779ac918e3 100644 --- a/lld/test/elf/ARM/rel-rel32.test +++ b/lld/test/elf/ARM/rel-rel32.test @@ -5,10 +5,10 @@ # RUN: llvm-objdump -s -t %t | FileCheck %s # CHECK: Contents of section .text: -# CHECK-NEXT: 400074 80b400af 880f0000 +# CHECK-NEXT: 400074 {{[0-9a-f]+}} 880fff00 # CHECK: SYMBOL TABLE: -# CHECK: 00400074 g F .text 00000004 main -# CHECK: 00401000 g .bss 00000004 _myref +# CHECK: 00400074 g F .text {{[0-9a-f]+}} main +# CHECK: 00401000 g .bss {{[0-9a-f]+}} _myref --- --- @@ -23,7 +23,7 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 - Content: 80B400AF0000000000231846BD465DF8047B7047 + Content: 80B400AF0000FF0000231846BD465DF8047B7047 - Name: .rel.text Type: SHT_REL Link: .symtab @@ -42,48 +42,8 @@ Sections: Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 - Content: '00474343' - - Name: .comment - Type: SHT_PROGBITS - Flags: [ SHF_MERGE, SHF_STRINGS ] - AddressAlign: 0x0000000000000001 - Content: 004743433A202863726F7373746F6F6C2D4E47206C696E61726F2D312E31332E312D342E392D323031342E3039202D204C696E61726F2047434320342E392D323031342E30392920342E392E32203230313430393034202870726572656C656173652900 - - Name: .note.GNU-stack - Type: SHT_PROGBITS - AddressAlign: 0x0000000000000001 Content: '' - - Name: .ARM.attributes - Type: SHT_ARM_ATTRIBUTES - AddressAlign: 0x0000000000000001 - Content: 4134000000616561626900012A00000005372D4100060A0741080109020A041204140115011703180119011A021B031C011E062201 Symbols: - Local: - - Name: test.c - Type: STT_FILE - - Name: .text - Type: STT_SECTION - Section: .text - - Name: .data - Type: STT_SECTION - Section: .data - - Name: .bss - Type: STT_SECTION - Section: .bss - - Name: '$d' - Section: .text - Value: 0x0000000000000004 - - Name: '$t' - Section: .text - Value: 0x0000000000000008 - - Name: .note.GNU-stack - Type: STT_SECTION - Section: .note.GNU-stack - - Name: .comment - Type: STT_SECTION - Section: .comment - - Name: .ARM.attributes - Type: STT_SECTION - Section: .ARM.attributes Global: - Name: _myref Type: STT_OBJECT