forked from Imagelibrary/binutils-gdb
objdump -D of bss sections and -s with -j
There is some inconsistency between the behaviour of objdump -D and objdump -s, both supposedly operating on all sections by default. objdump -s ignores bss sections, while objdump -D dissassembles the zeros. Fix this by making objdump -D ignore bss sections too. Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should, since the user is specifically asking to look at all those zeros. This change does find some tests that used objdump -D with expected output in bss-style sections. I've updated all the msp430 tests that just wanted to find a non-empty section to look at section headers instead, making the tests slightly more stringent. The ppc xcoff and spu tests are fixed by adding -j options to objdump, which makes the tests somewhat more lenient. binutils/ * objdump.c (disassemble_section): Ignore sections without contents, unless overridden by -j. (dump_section): Allow -j to override the default of not displaying sections without contents. * doc/binutils.texi (objdump options): Update -D, -s and -j description. gas/ * testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump sections with -j. * testsuite/gas/ppc/xcoff-tls-64.d: Likewise. ld/ * testsuite/ld-msp430-elf/main-bss-lower.d, * testsuite/ld-msp430-elf/main-bss-upper.d, * testsuite/ld-msp430-elf/main-const-lower.d, * testsuite/ld-msp430-elf/main-const-upper.d, * testsuite/ld-msp430-elf/main-text-lower.d, * testsuite/ld-msp430-elf/main-text-upper.d, * testsuite/ld-msp430-elf/main-var-lower.d, * testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output. * testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh rather than objdump -D or objdump -d with tests checking for non-empty given sections. * testsuite/ld-spu/ear.d, * testsuite/ld-spu/icache1.d, * testsuite/ld-spu/ovl.d, * testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
This commit is contained in:
@@ -2407,8 +2407,9 @@ used when disassembling.
|
||||
|
||||
@item -D
|
||||
@itemx --disassemble-all
|
||||
Like @option{-d}, but disassemble the contents of all sections, not just
|
||||
those expected to contain instructions.
|
||||
Like @option{-d}, but disassemble the contents of all non-empty
|
||||
non-bss sections, not just those expected to contain instructions.
|
||||
@option{-j} may be used to select specific sections.
|
||||
|
||||
This option also has a subtle effect on the disassembly of
|
||||
instructions in code sections. When option @option{-d} is in effect
|
||||
@@ -2502,7 +2503,8 @@ for specification with @option{-b} or @option{-m}.
|
||||
@item -j @var{name}
|
||||
@itemx --section=@var{name}
|
||||
@cindex section information
|
||||
Display information only for section @var{name}.
|
||||
Display information for section @var{name}. This option may be
|
||||
specified multiple times.
|
||||
|
||||
@item -L
|
||||
@itemx --process-links
|
||||
@@ -2775,8 +2777,9 @@ disassembly.
|
||||
@itemx --full-contents
|
||||
@cindex sections, full contents
|
||||
@cindex object file sections
|
||||
Display the full contents of any sections requested. By default all
|
||||
non-empty sections are displayed.
|
||||
Display the full contents of sections, often used in combination with
|
||||
@option{-j} to request specific sections. By default all non-empty
|
||||
non-bss sections are displayed.
|
||||
|
||||
@item -S
|
||||
@itemx --source
|
||||
|
||||
@@ -3685,15 +3685,18 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
|
||||
next_sym
|
||||
} loop_until;
|
||||
|
||||
/* Sections that do not contain machine
|
||||
code are not normally disassembled. */
|
||||
if (! disassemble_all
|
||||
&& only_list == NULL
|
||||
&& ((section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
|
||||
!= (SEC_CODE | SEC_HAS_CONTENTS)))
|
||||
return;
|
||||
if (only_list == NULL)
|
||||
{
|
||||
/* Sections that do not contain machine
|
||||
code are not normally disassembled. */
|
||||
if ((section->flags & SEC_HAS_CONTENTS) == 0)
|
||||
return;
|
||||
|
||||
if (! process_section_p (section))
|
||||
if (! disassemble_all
|
||||
&& (section->flags & SEC_CODE) == 0)
|
||||
return;
|
||||
}
|
||||
else if (!process_section_p (section))
|
||||
return;
|
||||
|
||||
datasize = bfd_section_size (section);
|
||||
@@ -4970,10 +4973,12 @@ dump_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED)
|
||||
int count;
|
||||
int width;
|
||||
|
||||
if (! process_section_p (section))
|
||||
return;
|
||||
|
||||
if ((section->flags & SEC_HAS_CONTENTS) == 0)
|
||||
if (only_list == NULL)
|
||||
{
|
||||
if ((section->flags & SEC_HAS_CONTENTS) == 0)
|
||||
return;
|
||||
}
|
||||
else if (!process_section_p (section))
|
||||
return;
|
||||
|
||||
if ((datasize = bfd_section_size (section)) == 0)
|
||||
|
||||
Reference in New Issue
Block a user