export-class.exp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Expect script for symbol export classes.
  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-ELF targets.
  26. if { ![is_elf_format] || ![check_shared_lib_support] } {
  27. return
  28. }
  29. # Exclude some more targets; feel free to include your favorite one
  30. # if you like.
  31. if { ![istarget *-*-linux*]
  32. && ![istarget arm*-*-uclinuxfdpiceabi]
  33. && ![istarget *-*-nacl*]
  34. && ![istarget *-*-gnu*] } {
  35. return
  36. }
  37. set testname "Symbol export class test"
  38. # Build an auxiliary shared object with conflicting versioned symbol
  39. # definitions.
  40. run_ld_link_tests [list \
  41. [list \
  42. "$testname (auxiliary shared object)" \
  43. "-shared -version-script export-class-lib.ver" "" \
  44. "" \
  45. { export-class-lib.s } \
  46. {} \
  47. "export-class-lib.so" \
  48. ] \
  49. ]
  50. # Build a static object that pulls symbol definitions. It has to come
  51. # first before the auxiliary shared object and other static objects on
  52. # the linker's command line and hence we need to build it separately.
  53. run_ld_link_tests [list \
  54. [list \
  55. "$testname (initial static object)" \
  56. "-r" "" \
  57. "" \
  58. { export-class-ref.s } \
  59. {} \
  60. "export-class-ref-r.o" \
  61. ] \
  62. ]
  63. # Build static objects that satisfy symbol dependencies and preempt
  64. # shared-object symbol definitions, and link all the objects built into
  65. # the final shared object. The command-line order of objects linked is
  66. # important to make sure the linker correctly preempts versioned symbols
  67. # from the auxiliary shared object and is as follows: ref, lib, dep, def.
  68. # Get a dump to make sure symbol dependencies are resolved internally.
  69. run_ld_link_tests [list \
  70. [list \
  71. "$testname (final shared object)" \
  72. "-shared -Tdata=0x12340000 tmpdir/export-class-ref-r.o tmpdir/export-class-lib.so" "" \
  73. "" \
  74. { export-class-dep.s export-class-def.s } \
  75. { \
  76. { readelf -s export-class.sd } \
  77. { readelf -V export-class.vd } \
  78. } \
  79. "export-class.so" \
  80. ] \
  81. ]