[yaml2obj/obj2yaml] - Add a basic support for extended section indexes.
commit80ba56dce36cbb5a791042a3d8a5a5d1ab154aea
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 09:49:05 +0000 (8 09:49 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 09:49:05 +0000 (8 09:49 +0000)
treef4c5ae4140d283d19cce1d4c4fbf7bb42310d8b6
parent9f63e8f09be5ffbd3e00e2ed469c575e7f9e5908
[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