[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/23947] objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC) secti
nickc at redhat dot com
[Bug binutils/23947] objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC) sections
Fri, 21 Feb 2020 11:33:37 +0000
Nick Clifton <nickc at redhat dot com> changed:
What |Removed |Added
Ever confirmed|1 |0
--- Comment #3 from Nick Clifton <nickc at redhat dot com> ---
(In reply to Paul Pluzhnikov from comment #2)
> $ objdump -sj.strtab foo.o
> /build/binutils/objdump: section '.strtab' mentioned in a -j option, but not
Ah - this is more of a (mis-)feature than a bug. When the BFD library reads in
a file it converts some sections into special internal structure. This applies
to string tables, symbol tables and relocations. This means that when objdump
is asked to dump such sections it will not see them:
% objdump -sj.strtab -sj.symtab -sj.rela.eh_frame foo.o
objdump: section '.rela.eh_frame' mentioned in a -j option, but not found in
any input file
objdump: section '.symtab' mentioned in a -j option, but not found in any input
objdump: section '.strtab' mentioned in a -j option, but not found in any input
Similarly if you run "objdump --section-headers" you will not see these
In part this is why readelf might be considered to be superior to objdump,
since it has no such limitations:
% readelf -x.strtab -x.symtab -x.rela.eh_frame foo.o
Hex dump of section '.rela.eh_frame':
0x00000000 20000000 00000000 02000000 02000000 ...............
0x00000010 00000000 00000000 ........
Hex dump of section '.symtab':
0x00000000 00000000 00000000 00000000 00000000 ................
0x00000010 00000000 00000000 00000000 0400f1ff ................
Hex dump of section '.strtab':
0x00000000 007a6f72 6b00 .zork.
[I have truncated the output somewhat to save space in this reply].
Of course if you want to see the symbols in foo.o you can also use "objdump
--syms foo.o" and the relocs via "objdump --reloc foo.o". There is no direct
option to dump the string table however.
Also, just to cover a point raised in the original bug report. The reason
why the "contents are not considered meaningful in the binary format" is that
in this context "binary format" actually refers to a specific file format -
confusingly called 'binary' - rather than generically to any binary file. In
the "binary file format" any section that is not loaded or allocated cannot
have any purpose, and hence can be ignored.
As for looking at the contents of a specific section, you already know about
readelf's -x option (and presumably the -p and -R options), so why would you
need to use objcopy to extract a section before looking at it ?
Does this clear up your questions ? I would like to set this PR to
RESOLVED/NOTABUG if you are happy with my answers.
You are receiving this mail because:
You are on the CC list for the bug.