[PATCH] D90458: [yaml2obj] - ProgramHeaders: introduce FirstSec/LastSec instead of Sections list.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 04:43:32 PST 2020


jhenderson added inline comments.


================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:488
 
-      unsigned Index;
-      if (SN2I.lookup(SecName.Section, Index)) {
-        YamlPhdr.Chunks.push_back(Sections[Index]);
-        continue;
-      }
+    // Get the index of section, or 0 in case when the section doesn't exist.
+    size_t First = NameToIndex[*YamlPhdr.FirstSec];
----------------



================
Comment at: llvm/test/tools/llvm-readobj/ELF/gnu-notes.test:192
+    FirstSec: .note
+    LastSec: .note
 
----------------



================
Comment at: llvm/test/tools/llvm-readobj/ELF/hash-histogram.test:412
+    FirstSec: .gnu.hash
+    LastSec: .gnu.hash
----------------



================
Comment at: llvm/test/tools/obj2yaml/ELF/program-headers.yaml:395-397
   - Name:    .non-alloc.2
     Type:    SHT_NULL
     Flags:   [ ]
----------------
We probably need a case where .non-alloc.2 would be the `LastSec` too.


================
Comment at: llvm/tools/obj2yaml/elf2yaml.cpp:392-399
     for (const std::unique_ptr<ELFYAML::Chunk> &C : Chunks) {
       ELFYAML::Section &S = cast<ELFYAML::Section>(*C.get());
-      if (isInSegment<ELFT>(S, Sections[S.OriginalSecNdx], Phdr))
-        PH.Sections.push_back({S.Name});
+      if (isInSegment<ELFT>(S, Sections[S.OriginalSecNdx], Phdr)) {
+        if (!PH.FirstSec)
+          PH.FirstSec = S.Name;
+        PH.LastSec = S.Name;
+      }
----------------
Does this loop work if section headers are not in section offset order? Or are they guaranteed to be by some sorting earlier on?


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

https://reviews.llvm.org/D90458



More information about the llvm-commits mailing list