[PATCH] D63185: [llvm-objcopy] [WIP] Librarify llvm-objcopy

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 00:44:16 PDT 2019


abrachet created this revision.
abrachet added reviewers: jhenderson, rupprecht.
Herald added subscribers: llvm-commits, jakehehrlich.
Herald added a reviewer: alexshap.
Herald added a project: LLVM.

This is for my GSoC project to librarify llvm-objcopy. See bug 41044 <https://bugs.llvm.org/show_bug.cgi?id=41044>

The current code is in a very rough state and is a work in progress (WIP). It will of course be different however this is just for a check in and giving an example of renaming sections. This approach does so by keeping a map of modified sections which allows sections to be immutable but also seemingly modified in place. For example, if we rename section at index 1, then the iterator (hypothetical at this point but see MutableObject::getSection() ) at 1 will expose the new one. This lets sections be both immutable and rewritten to the file in their original order. Also I like that in this way methods like renameSection aren't themselves virtual, of course relying on virtual methods but I think this is a good start for code reuse.

I have never been great at designing class hierarchies and would love tips on how to structure the relationship between the classes. Jake had previously suggested having a hierarchy based on semantic meaning not implementation details, clearly there is a lot of work to be done here, I'm not blind to the fact that this code is a very rough draft.

Of note, something like SectionBase::clone() feels really bad to me. I don't really know a better way to do this though.

I would also say to ignore access modifiers for now, and also that everything is in the header file, I know this isn't conformant with the coding standards but I figured this was easier to keep in one file for now.


https://reviews.llvm.org/D63185

Files:
  llvm/tools/llvm-objcopy/MutableObject/MutableObject.h
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63185.204221.patch
Type: text/x-patch
Size: 6731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190612/47c951ab/attachment.bin>


More information about the llvm-commits mailing list