[PATCH] D75123: [obj2yaml, yaml2obj] - Read and dump the "Content" key of the RawContentSection section as array.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 01:59:57 PST 2020
grimar added a comment.
In D75123#1891658 <https://reviews.llvm.org/D75123#1891658>, @MaskRay wrote:
> Just wanted to flag up a concern: `"feff"` -> `[ 0xFE, 0xFF ]` can make an opaque section content longer.
>
> ## Comment 1.
> 0xfe, 0xfe,
> ## Comment 2.
> 0xfe, 0xfe ]
>
>
> Sometimes there may be a need to describe a little-endian 32-bit value, for example. Is the proposal to use `0x01, 0x00, 0x00, 0x00` for a little-endian 1?
Currently you can do:
---- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "01000000"
It does not matter if you use `ELFDATA2MSB` or `ELFDATA2LSB`. The output will be the same:
SectionData (
0000: 01000000
)
And the same happens when this patch is used with `Content: [ 0x01, 0x00, 0x00, 0x00 ]`:
we have the same result with LSB/MSB, so nothing really changed here.
> ~180 tests in `test/tools/llvm-{objcopy,xray,objdump,elfabi,ar,dwarfdump}` `test/Object` `test/DebugInfo` `lld/test/ELF` need an update, too.
Hmm that's right, thanks for spotting. Seems I was too focused in yaml2obj/obj2yaml tests and forgot to run others. I am OK to update them though.
> If we support both `"0001"` and `[ 0x00, 0x01 ]`, we don't have to update those tests.
I see next problems here:
1. I am not sure how to make yaml2obj and obj2yaml to support both ways. Perhaps it is possible, I need to investigate how much hard to do this. But anyways it should be more complicated than the current approach, which is trivial. I.e. I'd like to be sure we want to try to go this way before I actually try.
2. What should be the default output for obj2yaml? Should it print `[ 0x00, 0x01 ]`? Then people will probably often use the output from obj2yaml as a sample and will ignore "0011" form probably. Also "0011" form does not allow to use large peice of a content nicely as it prints it in a single line and makes almost improssible to comment those bytes properly.
3. Using large chunk of raw bytes is a bad practice. Should we care much about keeping a shorter way to describe it?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75123/new/
https://reviews.llvm.org/D75123
More information about the llvm-commits
mailing list