[PATCH] D57940: Refactor RelocVisitor and fix computation of SHT_RELA-typed relocation entries

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 20 07:01:43 PST 2019


MaskRay marked an inline comment as done.
MaskRay added inline comments.


================
Comment at: ELF/DWARF.cpp:111-112
+  D.p = getAddend<ELFT>(Rel);
+  return RelocAddrEntry{SecIndex, RelocationRef(D, nullptr),
+                        RelocationResolver<typename ELFT::Rela>::Resolve, Val};
 }
----------------
dblaikie wrote:
> ruiu wrote:
> > I found this interface a bit awkward. Passing a DataRefImpl instance just to pass a single integer value seems odd to me.
> > 
> > I think my question is, is it that hard to read debug info? We don't necessarily have to use the library to read debug info, and if we can just read debug info with a small amount of code, that could be a better way. I don't know if that's the case, but that's something I want to investigate.
> If there's something awkward about LLVM's DWARF reading APIs, I'd love to see them improved (open to suggestions/requests/design discussions/patches) rather than forked/partially reimplemented in LLD, if at all reasonable/possible, for what it's worth.
> 
> DataRefImpl is a union of the integer and some other alternatives, by the looks of it - so I'm not sure I see this as being especially odd/awkward. I guess it's because some clients want to describe the parameter in one way, and some in another. If it's particularly hard to read here, there could be a convenience wrapper function that packs the parameter into a DataRefImpl/RelocationRef/etc?
The slight weird thing here is that `RelocationResolver<typename ELFT::Rela>::Resolve` is the constant for every relocation involved. Putting it to every RelocAddrEntry is wasteful. I'll try improving this but for now I just want to get the SHT_RELA bug fixed.. D57939


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D57940





More information about the llvm-commits mailing list