export-class.exp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Expect script for symbol export classes, PowerPC variation.
  2. #
  3. # Copyright (C) 2012-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. # Exclude non-Linux targets; feel free to include your favorite one
  26. # if you like.
  27. if { ![istarget powerpc*-*-linux*] } {
  28. return
  29. }
  30. proc powerpc_export_class_test { abi endian emul } {
  31. set testname "PowerPC $abi $endian symbol export class test"
  32. set AFLAGS "-a$abi -$endian"
  33. set LDFLAGS "-m$emul"
  34. # Build an auxiliary shared object with conflicting versioned symbol
  35. # definitions.
  36. run_ld_link_tests [list \
  37. [list \
  38. "$testname (auxiliary shared object)" \
  39. "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" "" \
  40. "$AFLAGS" \
  41. { ../ld-elf/export-class-lib.s } \
  42. {} \
  43. "powerpc-$abi-export-class-lib.so" \
  44. ] \
  45. ]
  46. # Build a static object that pulls symbol definitions. It has to come
  47. # first before the auxiliary shared object and other static objects on
  48. # the linker's command line and hence we need to build it separately.
  49. run_ld_link_tests [list \
  50. [list \
  51. "$testname (initial static object)" \
  52. "$LDFLAGS -r" "" \
  53. "$AFLAGS" \
  54. { ../ld-elf/export-class-ref.s } \
  55. {} \
  56. "powerpc-$abi-export-class-ref-r.o" \
  57. ] \
  58. ]
  59. # Build static objects that satisfy symbol dependencies and preempt
  60. # shared-object symbol definitions, and link all the objects built into
  61. # the final shared object. The command-line order of objects linked is
  62. # important to make sure the linker correctly preempts versioned symbols
  63. # from the auxiliary shared object and is as follows: ref, lib, dep, def.
  64. # Get a dump to make sure symbol dependencies are resolved internally.
  65. run_ld_link_tests [list \
  66. [list \
  67. "$testname (final shared object)" \
  68. "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/powerpc-$abi-export-class-ref-r.o tmpdir/powerpc-$abi-export-class-lib.so" "" \
  69. "$AFLAGS" \
  70. { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \
  71. [list \
  72. [list readelf -r powerpc-$abi-export-class.rd] \
  73. [list readelf "-x .data" powerpc-$abi-export-class.xd] \
  74. ] \
  75. "powerpc-$abi-export-class.so" \
  76. ] \
  77. ]
  78. }
  79. set abis { 32 be elf32ppclinux 32 le elf32lppclinux 64 be elf64ppc 64 le elf64lppc }
  80. catch "exec $ld --help | grep emulations" ldemul
  81. foreach { abi endian emul } $abis {
  82. if { [string first $emul $ldemul] != -1 } then {
  83. powerpc_export_class_test $abi $endian $emul
  84. }
  85. }