[PATCH] D58054: [yaml2obj/obj2yaml] - Move `Info` field out from `Section` class.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 11 08:01:02 PST 2019


grimar created this revision.
grimar added reviewers: ruiu, jhenderson, rupprecht, shankare.
Herald added a subscriber: jakehehrlich.
grimar edited the summary of this revision.

ELFYAML.h contains a `Section` class which is a base for a few other
sections classes that are used for mapping different section types.

In rL230124 <https://reviews.llvm.org/rL230124> `Info` field was moved there from `RelocationSection` class
because patch reused it for `Group` section type. `Info` has a string type.

At the same time, sh_info has very different meanings for sections.
For SHT_GROUP the meaning of sh_info is "The symbol table index of an entry
in the associated symbol table. The name of the specified symbol table entry provides
a signature for the section group."
And for SHT_REL[A] is "The section header index of the section to which the relocation
applies."

So it 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.
(see patch).

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,
see for example SHT_SUNW_verdef/SHT_SUNW_verneed sections (SHT_GNU_verdef/SHT_GNU_verneed):
https://docs.oracle.com/cd/E19683-01/816-1386/6m7qcoblj/index.html#chapter6-47976

Given above, I think keeping is as StringRef in a common `Section` class is probably wrong.
I want to move it out to be able to have it as a number and to implement dumping/parsing the versioning
sections mentioned above. 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 support it.


https://reviews.llvm.org/D58054

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58054.186262.patch
Type: text/x-patch
Size: 4659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190211/3fa1f5b0/attachment.bin>


More information about the llvm-commits mailing list