[PATCH] Clarify getRelocationAddress x getRelocationOffset a bit.

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Wed Apr 24 14:51:46 PDT 2013


  I realized that if we are going to keep both getRelocationAddress and getRelocationOffset, we should check that both of them are called on the correct object types.

  The attached patch adds a private getROffest that fetches r_offset without adding any semantic meaning to it.

  getRelocationAddress and getRelocationOffset then just assert that they are called on the correct object type and forward to getROffest.

  Having to do

  +  if (Obj->getElfHeader()->e_type == ELF::ET_REL){
  +    if (error(RelI->getOffset(Offset))) return;
  +  } else {
  +    if (error(RelI->getAddress(Offset))) return;
  +  }

  in ELFDumper.cpp looks a bit silly, but just because on ELF offsets and addresses are both stored in the same place and tools are expected to dump it in the same way.

Hi Bigcheese,

http://llvm-reviews.chandlerc.com/D721

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D721?vs=1768&id=1770#toc

Files:
  include/llvm/Object/ELF.h
  include/llvm/Object/RelocVisitor.h
  lib/DebugInfo/DWARFContext.cpp
  lib/Object/COFFObjectFile.cpp
  lib/Object/MachOObjectFile.cpp
  test/Object/Inputs/hello-world.elf-x86-64
  test/Object/relocation-executable.test
  tools/llvm-objdump/MachODump.cpp
  tools/llvm-objdump/llvm-objdump.cpp
  tools/llvm-readobj/ELFDumper.cpp
  tools/llvm-readobj/llvm-readobj.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D721.3.patch
Type: text/x-patch
Size: 8940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130424/a39322da/attachment.bin>


More information about the llvm-commits mailing list