diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-02-22 08:45:21 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-02-22 08:45:21 +0000 |
| commit | 11358dd65d29a7ae50861aa5711092d7e9dd66d0 (patch) | |
| tree | 28ffe2cba36a31f0b881dc4e6248e1a7cd738dff /llvm/tools/obj2yaml | |
| parent | 151100787d35ebdba8584f3c3df7b9db33749190 (diff) | |
| download | bcm5719-llvm-11358dd65d29a7ae50861aa5711092d7e9dd66d0.tar.gz bcm5719-llvm-11358dd65d29a7ae50861aa5711092d7e9dd66d0.zip | |
[obj2yaml] - Do not miss section index for special symbols.
This fixes https://bugs.llvm.org/show_bug.cgi?id=40786
("obj2yaml symbol output missing section index for SHN_ABS and SHN_COMMON symbols")
Since SHN_ABS and SHN_COMMON symbols are special, we should preserve
the st_shndx for them. The patch does this for them and the other special symbols.
The test case is based on the test provided by James Henderson at the bug page!
Differential revision: https://reviews.llvm.org/D58498
llvm-svn: 354661
Diffstat (limited to 'llvm/tools/obj2yaml')
| -rw-r--r-- | llvm/tools/obj2yaml/elf2yaml.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index b02c25ad153..7f5e9a28d72 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -284,6 +284,13 @@ ELFDumper<ELFT>::dumpSymbol(const Elf_Sym *Sym, const Elf_Shdr *SymTab, 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()); |

