[PATCH] D37335: [MIPS] Initial support of microMIPS code linking

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 16:39:04 PDT 2017


atanasyan updated this revision to Diff 113792.
atanasyan added a comment.

- Remove `needShuffling` function.
- Remove separate `shuffle` and `unshuffle` functions and move the code into the `writeMicroRelocation32` routine. Now we "unsuffle" data when read implicit addend and "unshuffle" and then "shuffle" data back when writing result of microMIPS relocation.
- Fix shuffling of 16-bit words. Do it iif target binary is little-endian.
- Keep `memset` calls in `writePltHeader` and `writePlt` methods. In short, size of actual PLT entry can be less than `PltEntrySize` and we need to fill unused space by "nops". When we initialize `PltEntrySize` and `PltHeaderSize` fields we do not know what kind of PLT header/entry we will need to create: regular of microMIPS. These entries have different sizes. Ideally, if a PLT entry is referenced by microMIPS code only this entry should contain microMIPS code, if a PLT entry is referenced by regular code this entry should contain regular code. In a "mixed" case the PLT entry can be either microMIPS or regular, but each "cross-mode-call" has additional cost. Now LLD cannot: a) maintain PLT records with different sizes; b) record type of references (regular / microMIPS) for a PLT entry. To simplify the patch I assume that usually the most or all code have the same type regular or microMIPS. I allocate space for the largest PLT header/entry, but at the time of PLT creation I write either regular or microMIPS entries only. In the last case PLT has gaps which needs to be filled by "nops".


Repository:
  rL LLVM

https://reviews.llvm.org/D37335

Files:
  ELF/Arch/Mips.cpp
  ELF/InputSection.cpp
  ELF/Relocations.cpp
  test/ELF/Inputs/mips-micro.s
  test/ELF/mips-micro-got.s
  test/ELF/mips-micro-got64.s
  test/ELF/mips-micro-jal.s
  test/ELF/mips-micro-relocs.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37335.113792.patch
Type: text/x-patch
Size: 27502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170904/8dc33364/attachment.bin>


More information about the llvm-commits mailing list