[PATCH] D65391: [ELF.h] - Check the case when e_shstrndx=SHN_XINDEX, but the corresponding sh_link is broken.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 02:28:54 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL368139: [ELF.h] - Check the case when e_shstrndx=SHN_XINDEX, but the corresponding… (authored by grimar, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D65391?vs=212584&id=213823#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65391

Files:
  llvm/trunk/include/llvm/Object/ELF.h
  llvm/trunk/test/Object/invalid.test


Index: llvm/trunk/include/llvm/Object/ELF.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELF.h
+++ llvm/trunk/include/llvm/Object/ELF.h
@@ -465,7 +465,6 @@
 
   if (!Index) // no section string table.
     return "";
-  // TODO: Test a case when the sh_link of the section with index 0 is broken.
   if (Index >= Sections.size())
     return createError("section header string table index " + Twine(Index) +
                        " does not exist");
Index: llvm/trunk/test/Object/invalid.test
===================================================================
--- llvm/trunk/test/Object/invalid.test
+++ llvm/trunk/test/Object/invalid.test
@@ -652,3 +652,23 @@
 DynamicSymbols:
   - Name:    foo
     Binding: STB_GLOBAL
+
+## Check the case when e_shstrndx == SHN_XINDEX, but null section's sh_link contains
+## the index of a section header string table that is larger than the number of the sections.
+
+# RUN: yaml2obj --docnum=31 %s -o %t31
+# RUN: not llvm-objcopy %t31 2>&1 | FileCheck %s -DFILE=%t31 --check-prefix=INVALID-SHSTRTAB-INDEX
+
+# INVALID-SHSTRTAB-INDEX: error: section header string table index 255 does not exist
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+## SHN_XINDEX == 0xffff.
+  SHStrNdx: 0xffff
+Sections:
+  - Type: SHT_NULL
+    Link: 0xff


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65391.213823.patch
Type: text/x-patch
Size: 1406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190807/f53d2327/attachment.bin>


More information about the llvm-commits mailing list