[lld] r236334 - [ELF] Fix test for .init_array.
Davide Italiano
davide at freebsd.org
Fri May 1 12:20:48 PDT 2015
Author: davide
Date: Fri May 1 14:20:48 2015
New Revision: 236334
URL: http://llvm.org/viewvc/llvm-project?rev=236334&view=rev
Log:
[ELF] Fix test for .init_array.
Change the test so that it tests the right functionality.
Also put a description with the code from which the test was generated.
Reported by Simon Atanasysan.
Modified:
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp
lld/trunk/test/elf/init_array.test
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp?rev=236334&r1=236333&r2=236334&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp Fri May 1 14:20:48 2015
@@ -24,7 +24,7 @@ static void reloc64(uint8_t *location, u
/// \brief R_X86_64_PC32 - word32: S + A - P
static void relocPC32(uint8_t *location, uint64_t P, uint64_t S, int64_t A) {
uint32_t result = (uint32_t)(S + A - P);
- write32le(location, result + read32le(location));
+ write32le(location, result | read32le(location));
}
/// \brief R_X86_64_32 - word32: S + A
Modified: lld/trunk/test/elf/init_array.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/init_array.test?rev=236334&r1=236333&r2=236334&view=diff
==============================================================================
--- lld/trunk/test/elf/init_array.test (original)
+++ lld/trunk/test/elf/init_array.test Fri May 1 14:20:48 2015
@@ -1,5 +1,18 @@
+# Test .init_array.
+# Generated from the following C code:
+#
+# static void
+# init () {}
+#
+# static void (*const init_array []) ()
+# __attribute__ ((used, section (".init_array"), aligned (sizeof (void *))))
+# = { init };
+#
+# int
+# main() { return (0); }
+
#RUN: yaml2obj -format=elf %s -o=%t.o
-#RUN: lld -flavor gnu -target x86_64 %t.o -o %t1 -e=main
+#RUN: lld -flavor gnu -target x86_64 %t.o -o %t -e=main
#RUN: llvm-objdump -t -section-headers %t | FileCheck %s
#CHECK: .init_array {{[0-9]+}} [[ADDR:[0-9]+]]
@@ -17,26 +30,32 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000000010
- Content: 554889E5B800000000C745FC000000008B0C2500000000894DF85DC3
- - Name: .rela.text
- Type: SHT_RELA
- Link: .symtab
- AddressAlign: 0x0000000000000008
- Info: .text
- Relocations:
- - Offset: 0x0000000000000013
- Symbol: a
- Type: R_X86_64_32S
+ Content: 554889E5B800000000C745FC000000005DC366666666662E0F1F840000000000554889E55DC3
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
- Content: '05000000'
+ Content: ''
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
+ - Name: .init_array
+ Type: SHT_INIT_ARRAY
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000008
+ Content: '0000000000000000'
+ - Name: .rela.init_array
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .init_array
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: .text
+ Type: R_X86_64_64
+ Addend: 32
- Name: .comment
Type: SHT_PROGBITS
Flags: [ SHF_MERGE, SHF_STRINGS ]
@@ -50,7 +69,7 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x0000000000000008
- Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000000000001C00000000410E108602430D0600000000000000
+ Content: 1400000000000000017A5200017810011B0C070890010000180000001C000000000000001200000000410E108602430D060000001800000038000000000000000600000000410E108602430D06000000
- Name: .rela.eh_frame
Type: SHT_RELA
Link: .symtab
@@ -60,8 +79,21 @@ Sections:
- Offset: 0x0000000000000020
Symbol: .text
Type: R_X86_64_PC32
+ - Offset: 0x000000000000003C
+ Symbol: .text
+ Type: R_X86_64_PC32
+ Addend: 32
Symbols:
Local:
+ - Name: init
+ Type: STT_FUNC
+ Section: .text
+ Value: 0x0000000000000020
+ Size: 0x0000000000000006
+ - Name: init_array
+ Type: STT_OBJECT
+ Section: .init_array
+ Size: 0x0000000000000008
- Name: .text
Type: STT_SECTION
Section: .text
@@ -71,6 +103,9 @@ Symbols:
- Name: .bss
Type: STT_SECTION
Section: .bss
+ - Name: .init_array
+ Type: STT_SECTION
+ Section: .init_array
- Name: .comment
Type: STT_SECTION
Section: .comment
@@ -81,12 +116,8 @@ Symbols:
Type: STT_SECTION
Section: .eh_frame
Global:
- - Name: a
- Type: STT_OBJECT
- Section: .data
- Size: 0x0000000000000004
- Name: main
Type: STT_FUNC
Section: .text
- Size: 0x000000000000001C
+ Size: 0x0000000000000012
...
More information about the llvm-commits
mailing list