[obj2yaml] - Dump section offsets in some cases.
Currently we never dump the `sh_offset` key. Though it sometimes an important information. To reduce the noise this patch implements the following logic: 1) The "Offset" key for the first section is always emitted. 2) If we can derive the offset for a next section naturally, then the "Offset" key is omitted. By "naturally" I mean that section[X] offset is expected to be: ``` offsetOf(section[X]) == alignTo(section[X - 1].sh_offset + section[X - 1].sh_size, section[X].sh_addralign) ``` So, when it has the expected value, we omit it from the output. Differential revision: https://reviews.llvm.org/D91152
Showing
- llvm/include/llvm/ObjectYAML/ELFYAML.h 3 additions, 0 deletionsllvm/include/llvm/ObjectYAML/ELFYAML.h
- llvm/lib/ObjectYAML/ELFEmitter.cpp 2 additions, 2 deletionsllvm/lib/ObjectYAML/ELFEmitter.cpp
- llvm/test/Object/obj2yaml.test 4 additions, 0 deletionsllvm/test/Object/obj2yaml.test
- llvm/test/tools/obj2yaml/ELF/offset.yaml 260 additions, 0 deletionsllvm/test/tools/obj2yaml/ELF/offset.yaml
- llvm/tools/obj2yaml/elf2yaml.cpp 38 additions, 0 deletionsllvm/tools/obj2yaml/elf2yaml.cpp
Loading
Please register or sign in to comment