(root)/
binutils-2.41/
ld/
testsuite/
ld-elfvers/
vers1.c
       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  
       8  const char * show_bar1 = "asdf";
       9  const char * show_bar2 = "asdf";
      10  
      11  extern int new2_foo();
      12  extern int bar33();
      13  
      14  int
      15  bar()
      16  {
      17  	return 3;
      18  }
      19  
      20  /*
      21   * The 'hide' prefix is something so that we can automatically search the
      22   * symbol table and verify that none of these symbols were actually exported.
      23   */
      24  int
      25  hide_original_foo()
      26  {
      27  	return 1+bar();
      28  
      29  }
      30  
      31  int
      32  hide_old_foo()
      33  {
      34  	return 10+bar();
      35  
      36  }
      37  
      38  int
      39  hide_old_foo1()
      40  {
      41  	return 100+bar();
      42  
      43  }
      44  
      45  int
      46  hide_new_foo()
      47  {
      48  	return 1000+bar();
      49  
      50  }
      51  
      52  FUNC_SYMVER(hide_original_foo, show_foo@);
      53  FUNC_SYMVER(hide_old_foo, show_foo@VERS_1.1);
      54  FUNC_SYMVER(hide_old_foo1, show_foo@VERS_1.2);
      55  FUNC_SYMVER(hide_new_foo, show_foo@@VERS_2.0);
      56  
      57  
      58  
      59  #ifdef DO_TEST10
      60  /* In test 10, we try and define a non-existant version node.  The linker
      61   * should catch this and complain. */
      62  int
      63  hide_new_bogus_foo()
      64  {
      65  	return 1000+bar();
      66  
      67  }
      68  FUNC_SYMVER(hide_new_bogus_foo, show_foo@VERS_2.2);
      69  #endif
      70  
      71  
      72  
      73  
      74  #ifdef DO_TEST11
      75  /*
      76   * This test is designed to catch a couple of syntactic errors.  The assembler
      77   * should complain about both of the directives below.
      78   */
      79  void
      80  xyzzz()
      81  {
      82    new2_foo();
      83    bar33();
      84  }
      85  
      86  FUNC_SYMVER(new2_foo, fooVERS_2.0);
      87  FUNC_SYMVER(bar33, bar@@VERS_2.0);
      88  #endif
      89  
      90  #ifdef DO_TEST12
      91  /*
      92   * This test is designed to catch a couple of syntactic errors.  The assembler
      93   * should complain about both of the directives below.
      94   */
      95  void
      96  xyzzz()
      97  {
      98    new2_foo();
      99    bar33();
     100  }
     101  
     102  FUNC_SYMVER(bar33, bar@@VERS_2.0);
     103  #endif