[PATCH] D69305: [llvm/Object] - Fix the error message reported for a broken SHT_SYMTAB_SHNDX section.
George R. via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 25 02:28:51 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53c164e2216f: [llvm/Object] - Fix the error message reported for a broken SHT_SYMTAB_SHNDX… (authored by georgerim).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D69305?vs=226040&id=226386#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69305/new/
https://reviews.llvm.org/D69305
Files:
llvm/include/llvm/Object/ELF.h
llvm/test/Object/invalid.test
llvm/test/tools/obj2yaml/elf-sht-symtab-shndx.yaml
Index: llvm/test/tools/obj2yaml/elf-sht-symtab-shndx.yaml
===================================================================
--- llvm/test/tools/obj2yaml/elf-sht-symtab-shndx.yaml
+++ llvm/test/tools/obj2yaml/elf-sht-symtab-shndx.yaml
@@ -98,8 +98,7 @@
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: not obj2yaml %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4
-## FIXME: The error message below needs rewording. Size should not be equal to the number of symbols.
-## CASE4: Error reading file: [[FILE]]: SHT_SYMTAB_SHNDX section has sh_size (48) which is not equal to the number of symbols (3)
+## CASE4: Error reading file: [[FILE]]: SHT_SYMTAB_SHNDX has 3 entries, but the symbol table associated has 2
--- !ELF
FileHeader:
Index: llvm/test/Object/invalid.test
===================================================================
--- llvm/test/Object/invalid.test
+++ llvm/test/Object/invalid.test
@@ -213,7 +213,7 @@
# RUN: yaml2obj %s --docnum=11 -o %t11
# RUN: not llvm-readobj --symbols %t11 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
-# INVALID-XINDEX-SIZE: error: {{.*}}: SHT_SYMTAB_SHNDX section has sh_size (24) which is not equal to the number of symbols (2)
+# INVALID-XINDEX-SIZE: error: {{.*}}: SHT_SYMTAB_SHNDX has 2 entries, but the symbol table associated has 1
--- !ELF
FileHeader:
Index: llvm/include/llvm/Object/ELF.h
===================================================================
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -641,11 +641,12 @@
SymTable.sh_type) +
" section (expected SHT_SYMTAB/SHT_DYNSYM)");
- if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
- return createError("SHT_SYMTAB_SHNDX section has sh_size (" +
- Twine(SymTable.sh_size) +
- ") which is not equal to the number of symbols (" +
- Twine(V.size()) + ")");
+ uint64_t Syms = SymTable.sh_size / sizeof(Elf_Sym);
+ if (V.size() != Syms)
+ return createError("SHT_SYMTAB_SHNDX has " + Twine(V.size()) +
+ " entries, but the symbol table associated has " +
+ Twine(Syms));
+
return V;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69305.226386.patch
Type: text/x-patch
Size: 2258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191025/c3ae44b1/attachment.bin>
More information about the llvm-commits
mailing list