[llvm] r339772 - [yaml2obj] - Teach yaml2obj to produce SHT_GROUP section with a custom Info field.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 06:55:22 PDT 2018


Author: grimar
Date: Wed Aug 15 06:55:22 2018
New Revision: 339772

URL: http://llvm.org/viewvc/llvm-project?rev=339772&view=rev
Log:
[yaml2obj] - Teach yaml2obj to produce SHT_GROUP section with a custom Info field.

This allows to set custom Info field value for SHT_GROUP sections.

It is useful to allow this because we would be able to replace at least one binary
object committed in LLD and replace it with the yaml2obj based test.

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

Added:
    llvm/trunk/test/tools/yaml2obj/elf-comdat-broken-info.yaml
Modified:
    llvm/trunk/tools/yaml2obj/yaml2elf.cpp

Added: llvm/trunk/test/tools/yaml2obj/elf-comdat-broken-info.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/elf-comdat-broken-info.yaml?rev=339772&view=auto
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/elf-comdat-broken-info.yaml (added)
+++ llvm/trunk/test/tools/yaml2obj/elf-comdat-broken-info.yaml Wed Aug 15 06:55:22 2018
@@ -0,0 +1,27 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s
+
+--- !ELF
+FileHeader:
+  Class:               ELFCLASS64
+  Data:                ELFDATA2LSB
+  Type:                ET_REL
+  Machine:             EM_X86_64
+Sections:
+  - Name:              .group
+    Type:              SHT_GROUP
+    Link:              .symtab
+    Info:              12345
+    Members:
+      - SectionOrType: GRP_COMDAT
+
+## Check we are able to produce SHT_GROUP section with a custom Info value (12345).
+# CHECK:      Name: .group
+# CHECK-NEXT: Type: SHT_GROUP
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info: 12345

Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=339772&r1=339771&r2=339772&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Wed Aug 15 06:55:22 2018
@@ -274,7 +274,7 @@ bool ELFState<ELFT>::initSectionHeaders(
         return false;
     } else if (auto S = dyn_cast<ELFYAML::Group>(Sec.get())) {
       unsigned SymIdx;
-      if (SymN2I.lookup(S->Info, SymIdx)) {
+      if (SymN2I.lookup(S->Info, SymIdx) && !to_integer(S->Info, SymIdx)) {
         WithColor::error() << "Unknown symbol referenced: '" << S->Info
                            << "' at YAML section '" << S->Name << "'.\n";
         return false;




More information about the llvm-commits mailing list