vers1.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Basic test of versioning. The idea with this is that we define
  3. * a bunch of definitions of the same symbol, and we can theoretically
  4. * then link applications against varying sets of these.
  5. */
  6. #include "vers.h"
  7. const char * show_bar1 = "asdf";
  8. const char * show_bar2 = "asdf";
  9. extern int new2_foo();
  10. extern int bar33();
  11. int
  12. bar()
  13. {
  14. return 3;
  15. }
  16. /*
  17. * The 'hide' prefix is something so that we can automatically search the
  18. * symbol table and verify that none of these symbols were actually exported.
  19. */
  20. int
  21. hide_original_foo()
  22. {
  23. return 1+bar();
  24. }
  25. int
  26. hide_old_foo()
  27. {
  28. return 10+bar();
  29. }
  30. int
  31. hide_old_foo1()
  32. {
  33. return 100+bar();
  34. }
  35. int
  36. hide_new_foo()
  37. {
  38. return 1000+bar();
  39. }
  40. FUNC_SYMVER(hide_original_foo, show_foo@);
  41. FUNC_SYMVER(hide_old_foo, show_foo@VERS_1.1);
  42. FUNC_SYMVER(hide_old_foo1, show_foo@VERS_1.2);
  43. FUNC_SYMVER(hide_new_foo, show_foo@@VERS_2.0);
  44. #ifdef DO_TEST10
  45. /* In test 10, we try and define a non-existant version node. The linker
  46. * should catch this and complain. */
  47. int
  48. hide_new_bogus_foo()
  49. {
  50. return 1000+bar();
  51. }
  52. FUNC_SYMVER(hide_new_bogus_foo, show_foo@VERS_2.2);
  53. #endif
  54. #ifdef DO_TEST11
  55. /*
  56. * This test is designed to catch a couple of syntactic errors. The assembler
  57. * should complain about both of the directives below.
  58. */
  59. void
  60. xyzzz()
  61. {
  62. new2_foo();
  63. bar33();
  64. }
  65. FUNC_SYMVER(new2_foo, fooVERS_2.0);
  66. FUNC_SYMVER(bar33, bar@@VERS_2.0);
  67. #endif
  68. #ifdef DO_TEST12
  69. /*
  70. * This test is designed to catch a couple of syntactic errors. The assembler
  71. * should complain about both of the directives below.
  72. */
  73. void
  74. xyzzz()
  75. {
  76. new2_foo();
  77. bar33();
  78. }
  79. FUNC_SYMVER(bar33, bar@@VERS_2.0);
  80. #endif