diff options
author | Masatake Yamato <yamato@redhat.com> | 2018-11-07 18:07:36 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-11-07 18:07:36 +0000 |
commit | d3def5d73eb9d8295ca7b11d130b17a815151951 (patch) | |
tree | 037c3d7c37564e655599bd565b23d22822ed3992 /binutils/testsuite | |
parent | 0661ae2e5324719f7850e81fc1da9f6505361ae4 (diff) | |
download | gdb-d3def5d73eb9d8295ca7b11d130b17a815151951.zip gdb-d3def5d73eb9d8295ca7b11d130b17a815151951.tar.gz gdb-d3def5d73eb9d8295ca7b11d130b17a815151951.tar.bz2 |
Enhance objdump's --disassemble switch so that it can now take an optional parameter, specifying the starting symbol for disassembly. Disassembly will continue from this symbol up to the next symbol.
* objdump.c (long_options): Have the --disassemble option take an
optional argument.
(usage): Add description for the `symbol' argument to the
--disassemble option.
(disasm_sym): New file private variable.
(struct objdump_disasm_info): New field `symbol'.
(disassemble_section): Introduce `do_print' local variable
to control whether objdump displays the result of disassembling
for a symbol or not.
(main): Set `symbol' file private variable if the option argument
for the --disassemble option is given.
* doc/binutils.texi (objdump): Add description for the option
argument.
* NEWS: Mention the new feature.
* testsuite/binutils-all/objdump.exp: Add tests of the -d and
--disassemble=<symbol> options.
* testsuite/binutils-all/bintest.s: Add more symbols and code.
* testsuite/binutils-all/readelf.s: Update expected output.
* testsuite/binutils-all/readelf.ss-64: Likewise.
* testsuite/binutils-all/readelf.ss-mips: Likewise.
* testsuite/binutils-all/readelf.ss-tmips: Likewise.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/binutils-all/bintest.s | 8 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 1 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.exp | 82 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.s | 5 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.ss | 12 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.ss-64 | 1 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.ss-mips | 4 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/readelf.ss-tmips | 4 |
8 files changed, 105 insertions, 12 deletions
diff --git a/binutils/testsuite/binutils-all/bintest.s b/binutils/testsuite/binutils-all/bintest.s index 9e00650..dcf742f 100644 --- a/binutils/testsuite/binutils-all/bintest.s +++ b/binutils/testsuite/binutils-all/bintest.s @@ -10,3 +10,11 @@ data_symbol: static_data_symbol: .long 2 .comm common_symbol,4 + .text + .global text_symbol2 +text_symbol2: + .long 2 + .global text_symbol3 +text_symbol3: + .long 3 + diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 3676f76..762bd0a 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -80,6 +80,7 @@ proc objcopy_test {testname srcfile} { setup_xfail "hppa*-*-*" setup_xfail "m8*-*" setup_xfail "sh-*-coff*" + setup_xfail "tic54x-*-*" setup_xfail "tic80-*-*" clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*" diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp index effc3dd..b1dea8d 100644 --- a/binutils/testsuite/binutils-all/objdump.exp +++ b/binutils/testsuite/binutils-all/objdump.exp @@ -206,6 +206,85 @@ if { [ remote_file host exists $testarchive ] } then { test_objdump_r $testarchive bintest2.o } +# Test objdump -d +proc test_objdump_d { testfile dumpfile } { + global OBJDUMP + global OBJDUMPFLAGS + + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d $testfile"] + + set want "$dumpfile:.*Disassembly of section" + if ![regexp $want $got] then { + fail "objdump -d $testfile: No disassembly title" + return + } + + set want "$dumpfile:.*00+0 <text_symbol>" + if ![regexp $want $got] then { + fail "objdump -d $testfile: Missing symbol name and address" + return + } + + set want "$dumpfile:.*00+. <text_symbol2>" + if ![regexp $want $got] then { + fail "objdump -d $testfile: Missing second symbol" + return + } + + set want "$dumpfile:.*00+. <text_symbol3>" + if ![regexp $want $got] then { + fail "objdump -d $testfile: Missing third symbol" + return + } + + pass "objdump -d $testfile" +} + +test_objdump_d $testfile $testfile +if { [ remote_file host exists $testarchive ] } then { + test_objdump_d $testarchive bintest2.o +} + +# Test objdump --disassemble=<symbol> +proc test_objdump_d_sym { testfile dumpfile } { + global OBJDUMP + global OBJDUMPFLAGS + + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble=text_symbol2 $testfile"] + + set want "$dumpfile:.*Disassembly of section" + if ![regexp $want $got] then { + fail "objdump --disassemble=text_symbol2 $testfile: No disassembly title" + return + } + + set want "$dumpfile:.*00+0 <text_symbol>" + if [regexp $want $got] then { + fail "objdump --disassemble=text_symbol2 $testfile: First symbol displayed, when it should be absent" + return + } + + set want "$dumpfile:.*00+. <text_symbol2>" + if ![regexp $want $got] then { + fail "objdump --disassemble=text_symbol2 $testfile: Missing second symbol" + return + } + + set want "$dumpfile:.*00+. <text_symbol3>" + if [regexp $want $got] then { + fail "objdump --disassemble=text_symbol2 $testfile: Third symbol displayed when it should be absent" + return + } + + pass "objdump --disassemble=text_symbol2 $testfile" +} + +test_objdump_d_sym $testfile $testfile +if { [ remote_file host exists $testarchive ] } then { + test_objdump_d_sym $testarchive bintest2.o +} + + # Test objdump -s proc test_objdump_s { testfile dumpfile } { @@ -505,8 +584,7 @@ if {[is_elf_format]} then { test_follow_debuglink } - -# Options which are not tested: -a -d -D -R -T -x -l --stabs +# Options which are not tested: -a -D -R -T -x -l --stabs # I don't see any generic way to test any of these other than -a. # Tests could be written for specific targets, and that should be done # if specific problems are found. diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s index 5aae0ce..6ae4dc7 100644 --- a/binutils/testsuite/binutils-all/readelf.s +++ b/binutils/testsuite/binutils-all/readelf.s @@ -9,8 +9,9 @@ Section Headers: +\[ 2\] .rel.* +REL. +0+ 0+.* 0000.. 0. +I +.+ +1 +4 # MIPS targets put .rela.text here. #... - +\[ .\] .* +PROGBITS +00000000 0000(3c|40|48|50) 0000(04|10) 00 +WA +0 +0 +(.|..) - +\[ .\] .* +NOBITS +00000000 0000(40|44|4c|60) 000000 00 +WA +0 +0 +(.|..) + +\[ .\] .* +PROGBITS +00000000 0000(3c|40|44|48|50) 0000(04|10) 00 +WA +0 +0 +(.|..) + +\[ .\] .* +NOBITS +00000000 0000(40|44|48|4c|60) 000000 00 +WA +0 +0 +(.|..) +# ARM targets put .ARM.attributes here # MIPS targets put .reginfo, .mdebug, .MIPS.abiflags and .gnu.attributes here. # v850 targets put .call_table_data and .call_table_text here. #... diff --git a/binutils/testsuite/binutils-all/readelf.ss b/binutils/testsuite/binutils-all/readelf.ss index e9ab3ef..acc6d93 100644 --- a/binutils/testsuite/binutils-all/readelf.ss +++ b/binutils/testsuite/binutils-all/readelf.ss @@ -6,15 +6,15 @@ Symbol table '.symtab' contains .* entries: +2: 00000000 +0 +SECTION +LOCAL +DEFAULT +[34] +3: 00000000 +0 +SECTION +LOCAL +DEFAULT +[45] +4: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +1 static_text_symbol -# arm-elf targets add the $d mapping symbol here... +# ARM targets add the $d mapping symbol here... +# NDS32 targets add the $d2 mapping symbol here... #... +.: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +[34] static_data_symbol # v850 targets include extra SECTION symbols here for the .call_table_data # and .call_table_text sections. #... - +.: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 text_symbol - +..: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol - +..: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +[34] data_symbol - +..: 00000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(COM|ANSI_COM) common_symbol -# The MSP430 adds special crt0 symbols here. + +[0-9]+: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 text_symbol + +[0-9]+: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol + +[0-9]+: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +[34] data_symbol + +[0-9]+: 00000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(COM|ANSI_COM) common_symbol #... diff --git a/binutils/testsuite/binutils-all/readelf.ss-64 b/binutils/testsuite/binutils-all/readelf.ss-64 index b67bfda..bd10cab 100644 --- a/binutils/testsuite/binutils-all/readelf.ss-64 +++ b/binutils/testsuite/binutils-all/readelf.ss-64 @@ -15,3 +15,4 @@ Symbol table '.symtab' contains .* entries: +.: 0000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol +.: 0000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +3 data_symbol +[0-9]+: 0000000000000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +COM common_symbol +#pass diff --git a/binutils/testsuite/binutils-all/readelf.ss-mips b/binutils/testsuite/binutils-all/readelf.ss-mips index 01d3df1..9f4cfa5 100644 --- a/binutils/testsuite/binutils-all/readelf.ss-mips +++ b/binutils/testsuite/binutils-all/readelf.ss-mips @@ -1,5 +1,5 @@ -Symbol table '.symtab' contains 14 entries: +Symbol table '.symtab' contains 16 entries: +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +0: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +UND +1: 00000000 +0 +SECTION +LOCAL +DEFAULT +. (|\.text) @@ -15,3 +15,5 @@ Symbol table '.symtab' contains 14 entries: +11: 00000000 +0 +OBJECT +GLOBAL +DEFAULT +. data_symbol +12: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +. static_data_symbol +13: 00000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(PRC|COM) common_symbol + +14: 00000008 +0 +OBJECT +GLOBAL +DEFAULT +. text_symbol2 + +15: 0000000c +0 +OBJECT +GLOBAL +DEFAULT +. text_symbol3 diff --git a/binutils/testsuite/binutils-all/readelf.ss-tmips b/binutils/testsuite/binutils-all/readelf.ss-tmips index c59f753..d22fc08 100644 --- a/binutils/testsuite/binutils-all/readelf.ss-tmips +++ b/binutils/testsuite/binutils-all/readelf.ss-tmips @@ -1,5 +1,5 @@ -Symbol table '.symtab' contains 14 entries: +Symbol table '.symtab' contains 16 entries: +Num: +Value +Size +Type +Bind +Vis +Ndx +Name +0: 00000000 +0 +NOTYPE +LOCAL +DEFAULT +UND +1: 00000000 +0 +SECTION +LOCAL +DEFAULT +1 @@ -15,3 +15,5 @@ Symbol table '.symtab' contains 14 entries: +11: 00000000 +0 +NOTYPE +GLOBAL +DEFAULT +UND external_symbol +12: 00000000 +0 +OBJECT +GLOBAL +DEFAULT +3 data_symbol +13: 00000004 +4 +(COMMON|OBJECT) +GLOBAL +DEFAULT +(PRC|COM) common_symbol + +14: 00000008 +0 +OBJECT +GLOBAL +DEFAULT +. text_symbol2 + +15: 0000000c +0 +OBJECT +GLOBAL +DEFAULT +. text_symbol3 |