[PATCH] D74955: [obj2yaml] - Dump SHT_STRTAB, SHT_SYMTAB and SHT_DYNSYM sections.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 22 03:35:26 PST 2020
grimar added a comment.
In D74955#1886907 <https://reviews.llvm.org/D74955#1886907>, @MaskRay wrote:
> Since rL238073 <https://reviews.llvm.org/rL238073>, clang no longer produces .shstrtab, but rather uses a unified .strtab for both section names and symbol names. Dumping `SHT_STRTAB` is necessary to differentiate the two cases.
>
> Do you mean that yaml2obj generated SHT_DYNSYM is not at the normal place (early in the section header table, somewhere before .rodata)?
No. The place is just different from the one in the original object.
See: imagine we have test.s:
.data
.section .bar,"a"
.quad .bar
.text
.section .foo,"ax"
.quad .foo
.section .zed,"ax"
.quad .foo
and do:
as test.s -o test.o
ld.bfd test.o -shared -o test.so
We have an output with the following section headers:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .hash HASH 0000000000000190 00000190
0000000000000010 0000000000000004 A 3 0 8
[ 2] .gnu.hash GNU_HASH 00000000000001a0 000001a0
000000000000001c 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 00000000000001c0 000001c0
0000000000000018 0000000000000018 A 4 1 8
[ 4] .dynstr STRTAB 00000000000001d8 000001d8
0000000000000001 0000000000000000 A 0 0 1
[ 5] .rela.dyn RELA 00000000000001e0 000001e0
0000000000000048 0000000000000018 A 3 0 8
[ 6] .foo PROGBITS 0000000000001000 00001000
0000000000000008 0000000000000000 AX 0 0 1
[ 7] .zed PROGBITS 0000000000001008 00001008
0000000000000008 0000000000000000 AX 0 0 1
[ 8] .bar PROGBITS 0000000000002000 00002000
0000000000000008 0000000000000000 A 0 0 1
[ 9] .eh_frame PROGBITS 0000000000002008 00002008
0000000000000000 0000000000000000 A 0 0 8
[10] .dynamic DYNAMIC 0000000000003ef0 00002ef0
0000000000000110 0000000000000010 WA 4 0 8
[11] .symtab SYMTAB 0000000000000000 00003000
0000000000000120 0000000000000018 12 12 8
[12] .strtab STRTAB 0000000000000000 00003120
000000000000000a 0000000000000000 0 0 1
[13] .shstrtab STRTAB 0000000000000000 0000312a
0000000000000061 0000000000000000 0 0 1
Then after invoking obj2yaml and yaml2obj we have:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .hash HASH 0000000000000190 00000040
0000000000000010 0000000000000000 A 9 0 8
[ 2] .gnu.hash GNU_HASH 00000000000001a0 00000050
000000000000001c 0000000000000000 A 9 0 8
[ 3] .rela.dyn RELA 00000000000001e0 00000070
0000000000000048 0000000000000018 A 9 0 8
[ 4] .foo PROGBITS 0000000000001000 000000b8
0000000000000008 0000000000000000 AX 0 0 1
[ 5] .zed PROGBITS 0000000000001008 000000c0
0000000000000008 0000000000000000 AX 0 0 1
[ 6] .bar PROGBITS 0000000000002000 000000c8
0000000000000008 0000000000000000 A 0 0 1
[ 7] .eh_frame PROGBITS 0000000000002008 000000d0
0000000000000000 0000000000000000 A 0 0 8
[ 8] .dynamic DYNAMIC 0000000000003ef0 000000d0
0000000000000110 0000000000000010 WA 10 0 8
[ 9] .dynsym DYNSYM 0000000000000000 000001e0
0000000000000018 0000000000000018 A 10 1 8
[10] .dynstr STRTAB 0000000000000000 000001f8
0000000000000001 0000000000000000 A 0 0 1
[11] .symtab SYMTAB 0000000000000000 00000200
0000000000000120 0000000000000018 12 12 8
[12] .strtab STRTAB 0000000000000000 00000320
0000000000000050 0000000000000000 0 0 1
[13] .shstrtab STRTAB 0000000000000000 00000370
0000000000000061 0000000000000000 0 0 1
Note that `.dynsym` and `.dynstr` changed their location. That happened
because obj2yaml did not dump them and hence yaml2obj added them to the end of the list,
together with `.symtab`,`.strtab` and `.shstrtab`.
With this patch it is possible to preserve the original sections order as obj2yaml starts to create placeholders for them.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74955/new/
https://reviews.llvm.org/D74955
More information about the llvm-commits
mailing list