tls_common.exp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Expect script for .tls_common tests
  2. # Copyright (C) 2006-2022 Free Software Foundation, Inc.
  3. #
  4. # This file is part of the GNU Binutils.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  19. # MA 02110-1301, USA.
  20. #
  21. # Written by Jakub Jelinek (jakub@redhat.com)
  22. #
  23. # Make sure that binutils can correctly handle ld output in ELF.
  24. if { !([istarget *-*-linux*]
  25. || [istarget arm*-*-uclinuxfdpiceabi]
  26. || [istarget *-*-nacl*]
  27. || [istarget *-*-gnu*]) || [istarget *ecoff] } then {
  28. return
  29. }
  30. if { ![ld_assemble $as "--elf-stt-common=no $srcdir/$subdir/tls_common.s" tmpdir/tls_commona.o]
  31. || ![ld_assemble $as "--elf-stt-common=yes $srcdir/$subdir/tls_common.s" tmpdir/tls_commonb.o] } {
  32. unsupported "tls_common"
  33. return
  34. }
  35. if { ![ld_link $ld tmpdir/tls_common1a.o "-r tmpdir/tls_commona.o"]
  36. || ![ld_link $ld tmpdir/tls_common1b.o "-r tmpdir/tls_commona.o"] } {
  37. fail "tls_common"
  38. return
  39. }
  40. if { ![ld_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
  41. if { [string match "*not supported*" $link_output]
  42. || [string match "*unrecognized option*" $link_output] } {
  43. unsupported "$ld_options is not supported by this target"
  44. } else {
  45. fail "tls_common"
  46. }
  47. return
  48. }
  49. if { ![ld_link $ld tmpdir/tls_commonb "tmpdir/tls_common1b.o"] } {
  50. if { [string match "*not supported*" $link_output]
  51. || [string match "*unrecognized option*" $link_output] } {
  52. unsupported "$ld_options is not supported by this target"
  53. } else {
  54. fail "tls_common"
  55. }
  56. return
  57. }
  58. set readelf_output [run_host_cmd "$READELF" "-l --wide tmpdir/tls_commona"]
  59. if ![regexp ".*TLS.*0x0+ 0x0+4 R .*" $readelf_output] then {
  60. send_log "$readelf_output\n"
  61. fail "tls_common"
  62. return
  63. }
  64. set readelf_output [run_host_cmd "$READELF" "-l --wide tmpdir/tls_commona"]
  65. if ![regexp ".*TLS.*0x0+ 0x0+4 R .*" $readelf_output] then {
  66. send_log "$readelf_output\n"
  67. fail "tls_common"
  68. return
  69. }
  70. pass "tls_common"