diff options
author | Nick Clifton <nickc@redhat.com> | 2019-01-17 15:29:43 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2019-01-17 15:29:43 +0000 |
commit | baae986a40eb2ed6d612436586bfa7dd1d88702d (patch) | |
tree | dbd18a9b28eb55af549e1e9bd5d94132c7fc7472 /binutils/testsuite | |
parent | e89c69419641d638a96cb7ca3c9fa4b3feac5ce0 (diff) | |
download | gdb-baae986a40eb2ed6d612436586bfa7dd1d88702d.zip gdb-baae986a40eb2ed6d612436586bfa7dd1d88702d.tar.gz gdb-baae986a40eb2ed6d612436586bfa7dd1d88702d.tar.bz2 |
Update objdump's --disassemble=<symbol> feature so that if <symbol> is a function, the entire function will be disassembled, regardless of the presence of interveening symbols.
* objdump.c (disassemble_section): When disassembling from a
symbol only stop at the next symbol if the original symbol was not
a function symbol. Otherwise continue disassembling until a new
function is reached.
* testsuite/binutils-all/objdump.exp: Add tests of extended
functionality.
* testsuite/binutils-all/disasm.s: New test source file.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/binutils-all/disasm.s | 24 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.exp | 93 |
2 files changed, 114 insertions, 3 deletions
diff --git a/binutils/testsuite/binutils-all/disasm.s b/binutils/testsuite/binutils-all/disasm.s new file mode 100644 index 0000000..7dccf9a --- /dev/null +++ b/binutils/testsuite/binutils-all/disasm.s @@ -0,0 +1,24 @@ + .text + + .globl start_of_text +start_of_text: + .type start_of_text, "function" + .long 1 + .size start_of_text, . - start_of_text + + .globl func +func: + .type func, "function" + .long 2 + .global global_non_func_sym +global_non_func_sym: + .long 3 +local_non_func_sym: + .long 4 + .size func, . - func + + .globl next_func +next_func: + .type next_func, "function" + .long 5 + .size next_func, . - next_func diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp index 50c81ba..dd2e9bb 100644 --- a/binutils/testsuite/binutils-all/objdump.exp +++ b/binutils/testsuite/binutils-all/objdump.exp @@ -62,7 +62,7 @@ if [regexp $want $got] then { if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { - fail "objdump (assembling)" + fail "objdump (assembling bintest.s)" return } if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest2.o]} then { @@ -280,8 +280,95 @@ proc test_objdump_d_sym { testfile dumpfile } { } test_objdump_d_sym $testfile $testfile -if { [ remote_file host exists $testarchive ] } then { - test_objdump_d_sym $testarchive bintest2.o + +proc test_objdump_d_func_sym { testfile dumpfile } { + global OBJDUMP + global OBJDUMPFLAGS + + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble=func --disassemble-zeroes $testfile"] + + set want "$dumpfile:.*Disassembly of section" + if ![regexp $want $got] then { + fail "objdump --disassemble=func $testfile: No disassembly title" + return + } + + set want "$dumpfile:.*00+0 <start_of_text>" + if [regexp $want $got] then { + fail "objdump --disassemble=func $testfile: First symbol displayed, when it should be absent" + return + } + + set want "$dumpfile:.*00+. <func>" + if ![regexp $want $got] then { + fail "objdump --disassemble=func $testfile: Disassembly does not start at function symbol" + return + } + + set want "$dumpfile:.*00+. <global_non_func_sym>" + if ![regexp $want $got] then { + fail "objdump --disassemble=func $testfile: Non function symbol not displayed" + return + } + + set want "$dumpfile:.*00+. <next_func>" + if [regexp $want $got] then { + fail "objdump --disassemble=func $testfile: Disassembly did not stop at the next function" + return + } + + pass "objdump --disassemble=func $testfile" +} + +proc test_objdump_d_non_func_sym { testfile dumpfile } { + global OBJDUMP + global OBJDUMPFLAGS + + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble=global_non_func_sym $testfile"] + + set want "$dumpfile:.*Disassembly of section" + if ![regexp $want $got] then { + fail "objdump --disassemble=non_func $testfile: No disassembly title" + return + } + + set want "$dumpfile:.*00+0 <start_of_text>" + if [regexp $want $got] then { + fail "objdump --disassemble=non_func $testfile: First symbol displayed, when it should be absent" + return + } + + set want "$dumpfile:.*00+. <global_non_func_sym>" + if ![regexp $want $got] then { + fail "objdump --disassemble=non_func $testfile: Non function symbol not displayed" + return + } + + set want "$dumpfile:.*00+. <local_non_func_sym>" + if [regexp $want $got] then { + fail "objdump --disassemble=non_func $testfile: Disassembly did not stop at the next symbol" + return + } + + pass "objdump --disassemble=non_func $testfile" +} + +# Extra test for ELF format - check that --disassemble=func disassembles +# all of func, and does not stop at the next symbol. +if { [is_elf_format] } then { + + if {![binutils_assemble $srcdir/$subdir/disasm.s tmpdir/disasm.o]} then { + fail "objdump --disassemble=func (assembling disasm.s)" + } else { + if [is_remote host] { + set elftestfile [remote_download host tmpdir/disasm.o] + } else { + set elftestfile tmpdir/disasm.o + } + + test_objdump_d_func_sym $elftestfile $elftestfile + test_objdump_d_non_func_sym $elftestfile $elftestfile + } } |