objdump.exp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Copyright (C) 2016-2017 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  15. if {![istarget "arc*-*-*"]} then {
  16. return
  17. }
  18. if {[which $OBJDUMP] == 0} then {
  19. perror "$OBJDUMP does not exist"
  20. return
  21. }
  22. send_user "Version [binutil_version $OBJDUMP]"
  23. # Helper functions
  24. # Create object file from the assembly source.
  25. proc do_objfile { srcfile } {
  26. global srcdir
  27. global subdir
  28. set objfile [regsub -- "\.s$" $srcfile ".o"]
  29. if {![binutils_assemble $srcdir/$subdir/$srcfile tmpdir/$objfile]} then {
  30. return
  31. }
  32. if [is_remote host] {
  33. set objfile [remote_download host tmpdir/$objfile]
  34. } else {
  35. set objfile tmpdir/$objfile
  36. }
  37. return $objfile
  38. }
  39. # Ensure that disassembler output includes EXPECTED lines.
  40. proc check_assembly { testname objfile expected { disas_flags "" } } {
  41. global OBJDUMP
  42. global OBJDUMPFLAGS
  43. set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \
  44. $objfile"]
  45. if [regexp $expected $got] then {
  46. pass $testname
  47. } else {
  48. fail $testname
  49. }
  50. }
  51. # Make sure that a warning message is generated (because the disassembly does
  52. # not match the assembled instructions, which has happened because the user
  53. # has not specified a -M option on the disassembler command line, and so the
  54. # disassembler has had to guess as the instruction class in use).
  55. set want "Warning: disassembly.*vmac2hnfr\[ \t\]*r0,r2,r4.*dmulh12.f\[ \t\]*r0,r2,r4.*dmulh11.f"
  56. check_assembly "Warning test" [do_objfile dsp.s] $want
  57. set double_store_hs_expected {std\s*r0r1,\[r3\]}
  58. set objfile [do_objfile double_store.s]
  59. check_assembly "arc double_store default -M" $objfile \
  60. $double_store_hs_expected
  61. check_assembly "arc double_store -Mcpu=hs" $objfile \
  62. $double_store_hs_expected "-Mcpu=hs"
  63. check_assembly "arc double_store -Mcpu=hs38_linux" $objfile \
  64. $double_store_hs_expected "-Mcpu=hs38_linux"
  65. set double_store_em_expected ".long 0x1b000006"
  66. check_assembly "arc double_store -Mcpu=em" $objfile \
  67. $double_store_em_expected "-Mcpu=em"
  68. check_assembly "arc double_store -Mcpu=em4_dmips" $objfile \
  69. $double_store_em_expected "-Mcpu=em4_dmips"
  70. # Test to ensure that only value up to the next `,' is checked. There used to
  71. # be a bug, where whole `em,fpus' was compared against known CPU values, and
  72. # that comparison would fail. When this bug is present, whole cpu= option will
  73. # be ignored and instruction will be disassembled as ARC HS.
  74. check_assembly "arc double_store -Mcpu=em,fpus" $objfile \
  75. $double_store_em_expected "-Mcpu=em,fpus"
  76. # Make sure that the last cpu= value is used.
  77. check_assembly "arc double_store -Mcpu=hs,cpu=em" $objfile \
  78. $double_store_em_expected "-Mcpu=hs,cpu=em"