eh-group.exp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Expect script for .eh_frame entries to a removed section.
  2. # Copyright (C) 2008-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. #
  22. # Written by Jan Kratochvil (jan.kratochvil@redhat.com)
  23. #
  24. # .eh_frame with relocations to a removed (group) section did result to:
  25. # error in tmpdir/eh-group.o(.eh_frame); no .eh_frame_hdr table will be created.
  26. # The purpose of this test is to merge two .o files with -r and then link this
  27. # merged file (containing a discarded R_X86_64_NONE relocation) to the final
  28. # executable trying to create .eh_frame_hdr. It needs a separate .exp file due
  29. # to the requirement of two `ld' runs.
  30. # Exclude non-CFI (such as ia64) targets.
  31. if {![check_as_cfi]} {
  32. return
  33. }
  34. # The test uses ELF .section directive
  35. if ![is_elf_format] {
  36. return
  37. }
  38. # alpha-linux-gnu does not support 64-bit relocations:
  39. # relocation truncated to fit: REFLONG against `.gcc_except_table'
  40. # arm-eabi does not support 64-bit relocations:
  41. # bad relocation fixup type (1)
  42. set testname "Guess the target size from eh-group1size.o"
  43. if [ld_assemble $as "$srcdir/$subdir/eh-group1.s" "tmpdir/eh-group1size.o"] {
  44. pass $testname
  45. } else {
  46. fail $testname
  47. }
  48. set as_options ""
  49. if [is_elf64 "tmpdir/eh-group1size.o"] {
  50. set as_options "$as_options --defsym ELF64=1"
  51. }
  52. set build_tests_ld [list \
  53. [list "Build eh-group1.o" \
  54. "-r" "" "$as_options" \
  55. {eh-group1.s eh-group2.s} {} "eh-group.o"] \
  56. ]
  57. run_ld_link_tests $build_tests_ld
  58. set testname "Link eh-group.o to eh-group"
  59. if [ld_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
  60. pass $testname
  61. } else {
  62. fail $testname
  63. }