]> granicus.if.org Git - llvm/commit
[yaml2obj/obj2yaml] - Add a basic support for extended section indexes.
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 09:49:05 +0000 (09:49 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 09:49:05 +0000 (09:49 +0000)
commite78ae1e5b624e1f9d56642faaba251f9b6e50a5e
treef4c5ae4140d283d19cce1d4c4fbf7bb42310d8b6
parent79c48fc453861f69d365e24a768eed52bac33c8f
[yaml2obj/obj2yaml] - Add a basic support for extended section indexes.

In some cases a symbol might have section index == SHN_XINDEX.
This is an escape value indicating that the actual section header index
is too large to fit in the containing field.
Then the SHT_SYMTAB_SHNDX section is used. It contains the 32bit values
that stores section indexes.

ELF gABI says that there can be multiple SHT_SYMTAB_SHNDX sections,
i.e. for example one for .symtab and one for .dynsym
(1) https://groups.google.com/forum/#!topic/generic-abi/-XJAV5d8PRg
(2) DT_SYMTAB_SHNDX: http://www.sco.com/developers/gabi/latest/ch5.dynamic.html

In this patch I am only supporting a single SHT_SYMTAB_SHNDX associated
with a .symtab. This is a more or less common case which is used a few tests I saw in LLVM.

I decided not to create the SHT_SYMTAB_SHNDX section as "implicit",
but implement is like a kind of regular section for now.
i.e. tools do not recreate this section or its content, like they do for
symbol table sections, for example. That should allow to write all kind of
possible broken test cases for our needs and keep the output closer to requested.

Differential revision: https://reviews.llvm.org/D65446

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368272 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Object/ELF.h
include/llvm/ObjectYAML/ELFYAML.h
lib/ObjectYAML/ELFEmitter.cpp
lib/ObjectYAML/ELFYAML.cpp
test/Object/invalid.test
test/tools/llvm-readobj/elf-section-types.test
test/tools/obj2yaml/Inputs/shn_xindex.o [deleted file]
test/tools/obj2yaml/elf-sht-symtab-shndx.yaml [new file with mode: 0644]
test/tools/obj2yaml/special-symbol-indices.yaml
test/tools/yaml2obj/elf-sht-symtab-shndx.yaml [new file with mode: 0644]
tools/obj2yaml/elf2yaml.cpp