[llvm] 7a587ca - [yaml2obj] - Rename FileHeader::SH* fields.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 02:47:51 PDT 2020


Author: Georgii Rymar
Date: 2020-07-15T12:47:31+03:00
New Revision: 7a587ca93200c49e47fe205ce037895c81c5a542

URL: https://github.com/llvm/llvm-project/commit/7a587ca93200c49e47fe205ce037895c81c5a542
DIFF: https://github.com/llvm/llvm-project/commit/7a587ca93200c49e47fe205ce037895c81c5a542.diff

LOG: [yaml2obj] - Rename FileHeader::SH* fields.

In D83482 we agreed to name e_* fields that are used for overriding
values (like e_phoff) as EPh* (e.g. EPhOff).

Currently we have a set of e_sh* fields that are named inconsistently
with this rule. This patch renames all of them.

Differential revision: https://reviews.llvm.org/D83766

Added: 
    

Modified: 
    llvm/include/llvm/ObjectYAML/ELFYAML.h
    llvm/lib/ObjectYAML/ELFEmitter.cpp
    llvm/lib/ObjectYAML/ELFYAML.cpp
    llvm/test/Object/invalid.test
    llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test
    llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
    llvm/test/tools/llvm-readobj/ELF/hash-table.test
    llvm/test/tools/llvm-readobj/ELF/invalid-shstrndx.test
    llvm/test/tools/llvm-readobj/ELF/many-sections.s
    llvm/test/tools/llvm-readobj/ELF/sections-no-section-header-string-table.test
    llvm/test/tools/llvm-readobj/ELF/symbols.test
    llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
    llvm/test/tools/yaml2obj/ELF/section-headers.yaml
    llvm/tools/obj2yaml/elf2yaml.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h b/llvm/include/llvm/ObjectYAML/ELFYAML.h
