From: George Rimar Date: Mon, 23 Sep 2019 10:43:09 +0000 (+0000) Subject: [llvm-readobj] - Stop treating ".stack_sizes.*" sections as stack sizes sections. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a572627318993d64ade4e4b534478f2f917dedc5;p=llvm [llvm-readobj] - Stop treating ".stack_sizes.*" sections as stack sizes sections. 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. Differential revision: https://reviews.llvm.org/D67824 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372578 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-readobj/stack-sizes.test b/test/tools/llvm-readobj/stack-sizes.test index 354391786bb..17ba092aafd 100644 --- a/test/tools/llvm-readobj/stack-sizes.test +++ b/test/tools/llvm-readobj/stack-sizes.test @@ -48,7 +48,7 @@ Sections: ## 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" @@ -66,9 +66,9 @@ Sections: 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 diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 316f49e071c..17d85c27ae0 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -4829,7 +4829,7 @@ void DumpStyle::printNonRelocatableStackSizes( 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()); @@ -4879,7 +4879,7 @@ void DumpStyle::printRelocatableStackSizes( // 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; @@ -4900,7 +4900,7 @@ void DumpStyle::printRelocatableStackSizes( 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;