[PATCH] D14140: [ELF2] SECTIONS command basic support
Denis Protivensky via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 06:27:07 PST 2015
denis-protivensky added a comment.
In http://reviews.llvm.org/D14140#282350, @rafael wrote:
> It is not clear if this is needed by real program. For now just leave
> it out to have a simpler code. Even if it is needed, it would be
> better to just organize the code as
>
> - add sections from input files
> - sort
> - add linker generated sections
> - sort the end + merge
>
> no?
I'll leave simpler code, thanks.
================
Comment at: ELF/Writer.cpp:550-557
@@ -515,8 +549,10 @@
// we can correctly decide if a dynamic relocation is needed.
- for (const std::unique_ptr<ObjectFile<ELFT>> &F : Symtab.getObjectFiles())
- for (InputSectionBase<ELFT> *B : F->getSections())
- if (auto *S = dyn_cast_or_null<InputSection<ELFT>>(B))
- if (S != &InputSection<ELFT>::Discarded)
- if (S->isLive())
- scanRelocs(*S);
+ for (const std::unique_ptr<ObjectFile<ELFT>> &F : Symtab.getObjectFiles()) {
+ for (InputSectionBase<ELFT> *C : F->getSections()) {
+ if (isDiscarded(C))
+ continue;
+ if (auto *S = dyn_cast<InputSection<ELFT>>(C))
+ scanRelocs(*S);
+ }
+ }
----------------
ruiu wrote:
> for (const std::unique_ptr<ObjectFile<ELFT>> &F : Symtab.getObjectFiles())
> for (InputSectionBase<ELFT> *C : F->getSections())
> if (!isDiscarded(C))
> if (auto *S = dyn_cast<InputSection<ELFT>>(C))
> scanRelocs(*S);
Ok.
================
Comment at: ELF/Writer.cpp:906-911
@@ -869,1 +905,8 @@
+template <class ELFT> void Writer<ELFT>::parseSectionDescriptions() {
+ for (const std::pair<StringRef, OutputSectionDescription> &OutSec :
+ Config->OutputSections)
+ for (StringRef Name : OutSec.second.InputSectionNames)
+ InputToOutputSection[Name] = OutSec.second.Name;
+}
+
----------------
ruiu wrote:
> Looks like OutputSectionDescription doesn't have to be a struct. We can make Config->OutputSections of type StringMap<StringRef> which maps input section names to output section names.
I can't substitute MapVector with StringMap since I need to know original ordering of output sections defined in linker script so I can sort them accordingly.
I'll remove the OutputSectionDescription structure and use MapVector<StringRef, std::vector<StringRef>> instead.
http://reviews.llvm.org/D14140
More information about the llvm-commits
mailing list