[PATCH] D37915: [llvm-objcopy] Add support for dynamic relocations
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 07:02:37 PDT 2017
jhenderson added a comment.
I definitely agree with your TODO comment. Could we simply add a function a bit like "finalize" but for late initialization to the SectionBase interface, and implemented/overridden in the various sub-classes as required? It would, I think, just need to take the list of sections, or the Object itself as an argument. That should be another change anyway.
As for the whole code-duplication situation, I think it may be possible to derive from a templated base class like so:
class RelocationSectionBase <typename SymtabType>: public SectionBase
{
SymtabType Symbols;
void setSymTab(SymtabType * SymTab) { Symbols = SymTab; }
//other shared code here, e.g. finalize, setSection etc
}
class RelocationSection : public RelocationSectionBase<SymbolTableSection>
{
// Stuff specific to static relocation sections, e.g. addRelocation, writeSection
}
class DynamicRelocationSection : public RelocationSectionBase<DynamicSymbolTableSection>
{
// Stuff specific to dynamic relocation sections, e.g. writeSection (which would probably just be a copy of Section's writeSection)
}
I believe this would avoid any additional casting, though without actually trying to implement it, I'm not certain.
Repository:
rL LLVM
https://reviews.llvm.org/D37915
More information about the llvm-commits
mailing list