[PATCH] D67824: [llvm-readobj] - Stop treating ".stack_sizes.*" sections as stack sizes sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 03:04:45 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay, rupprecht.
Herald added a subscriber: seiya.

llvm-readobj currently handles `.stack_sizes.*` (e.g. `.stack_sizes.foo`)
as a normal stack sizes section. Though MC does not produce sections with
such names. Also, linkers do not combine `.stack_sizes.*` into `.stack_sizes`.

A mini discussion about this correctness issue is here: https://reviews.llvm.org/D67757#inline-609274
This patch changes implementation so that only now only '.stack_sizes' name is
accepted as a real stack sizes section.


https://reviews.llvm.org/D67824

Files:
  test/tools/llvm-readobj/stack-sizes.test
  tools/llvm-readobj/ELFDumper.cpp


Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -4830,7 +4830,7 @@
   StringRef FileStr = Obj->getFileName();
   for (const SectionRef &Sec : Obj->sections()) {
     StringRef SectionName = getSectionName(Sec);
-    if (!SectionName.startswith(".stack_sizes"))
+    if (SectionName != ".stack_sizes")
       continue;
     PrintHeader();
     const Elf_Shdr *ElfSec = Obj->getSection(Sec.getRawDataRefImpl());
@@ -4883,7 +4883,7 @@
 
     // A stack size section that we haven't encountered yet is mapped to the
     // null section until we find its corresponding relocation section.
-    if (SectionName.startswith(".stack_sizes"))
+    if (SectionName == ".stack_sizes")
       if (StackSizeRelocMap.count(Sec) == 0) {
         StackSizeRelocMap[Sec] = NullSection;
         continue;
@@ -4904,7 +4904,7 @@
       consumeError(ContentsSectionNameOrErr.takeError());
       continue;
     }
-    if (!ContentsSectionNameOrErr->startswith(".stack_sizes"))
+    if ((*ContentsSectionNameOrErr) != ".stack_sizes")
       continue;
     // Insert a mapping from the stack sizes section to its relocation section.
     StackSizeRelocMap[Obj->toSectionRef(ContentsSec)] = Sec;
Index: test/tools/llvm-readobj/stack-sizes.test
===================================================================
--- test/tools/llvm-readobj/stack-sizes.test
+++ test/tools/llvm-readobj/stack-sizes.test
@@ -32,7 +32,7 @@
 ## followed by a ULEB for the size.
     Content: "000000000000000010000000000000000020"
     Link:    .text
-  - Name:    .stack_sizes.baz
+  - Name:    '.stack_sizes [1]'
     Type:    SHT_PROGBITS
 ## One stack size entry.
     Content: "200000000000000008"
@@ -50,9 +50,9 @@
         Addend: 16
         Symbol: .text
         Type:   R_X86_64_64
-  - Name:   .rela.stack_sizes.baz
+  - Name:   '.rela.stack_sizes [1]'
     Type:   SHT_RELA
-    Info:   .stack_sizes.baz
+    Info:   '.stack_sizes [1]'
     Relocations:
       - Offset: 0
         Symbol: separate_text_section_baz


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67824.220990.patch
Type: text/x-patch
Size: 2122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190920/267bf616/attachment.bin>


More information about the llvm-commits mailing list