[PATCH] D91533: [lib/Object] - Generalize the RelocationResolver API.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 04:49:11 PST 2020


grimar updated this revision to Diff 306055.
grimar added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

- Updated implementation to make LLD compilable.
- Addressed review comments.

Note: The way how LLD works with relocation resolver API
is a bit tricky. Main logic is located in `LLDDwarfObj<ELFT>::findAux`
and `LLDRelocationResolver::resolve` functions:

https://github.com/llvm/llvm-project/blob/master/lld/ELF/DWARF.cpp#L78
https://github.com/llvm/llvm-project/blob/master/lld/ELF/DWARF.cpp#L126

the idea is that it creates the `RelocationRef` with no owning object
and sets the `DataRefImpl.d` field either to 0 (for Rel) or to r_addend (for Rela).
Then the `DWARFDataExtractor::getRelocatedValue` also passes the piece of object data
which contains the addend for Rel objects.

After that, LLD provides 2 `resolve` functions that do either `s + a` or `s + ref.getRawDataRefImpl().p`.
They don't use relocation types and offsets because it is assumed that the computation is
always (S + A). No owning object is requred in this scheme, so it worked before.

The tricky part is that the `RelocationRef` with no owning object is a specific corner case.
Without an owning object it is not possible to call `RelocationRef::getType()`,
`RelocationRef::getOffset()` etc methods.

I had to update the `resolveRelocation` method to support the LLD specific way of using it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91533/new/

https://reviews.llvm.org/D91533

Files:
  lld/ELF/DWARF.cpp
  llvm/include/llvm/Object/ELFObjectFile.h
  llvm/include/llvm/Object/RelocationResolver.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
  llvm/lib/Object/RelocationResolver.cpp
  llvm/lib/XRay/InstrumentationMap.cpp
  llvm/test/Object/invalid.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91533.306055.patch
Type: text/x-patch
Size: 31129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201118/6983fd56/attachment.bin>


More information about the llvm-commits mailing list