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.
This commit is contained in:
parent
0661ae2e53
commit
d3def5d73e
12 changed files with 173 additions and 21 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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*"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
#...
|
||||
|
|
|
@ -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
|
||||
#...
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue