Change how we iterate over relocations on ELF.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 30 May 2013 03:05:14 +0000 (03:05 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 30 May 2013 03:05:14 +0000 (03:05 +0000)
commit7486d92a6c949a193bb75c0ffa0170eeb2fabb80
treeca8e73e165c5f83e01e2d97998f7baf7cd711f7e
parentd2df98f3aad701512c6f14579a24672a49df1150
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
83 files changed:
include/llvm/Object/ELF.h
include/llvm/Object/ObjectFile.h
lib/DebugInfo/DWARFContext.cpp
lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
lib/MC/MCObjectSymbolizer.cpp
lib/Object/ObjectFile.cpp
test/CodeGen/AArch64/adrp-relocation.ll
test/CodeGen/AArch64/basic-pic.ll
test/CodeGen/AArch64/elf-extern.ll
test/CodeGen/AArch64/jump-table.ll
test/CodeGen/ARM/2010-11-30-reloc-movt.ll
test/CodeGen/ARM/ehabi-mc-compact-pr0.ll
test/CodeGen/ARM/ehabi-mc-compact-pr1.ll
test/CodeGen/PowerPC/mcm-obj-2.ll
test/CodeGen/PowerPC/mcm-obj.ll
test/CodeGen/PowerPC/tls-gd-obj.ll
test/CodeGen/PowerPC/tls-ie-obj.ll
test/CodeGen/PowerPC/tls-ld-obj.ll
test/MC/AArch64/elf-globaladdress.ll
test/MC/AArch64/elf-reloc-addsubimm.s
test/MC/AArch64/elf-reloc-condbr.s
test/MC/AArch64/elf-reloc-ldrlit.s
test/MC/AArch64/elf-reloc-ldstunsimm.s
test/MC/AArch64/elf-reloc-movw.s
test/MC/AArch64/elf-reloc-pcreladdressing.s
test/MC/AArch64/elf-reloc-tstb.s
test/MC/AArch64/elf-reloc-uncondbrimm.s
test/MC/AArch64/tls-relocs.s
test/MC/ARM/eh-compact-pr0.s
test/MC/ARM/eh-compact-pr1.s
test/MC/ARM/eh-directive-cantunwind.s
test/MC/ARM/eh-directive-handlerdata.s
test/MC/ARM/eh-directive-personality.s
test/MC/ARM/eh-directive-section-multiple-func.s
test/MC/ARM/eh-directive-section.s
test/MC/ARM/eh-directive-text-section-multiple-func.s
test/MC/ARM/eh-directive-text-section.s
test/MC/ARM/elf-movt.s
test/MC/ARM/elf-reloc-01.ll
test/MC/ARM/elf-reloc-02.ll
test/MC/ARM/elf-reloc-03.ll
test/MC/ARM/elf-reloc-condcall.s
test/MC/ARM/elf-thumbfunc-reloc.ll
test/MC/ARM/elf-thumbfunc-reloc.s
test/MC/ELF/alias-reloc.s
test/MC/ELF/basic-elf-32.s
test/MC/ELF/basic-elf-64.s
test/MC/ELF/cfi-adjust-cfa-offset.s
test/MC/ELF/cfi-advance-loc2.s
test/MC/ELF/cfi-def-cfa-offset.s
test/MC/ELF/cfi-def-cfa-register.s
test/MC/ELF/cfi-def-cfa.s
test/MC/ELF/cfi-escape.s
test/MC/ELF/cfi-offset.s
test/MC/ELF/cfi-register.s
test/MC/ELF/cfi-rel-offset.s
test/MC/ELF/cfi-rel-offset2.s
test/MC/ELF/cfi-remember.s
test/MC/ELF/cfi-restore.s
test/MC/ELF/cfi-same-value.s
test/MC/ELF/cfi-undefined.s
test/MC/ELF/cfi-zero-addr-delta.s
test/MC/ELF/cfi.s
test/MC/ELF/gen-dwarf.s
test/MC/ELF/got.s
test/MC/ELF/local-reloc.s
test/MC/ELF/merge.s
test/MC/ELF/relocation-386.s
test/MC/ELF/relocation-pc.s
test/MC/ELF/relocation.s
test/MC/ELF/rename.s
test/MC/ELF/symref.s
test/MC/ELF/weak-relocation.s
test/MC/ELF/x86_64-reloc-sizetest.s
test/MC/Mips/eh-frame.s
test/MC/Mips/elf-gprel-32-64.ll
test/MC/Mips/elf-tls.ll
test/MC/PowerPC/ppc64-initial-cfa.ll
test/MC/PowerPC/ppc64-relocs-01.ll
test/MC/PowerPC/ppc64-tls-relocs-01.ll
test/Object/relocation-executable.test
test/tools/llvm-readobj/relocations.test
test/tools/llvm-readobj/sections-ext.test