]> granicus.if.org Git - llvm/commit
[yaml2obj/obj2yaml] - Move `Info` field out from `Section` class.
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 12 Feb 2019 09:08:59 +0000 (09:08 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 12 Feb 2019 09:08:59 +0000 (09:08 +0000)
commit1ee69f0dfeab734abf0c67b45939286c0a6c2001
tree450ae7da3b24febb635dc77af5bbb2e6588b0184
parenta43cecd3b42dc0d4cc15a7d2acd4c650cee64909
[yaml2obj/obj2yaml] - Move `Info` field out from `Section` class.

ELFYAML.h contains a `Section` class which is a base for a few other
sections classes that are used for mapping different section types.
`Section` has a `StringRef Info` field used for storing sh_info.

At the same time, sh_info has very different meanings for sections and
cannot be processed in a similar way generally,
for example ELFDumper does not handle it in `dumpCommonSection`
but do that in `dumpGroup` and `dumpCommonRelocationSection` respectively.

At this moment, we have and handle it as a string, because that was possible for
the current use case. But also it can simply be a number:
For SHT_GNU_verdef is "The number of version definitions within the section."

The patch moves `Info` field out to be able to have it as a number.
With that change, each class will be able to decide what type and purpose
of the sh_info field it wants to use.

I also had to edit 2 test cases. This is because patch fixes a bug. Previously we
accepted yaml files with Info fields for all sections (for example, for SHT_DYNSYM too).
But we do not handle it and the resulting objects had zero sh_info fields set for
such sections. Now it is accepted only for sections that supports it.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353810 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ObjectYAML/ELFYAML.h
lib/ObjectYAML/ELFYAML.cpp
test/tools/llvm-readobj/demangle.test
test/tools/llvm-readobj/gnu-hash-symbols.test
tools/obj2yaml/elf2yaml.cpp
tools/yaml2obj/yaml2elf.cpp