[PATCH] D80002: [yaml2obj] - Implement the "SectionHeaderTable" tag.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 15 10:18:26 PDT 2020


MaskRay added a comment.

This is a good idea.



================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:1457
+  for (const ELFYAML::SecHdr &Hdr : Doc.SectionHeader->Sections) {
+    if (!Ret.insert({Hdr.Name, ++SecNdx}).second)
+      reportError("repeated section name: '" + Hdr.Name +
----------------
try_emplace can remove `{}`


================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:1463
+
+  for (const ELFYAML::Section *S : Doc.getSections()) {
+    // Ignore special first SHT_NULL section.
----------------
Use `ArrayRef::slice` to skip SHT_NULL.


================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:1468
+    if (!Seen.count(S->Name))
+      reportError("section header must list the '" + S->Name + "' section");
+    Seen.erase(S->Name);
----------------
section name should be present in the `Sections` list



================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:1472
+
+  for (const auto& It : Seen)
+    reportError("section header contains undefined section '" + It.getKey() + "'");
----------------
`auto &`


================
Comment at: llvm/test/tools/yaml2obj/ELF/section-headers.yaml:31
+    Size: 0x20
+  - Type: Fill
+    Name:    .filler
----------------
Fill not indented correctly.


================
Comment at: llvm/test/tools/yaml2obj/ELF/section-headers.yaml:39
+SectionHeaderTable:
+  Sections:
+    - Name: [[SEC1]]
----------------
Can `Sections` be omitted?


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

https://reviews.llvm.org/D80002





More information about the llvm-commits mailing list