[PATCH] D58498: [obj2yaml] - Do not miss section index for special symbols.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 21 07:02:33 PST 2019
grimar updated this revision to Diff 187791.
grimar marked 3 inline comments as done.
grimar retitled this revision from "[obj2yaml] - Do not miss section index for SHN_ABS and SHN_COMMON symbols." to "[obj2yaml] - Do not miss section index for special symbols.".
grimar edited the summary of this revision.
grimar added a comment.
- Addressed review comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58498/new/
https://reviews.llvm.org/D58498
Files:
test/tools/obj2yaml/Inputs/shn_xindex.o
test/tools/obj2yaml/special-symbols-indices.yaml
tools/obj2yaml/elf2yaml.cpp
Index: tools/obj2yaml/elf2yaml.cpp
===================================================================
--- tools/obj2yaml/elf2yaml.cpp
+++ tools/obj2yaml/elf2yaml.cpp
@@ -284,6 +284,13 @@
return errorToErrorCode(SymbolNameOrErr.takeError());
S.Name = SymbolNameOrErr.get();
+ if (Sym->st_shndx >= ELF::SHN_LORESERVE) {
+ if (Sym->st_shndx == ELF::SHN_XINDEX)
+ return obj2yaml_error::not_implemented;
+ S.Index = (ELFYAML::ELF_SHN)Sym->st_shndx;
+ return obj2yaml_error::success;
+ }
+
auto ShdrOrErr = Obj.getSection(Sym, SymTab, ShndxTable);
if (!ShdrOrErr)
return errorToErrorCode(ShdrOrErr.takeError());
Index: test/tools/obj2yaml/special-symbols-indices.yaml
===================================================================
--- /dev/null
+++ test/tools/obj2yaml/special-symbols-indices.yaml
@@ -0,0 +1,46 @@
+# RUN: yaml2obj %s > %t
+# RUN: obj2yaml %t | FileCheck %s
+
+## Test checks that we are able to handle symbols with special/reserved indices.
+
+# CHECK: Symbols:
+# CHECK-NEXT: Global:
+# CHECK-NEXT: - Name: absolute
+# CHECK-NEXT: Index: SHN_ABS
+# CHECK-NEXT: Value: 0x0000000000001234
+# CHECK-NEXT: - Name: common
+# CHECK-NEXT: Index: SHN_COMMON
+# CHECK-NEXT: - Name: valid_index
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: - Name: processor_specific_index
+# CHECK-NEXT: Index: SHN_HEXAGON_SCOMMON_1
+# CHECK-NEXT: - Name: unknown_index
+# CHECK-NEXT: Index: 0x0000FFFE
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_HEXAGON
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+Symbols:
+ Global:
+ - Name: absolute
+ Index: SHN_ABS
+ Value: 0x1234
+ - Name: common
+ Index: SHN_COMMON
+ - Name: valid_index
+ Index: 0x1
+ - Name: processor_specific_index
+ Index: SHN_HEXAGON_SCOMMON_1
+ - Name: unknown_index
+ Index: 0xfffe
+
+## shn_xindex.o contains a symbol with st_shndx == SHN_XINDEX.
+## We do not support it at this moment.
+# RUN: not obj2yaml %S/Inputs/shn_xindex.o 2>&1 | FileCheck %s --check-prefix=ERR
+# ERR: Error reading file: {{.*}}shn_xindex.o: Feature not yet implemented.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58498.187791.patch
Type: text/x-patch
Size: 2318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190221/a5723a2c/attachment.bin>
More information about the llvm-commits
mailing list