index 651cd6a83398..b1ffb20681ea 100644
--- a/llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -84,11 +84,10 @@ struct FileHeader {
   Optional<llvm::yaml::Hex64> EPhOff;
   Optional<llvm::yaml::Hex16> EPhEntSize;
   Optional<llvm::yaml::Hex16> EPhNum;
-
-  Optional<llvm::yaml::Hex16> SHEntSize;
-  Optional<llvm::yaml::Hex64> SHOff;
-  Optional<llvm::yaml::Hex16> SHNum;
-  Optional<llvm::yaml::Hex16> SHStrNdx;
+  Optional<llvm::yaml::Hex16> EShEntSize;
+  Optional<llvm::yaml::Hex64> EShOff;
+  Optional<llvm::yaml::Hex16> EShNum;
+  Optional<llvm::yaml::Hex16> EShStrNdx;
 };
 
 struct SectionHeader {

diff  --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 8513874ffea8..f9f2f128e2e8 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -417,21 +417,21 @@ void ELFState<ELFT>::writeELFHeader(raw_ostream &OS, uint64_t SHOff) {
   else
     Header.e_phnum = 0;
 
-  Header.e_shentsize =
-      Doc.Header.SHEntSize ? (uint16_t)*Doc.Header.SHEntSize : sizeof(Elf_Shdr);
+  Header.e_shentsize = Doc.Header.EShEntSize ? (uint16_t)*Doc.Header.EShEntSize
+                                             : sizeof(Elf_Shdr);
 
   const bool NoShdrs =
       Doc.SectionHeaders && Doc.SectionHeaders->NoHeaders.getValueOr(false);
 
-  if (Doc.Header.SHOff)
-    Header.e_shoff = *Doc.Header.SHOff;
+  if (Doc.Header.EShOff)
+    Header.e_shoff = *Doc.Header.EShOff;
   else if (NoShdrs)
     Header.e_shoff = 0;
   else
     Header.e_shoff = SHOff;
 
-  if (Doc.Header.SHNum)
-    Header.e_shnum = *Doc.Header.SHNum;
+  if (Doc.Header.EShNum)
+    Header.e_shnum = *Doc.Header.EShNum;
   else if (!Doc.SectionHeaders)
     Header.e_shnum = Doc.getSections().size();
   else if (NoShdrs)
@@ -442,8 +442,8 @@ void ELFState<ELFT>::writeELFHeader(raw_ostream &OS, uint64_t SHOff) {
                                       : 0) +
         /*Null section*/ 1;
 
-  if (Doc.Header.SHStrNdx)
-    Header.e_shstrndx = *Doc.Header.SHStrNdx;
+  if (Doc.Header.EShStrNdx)
+    Header.e_shstrndx = *Doc.Header.EShStrNdx;
   else if (NoShdrs || ExcludedSectionHeaders.count(".shstrtab"))
     Header.e_shstrndx = 0;
   else

diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index dc65f77d565b..2353b34f188b 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -872,11 +872,10 @@ void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
   IO.mapOptional("EPhOff", FileHdr.EPhOff);
   IO.mapOptional("EPhEntSize", FileHdr.EPhEntSize);
   IO.mapOptional("EPhNum", FileHdr.EPhNum);
-
-  IO.mapOptional("SHEntSize", FileHdr.SHEntSize);
-  IO.mapOptional("SHOff", FileHdr.SHOff);
-  IO.mapOptional("SHNum", FileHdr.SHNum);
-  IO.mapOptional("SHStrNdx", FileHdr.SHStrNdx);
+  IO.mapOptional("EShEntSize", FileHdr.EShEntSize);
+  IO.mapOptional("EShOff", FileHdr.EShOff);
+  IO.mapOptional("EShNum", FileHdr.EShNum);
+  IO.mapOptional("EShStrNdx", FileHdr.EShStrNdx);
 }
 
 void MappingTraits<ELFYAML::ProgramHeader>::mapping(

diff  --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test
index 499200bbc8a7..a930a6a9dbe6 100644
--- a/llvm/test/Object/invalid.test
+++ b/llvm/test/Object/invalid.test
@@ -181,11 +181,11 @@ Sections:
 
 --- !ELF
 FileHeader:
-  Class:     ELFCLASS64
-  Data:      ELFDATA2LSB
-  Type:      ET_REL
-  Machine:   EM_X86_64
-  SHEntSize: 1
+  Class:      ELFCLASS64
+  Data:       ELFDATA2LSB
+  Type:       ET_REL
+  Machine:    EM_X86_64
+  EShEntSize: 1
 
 ## Check that llvm-readobj reports a warning if .symtab has sh_size
 ## that is not a multiple of sh_entsize.
@@ -306,11 +306,11 @@ Symbols: []
  
 --- !ELF
 FileHeader:
-  Class:   ELFCLASS64
-  Data:    ELFDATA2LSB
-  Type:    ET_REL
-  Machine: EM_X86_64
-  SHNum:   0xFF
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+  EShNum:   0xFF
 
 ## Check llvm-readobj does not crash on a truncated ELF.
 
@@ -521,11 +521,11 @@ ProgramHeaders:
 
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_REL
-  Machine:  EM_X86_64
-  SHStrNdx: 0xFF
+  Class:     ELFCLASS64
+  Data:      ELFDATA2LSB
+  Type:      ET_REL
+  Machine:   EM_X86_64
+  EShStrNdx: 0xFF
 Sections:
   - Name: .foo
     Type: SHT_PROGBITS
@@ -541,11 +541,11 @@ Sections:
 
 --- !ELF
 FileHeader:
-  Class:   ELFCLASS64
-  Data:    ELFDATA2LSB
-  Type:    ET_REL
-  Machine: EM_X86_64
-  SHNum:   0x0
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+  EShNum:   0x0
 Sections:
   - Type: SHT_NULL
     Size: 288230376151711743
@@ -560,11 +560,11 @@ Sections:
 
 --- !ELF
 FileHeader:
-  Class:   ELFCLASS64
-  Data:    ELFDATA2LSB
-  Type:    ET_REL
-  Machine: EM_X86_64
-  SHNum:   0x0
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+  EShNum:   0x0
 Sections:
   - Type: SHT_NULL
     Size: 288230376151711744
@@ -578,11 +578,11 @@ Sections:
  
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_REL
-  Machine:  EM_X86_64
-  SHOff:    0xffffffffffffffff
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+  EShOff:  0xffffffffffffffff
 
 ## Check that llvm-objdump reports an error when it tries to dump a
 ## symbol name and .strtab is empty.
@@ -641,12 +641,12 @@ DynamicSymbols:
 
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_REL
-  Machine:  EM_X86_64
+  Class:     ELFCLASS64
+  Data:      ELFDATA2LSB
+  Type:      ET_REL
+  Machine:   EM_X86_64
 ## SHN_XINDEX == 0xffff.
-  SHStrNdx: 0xffff
+  EShStrNdx: 0xffff
 Sections:
   - Type: SHT_NULL
     Link: 0xff

diff  --git a/llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test b/llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test
index 16e5af819ebe..1ec81578b9cc 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test
@@ -23,8 +23,8 @@ FileHeader:
   Machine: EM_X86_64
 ## We simulate no section header table by
 ## overriding the ELF header properties.
-  SHOff:   0x0
-  SHNum:   0x0
+  EShOff:  0x0
+  EShNum:  0x0
 Sections:
   - Name:    .rela.dyn
     Type:    SHT_RELA

diff  --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
index b1ea1981511f..5af6a56e6895 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
@@ -88,7 +88,7 @@ FileHeader:
   Type:       ET_EXEC
   Machine:    EM_X86_64
   EPhEntSize: [[PHENTSIZE=56]]
-  SHNum:      [[SHNUM=6]]
+  EShNum:     [[SHNUM=6]]
 Sections:
   - Name:         .note.ABI-tag
     Type:         SHT_NOTE

diff  --git a/llvm/test/tools/llvm-readobj/ELF/hash-table.test b/llvm/test/tools/llvm-readobj/ELF/hash-table.test
index b247c597eeb1..864f7f1426f3 100644
--- a/llvm/test/tools/llvm-readobj/ELF/hash-table.test
+++ b/llvm/test/tools/llvm-readobj/ELF/hash-table.test
@@ -64,8 +64,8 @@ FileHeader:
   Machine: EM_X86_64
 ## We simulate no section header table by
 ## overriding the ELF header properties.
-  SHOff:   0x0
-  SHNum:   0x0
+  EShOff:  0x0
+  EShNum:  0x0
 Sections:
   - Name:   .hash
     Type:   SHT_HASH

diff  --git a/llvm/test/tools/llvm-readobj/ELF/invalid-shstrndx.test b/llvm/test/tools/llvm-readobj/ELF/invalid-shstrndx.test
index 84583d2c3cd9..50bdd3fc1fb6 100644
--- a/llvm/test/tools/llvm-readobj/ELF/invalid-shstrndx.test
+++ b/llvm/test/tools/llvm-readobj/ELF/invalid-shstrndx.test
@@ -46,4 +46,4 @@ FileHeader:
   Data:      ELFDATA2LSB
   Type:      ET_REL
   Machine:   EM_X86_64
-  SHStrNdx:  0xFF
+  EShStrNdx: 0xFF

diff  --git a/llvm/test/tools/llvm-readobj/ELF/many-sections.s b/llvm/test/tools/llvm-readobj/ELF/many-sections.s
index eea5ed7f95e4..4271be7a0917 100644
--- a/llvm/test/tools/llvm-readobj/ELF/many-sections.s
+++ b/llvm/test/tools/llvm-readobj/ELF/many-sections.s
@@ -18,12 +18,12 @@
 
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_REL
-  Machine:  EM_X86_64
-  SHNum:    0
-  SHStrNdx: 0xffff ## SHN_XINDEX
+  Class:     ELFCLASS64
+  Data:      ELFDATA2LSB
+  Type:      ET_REL
+  Machine:   EM_X86_64
+  EShNum:    0
+  EShStrNdx: 0xffff ## SHN_XINDEX
 Sections:
   - Type: SHT_NULL
     Link: .shstrtab
@@ -56,13 +56,13 @@ Sections:
 
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_REL
-  Machine:  EM_X86_64
-  SHOff:    0
-  SHNum:    0
-  SHStrNdx: 0xffff ## SHN_XINDEX
+  Class:     ELFCLASS64
+  Data:      ELFDATA2LSB
+  Type:      ET_REL
+  Machine:   EM_X86_64
+  EShOff:    0
+  EShNum:    0
+  EShStrNdx: 0xffff ## SHN_XINDEX
 Sections:
   - Type: SHT_NULL
     Link: .shstrtab

diff  --git a/llvm/test/tools/llvm-readobj/ELF/sections-no-section-header-string-table.test b/llvm/test/tools/llvm-readobj/ELF/sections-no-section-header-string-table.test
index e5442d26444b..95a72a4d0513 100644
--- a/llvm/test/tools/llvm-readobj/ELF/sections-no-section-header-string-table.test
+++ b/llvm/test/tools/llvm-readobj/ELF/sections-no-section-header-string-table.test
@@ -92,11 +92,11 @@
 
 --- !ELF
 FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-  Machine:  EM_X86_64
-  SHStrNdx: 0
+  Class:     ELFCLASS64
+  Data:      ELFDATA2LSB
+  Type:      ET_DYN
+  Machine:   EM_X86_64
+  EShStrNdx: 0
 Sections:
   - Name:   .foo
     Type:   SHT_PROGBITS

diff  --git a/llvm/test/tools/llvm-readobj/ELF/symbols.test b/llvm/test/tools/llvm-readobj/ELF/symbols.test
index f9e4875a2875..492097d55c0f 100644
--- a/llvm/test/tools/llvm-readobj/ELF/symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/symbols.test
@@ -161,7 +161,7 @@ FileHeader:
   Data:      ELFDATA2LSB
   Type:      ET_REL
   Machine:   EM_X86_64
-  SHStrNdx:  [[SHSTRTAB=2]]
+  EShStrNdx: [[SHSTRTAB=2]]
 Sections:
   - Name:    .symtab
     Type:    SHT_SYMTAB

diff  --git a/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml b/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
index a6860546bdec..15d7bbd3a019 100644
--- a/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
@@ -33,14 +33,14 @@ ProgramHeaders:
 
 --- !ELF
 FileHeader:
-  Class:     ELFCLASS64
-  Data:      ELFDATA2LSB
-  Type:      ET_REL
-  Machine:   EM_X86_64
-  SHEntSize:  [[SHENTSIZE=64]]
-  SHOff:      [[SHOFF=200]]
-  SHNum:      [[SHNUM=3]]
-  SHStrNdx:   [[SHSTRNDX=2]]
+  Class:      ELFCLASS64
+  Data:       ELFDATA2LSB
+  Type:       ET_REL
+  Machine:    EM_X86_64
+  EShEntSize: [[SHENTSIZE=64]]
+  EShOff:     [[SHOFF=200]]
+  EShNum:     [[SHNUM=3]]
+  EShStrNdx:  [[SHSTRNDX=2]]
   EPhOff:     [[PHOFF=64]]
   EPhEntSize: [[PHENTSIZE=56]]
   EPhNum:     [[PHNUM=2]]

diff  --git a/llvm/test/tools/yaml2obj/ELF/section-headers.yaml b/llvm/test/tools/yaml2obj/ELF/section-headers.yaml
index 01845ba2a6cb..f593d76929fe 100644
--- a/llvm/test/tools/yaml2obj/ELF/section-headers.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/section-headers.yaml
@@ -184,9 +184,9 @@ FileHeader:
   Data:      ELFDATA2LSB
   Type:      ET_REL
   Machine:   EM_X86_64
-  SHOff:     0x2
-  SHNum:     0x3
-  SHStrNdx:  0x4
+  EShOff:    0x2
+  EShNum:    0x3
+  EShStrNdx: 0x4
 Sections:
   - Name: .foo
     Type: SHT_PROGBITS

diff  --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 7b0687a5a5f8..b45098538f87 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -200,7 +200,7 @@ bool ELFDumper<ELFT>::shouldPrintSection(const ELFYAML::Section &S,
 template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
   auto Y = std::make_unique<ELFYAML::Object>();
 
-  // Dump header. We do not dump EPh* and SH* fields. When not explicitly set,
+  // Dump header. We do not dump EPh* and ESh* fields. When not explicitly set,
   // the values are set by yaml2obj automatically and there is no need to dump
   // them here.
   Y->Header.Class = ELFYAML::ELF_ELFCLASS(Obj.getHeader()->getFileClass());


        


More information about the llvm-commits mailing list