[PATCH] D65367: [Object] Create MutableELFObject Class for Doing Mutations on ELFObjectFiles [Part 2]

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 07:28:57 PDT 2019


jhenderson added a comment.

I don't think you want to be modifying the number of dynamic symbols at all. That would require you to make other changes to loadable code, which would impact addresses, and effectively require you to completely relink the program.

You may however still need to modify the contents of the existing dynamic symbols (specifically you may need to be able to update their section indexes).



================
Comment at: llvm/include/llvm/Object/MutableELFObject.h:197
+               : DynSymbols;
+  }
+
----------------
grimar wrote:
> abrachet wrote:
> > grimar wrote:
> > > What about implementing `const` version using `non-const`? I.e. call `getWhichTable` from `getWhichTable const`.
> > How do I do this without const_casting `this`? Is that how you do it? This is very useful because this duplicating methods like this has been bugging me recently. Thanks!
> I think there is no way to do this without `const_cast`, but this is a normal/common way.
It doesn't look like you use the non-const version anywhere, so it can be deleted, right?


================
Comment at: llvm/include/llvm/Object/MutableELFObject.h:174
+
+  uint32_t findSectionIndex(uint64_t ShType) const {
+    for (uint32_t I = 0; I < Sections.originalSize(); ++I)
----------------
How about findSectionOfType?


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

https://reviews.llvm.org/D65367





More information about the llvm-commits mailing list