[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/23947] New: objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC)
From: |
ppluzhnikov at google dot com |
Subject: |
[Bug binutils/23947] New: objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC) sections |
Date: |
Sun, 02 Dec 2018 01:00:47 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=23947
Bug ID: 23947
Summary: objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC) sections
Product: binutils
Version: 2.32 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: ppluzhnikov at google dot com
Target Milestone: ---
On Fedora, /usr/bin/ls has a mini-symbols .gnu_debugdata section:
readelf -WS /usr/bin/ls
There are 30 section headers, starting at offset 0x26148:
...
[27] .gnu_debuglink PROGBITS 0000000000000000 025138 000020 00
0 0 4
I wanted to examine the contents of this section, so I did the usual:
objcopy -O binary -j.gnu_debuglink /usr/bin/ls /tmp/ls.mini.xz
but that produced an empty file. I had to resort to manually computing offset
and size, and doing dd to extract the contents.
AFAICT, this is happening because of the following check in bfd/binary.c:
284 /* We don't want to output anything for a section that is neither
285 loaded nor allocated. The contents of such a section are not
286 meaningful in the binary format. */
287 if ((sec->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
288 return TRUE;
289 if ((sec->flags & SEC_NEVER_LOAD) != 0)
290 return TRUE;
291
292 return _bfd_generic_set_section_contents (abfd, sec, data, offset,
size);
The statement that "contents is not meaningful in binary format" seems to be
patently false (or rather, assumes that "binary" is going to be used for a
specific purpose different from mine).
This appears to have been broken since forever:
^252b5132c7 (Richard Henderson 1999-05-03 07:29:11 +0000 284) /* We don't
want to output anything for a section that is neither
^252b5132c7 (Richard Henderson 1999-05-03 07:29:11 +0000 285) loaded nor
allocated. The contents of such a section are not
^252b5132c7 (Richard Henderson 1999-05-03 07:29:11 +0000 286) meaningful
in the binary format. */
^252b5132c7 (Richard Henderson 1999-05-03 07:29:11 +0000 287) if ((sec->flags
& (SEC_LOAD | SEC_ALLOC)) == 0)
b34976b65ae (Alan Modra 2002-11-30 08:39:46 +0000 288) return TRUE;
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug binutils/23947] New: objcopy refuses to copy !(SEC_LOAD|SEC_ALLOC) sections,
ppluzhnikov at google dot com <=