summaryrefslogtreecommitdiff
path: root/test/tools/llvm-readobj/sections-ext.test
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-05-30 03:05:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-05-30 03:05:14 +0000
commit7486d92a6c949a193bb75c0ffa0170eeb2fabb80 (patch)
treeca8e73e165c5f83e01e2d97998f7baf7cd711f7e /test/tools/llvm-readobj/sections-ext.test
parentd2df98f3aad701512c6f14579a24672a49df1150 (diff)
downloadllvm-7486d92a6c949a193bb75c0ffa0170eeb2fabb80.tar.gz
llvm-7486d92a6c949a193bb75c0ffa0170eeb2fabb80.tar.bz2
llvm-7486d92a6c949a193bb75c0ffa0170eeb2fabb80.tar.xz
Change how we iterate over relocations on ELF.
For COFF and MachO, sections semantically have relocations that apply to them. That is not the case on ELF. In relocatable objects (.o), a section with relocations in ELF has offsets to another section where the relocations should be applied. In dynamic objects and executables, relocations don't have an offset, they have a virtual address. The section sh_info may or may not point to another section, but that is not actually used for resolving the relocations. This patch exposes that in the ObjectFile API. It has the following advantages: * Most (all?) clients can handle this more efficiently. They will normally walk all relocations, so doing an effort to iterate in a particular order doesn't save time. * llvm-readobj now prints relocations in the same way the native readelf does. * probably most important, relocations that don't point to any section are now visible. This is the case of relocations in the rela.dyn section. See the updated relocation-executable.test for example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tools/llvm-readobj/sections-ext.test')
-rw-r--r--test/tools/llvm-readobj/sections-ext.test30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/tools/llvm-readobj/sections-ext.test b/test/tools/llvm-readobj/sections-ext.test
index 327f040854..e3a40c3eb1 100644
--- a/test/tools/llvm-readobj/sections-ext.test
+++ b/test/tools/llvm-readobj/sections-ext.test
@@ -108,10 +108,6 @@ ELF-NEXT: Info: 0
ELF-NEXT: AddressAlignment: 16
ELF-NEXT: EntrySize: 0
ELF-NEXT: Relocations [
-ELF-NEXT: 0xC R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
-ELF-NEXT: 0x12 R_386_GOTOFF .L.str 0x0
-ELF-NEXT: 0x1A R_386_PLT32 puts 0x0
-ELF-NEXT: 0x1F R_386_PLT32 SomeOtherFunction 0x0
ELF-NEXT: ]
ELF-NEXT: Symbols [
ELF-NEXT: Symbol {
@@ -139,6 +135,32 @@ ELF-NEXT: 0010: 8D830000 00008904 24E8FCFF FFFFE8FC |........$.......|
ELF-NEXT: 0020: FFFFFF31 C083C408 5BC3 |...1....[.|
ELF-NEXT: )
ELF-NEXT: }
+ELF-NEXT: Section {
+ELF-NEXT: Index: 2
+ELF-NEXT: Name: .rel.text (1)
+ELF-NEXT: Type: SHT_REL (0x9)
+ELF-NEXT: Flags [ (0x0)
+ELF-NEXT: ]
+ELF-NEXT: Address: 0x0
+ELF-NEXT: Offset: 0x360
+ELF-NEXT: Size: 32
+ELF-NEXT: Link: 8
+ELF-NEXT: Info: 1
+ELF-NEXT: AddressAlignment: 4
+ELF-NEXT: EntrySize: 8
+ELF-NEXT: Relocations [
+ELF-NEXT: 0xC R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
+ELF-NEXT: 0x12 R_386_GOTOFF .L.str 0x0
+ELF-NEXT: 0x1A R_386_PLT32 puts 0x0
+ELF-NEXT: 0x1F R_386_PLT32 SomeOtherFunction 0x0
+ELF-NEXT: ]
+ELF-NEXT: Symbols [
+ELF-NEXT: ]
+ELF-NEXT: SectionData (
+ELF-NEXT: 0000: 0C000000 0A0A0000 12000000 09020000 |................|
+ELF-NEXT: 0010: 1A000000 040B0000 1F000000 04090000 |................|
+ELF-NEXT: )
+ELF-NEXT: }
MACHO-I386: Sections [
MACHO-I386-NEXT: Section {