[PATCH] [Mips] Support MIPS N64 relocation record format

Simon Atanasyan simon at atanasyan.com
Sun Mar 22 13:42:12 PDT 2015


Hi shankarke, ruiu, Bigcheese,

N64 ABI relocation record r_info field in fact consists of five subfields:
* r_sym   - symbol index
* r_ssym  - special symbol
* r_type3 - third relocation type
* r_type2 - second relocation type
* r_type  - first relocation type

Up to three these relocations applied one by one. The first relocation uses an addendum from the relocation record. Each subsequent relocation takes as its addend the result of the previous operation. Only the final operation actually modifies the location relocated. The first relocation uses as a reference symbol specified by the `r_sym` field. The third relocation assumes NULL symbol.

The patch represents these data using LLD model and takes in account additional relocation types during a relocation calculation.

Additional relocations do not introduce any new relations between two atoms and just specify operations need to be done during a relocation calculation. The first relocation type (`r_type`) stored in the `Reference::_kindValue`. The rest of relocations and `r_ssym` value are stored in the new `Reference::_tag` field "as-is". I decided to do not "decode" these data on the core LLD level to prevent pollution of the core LLD model by very target specific data.

Also I have to override writing of relocation records in the `RelocationTable` class to convert MIPS N64 ABI relocation information from the `Reference` class back to the ELF relocation record.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8533

Files:
  include/lld/Core/Reference.h
  lib/ReaderWriter/ELF/DefaultLayout.h
  lib/ReaderWriter/ELF/Mips/MipsELFFile.h
  lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
  lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
  lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
  lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
  lib/ReaderWriter/ELF/SectionChunks.h
  lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  test/elf/Mips/n64-rel-chain.test
  test/elf/Mips/rel-dynamic-06-64.test
  test/elf/Mips/rel-dynamic-07-64.test
  test/elf/Mips/rel-dynamic-08-64.test
  test/elf/Mips/rel-gprel32-64.test

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8533.22439.patch
Type: text/x-patch
Size: 41104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150322/2619f26c/attachment.bin>


More information about the llvm-commits mailing list