comm-data.exp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Expect script for common symbol override.
  2. #
  3. # Copyright (C) 2011-2022 Free Software Foundation, Inc.
  4. #
  5. # This file is part of the GNU Binutils.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  20. # MA 02110-1301, USA.
  21. #
  22. #
  23. # Written by Maciej W. Rozycki <macro@codesourcery.com>
  24. #
  25. # This test is for ELF shared-library targets.
  26. if { ![is_elf_format] || ![check_shared_lib_support] } {
  27. return
  28. }
  29. # This target requires extra GAS options when building code for shared
  30. # libraries.
  31. set AFLAGS_PIC ""
  32. if [istarget "tic6x-*-*"] {
  33. append AFLAGS_PIC " -mpic -mpid=near"
  34. }
  35. # This target requires a non-default emulation for successful shared
  36. # library/executable builds.
  37. set LFLAGS ""
  38. if [istarget "tic6x-*-*"] {
  39. append LFLAGS " -melf32_tic6x_le"
  40. }
  41. # These targets do not default to linking with shared libraries.
  42. if { [istarget "mips*vr4100*-*-elf*"] \
  43. || [istarget "mips*vr4300*-*-elf*"] \
  44. || [istarget "mips*vr5000*-*-elf*"] } {
  45. append LFLAGS " -call_shared"
  46. }
  47. # Set the pointer size according to the ELF flavor.
  48. set AFLAGS ""
  49. if [is_elf64 "tmpdir/libcomm-data.so"] {
  50. append AFLAGS " --defsym ELF64=1"
  51. }
  52. # HPUX targets use a different .comm syntax.
  53. if [istarget "*-*-hpux*"] {
  54. append AFLAGS " --defsym HPUX=1"
  55. }
  56. set testname "Common symbol override test"
  57. # Define a global symbol.
  58. run_ld_link_tests [list \
  59. [list \
  60. "$testname (auxiliary shared object build)" \
  61. "$LFLAGS -shared" "" \
  62. "$AFLAGS_PIC" \
  63. { comm-data1.s } \
  64. { \
  65. { readelf -s comm-data1.sd } \
  66. } \
  67. "libcomm-data.so" \
  68. ] \
  69. [list \
  70. "libpr26580-1.so" \
  71. "$LFLAGS -shared" "" \
  72. "$AFLAGS_PIC $AFLAGS" \
  73. { pr26580-b.s } \
  74. { } \
  75. "libpr26580-1.so" \
  76. ] \
  77. ]
  78. # bfin-elf does not currently support copy relocs.
  79. setup_xfail "bfin-*-*"
  80. clear_xfail "bfin-*-linux-uclibc*"
  81. # Verify that a common symbol has been converted to an undefined
  82. # reference to the global symbol of the same name defined above
  83. # and that the debug reference has been dropped.
  84. run_ld_link_tests [list \
  85. [list \
  86. "$testname" \
  87. "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
  88. "$AFLAGS" \
  89. { comm-data2.s } \
  90. [list \
  91. [list readelf -s comm-data2.sd] \
  92. [list readelf -r comm-data2.rd] \
  93. [list readelf "-x .debug_foo" comm-data2.xd]] \
  94. "comm-data" \
  95. ] \
  96. [list \
  97. "$testname 3a" \
  98. "-static" "" \
  99. "" \
  100. { comm-data3a.s comm-data3b.s } \
  101. { \
  102. { readelf -s comm-data3.sd } \
  103. } \
  104. "comm-data3a" \
  105. ] \
  106. [list \
  107. "$testname 3b" \
  108. "-static" "" \
  109. "" \
  110. { comm-data3b.s comm-data3a.s } \
  111. { \
  112. { readelf -s comm-data3.sd } \
  113. } \
  114. "comm-data3b" \
  115. ] \
  116. [list \
  117. "pr26580-1" \
  118. "$LFLAGS --as-needed -Ltmpdir -lpr26580-1" "" \
  119. "$AFLAGS" \
  120. { pr26580-a.s } \
  121. { {readelf -s pr26580-1.sd} } \
  122. "pr26580-1" \
  123. ] \
  124. [list \
  125. "pr26580-2" \
  126. "$LFLAGS --no-as-needed -Ltmpdir -lpr26580-1" "" \
  127. "$AFLAGS" \
  128. { pr26580-a.s } \
  129. { {readelf -s pr26580-2.sd} } \
  130. "pr26580-2" \
  131. ] \
  132. ]