common_test_1.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* common_test_1.c -- test common symbol sorting
  2. Copyright (C) 2008-2022 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor <iant@google.com>
  4. This file is part of gold.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA.
  17. This is a test of a common symbol in the main program and a
  18. versioned symbol in a shared library. The common symbol in the
  19. main program should override the shared library symbol. */
  20. #include <assert.h>
  21. /* Common symbols should be sorted by size, largest first, and then by
  22. alignment, largest first. We mix up the names, because gas seems
  23. to sort common symbols roughly by name. */
  24. int c9[90];
  25. int c8[80];
  26. int c7[70];
  27. int c6[60];
  28. int c5[10];
  29. int c4[20];
  30. int c3[30];
  31. int c2[40];
  32. int c1[50];
  33. int a1 __attribute__ ((aligned (1 << 9)));
  34. int a2 __attribute__ ((aligned (1 << 8)));
  35. int a3 __attribute__ ((aligned (1 << 7)));
  36. int a4 __attribute__ ((aligned (1 << 6)));
  37. int a5 __attribute__ ((aligned (1 << 1)));
  38. int a6 __attribute__ ((aligned (1 << 2)));
  39. int a7 __attribute__ ((aligned (1 << 3)));
  40. int a8 __attribute__ ((aligned (1 << 4)));
  41. int a9 __attribute__ ((aligned (1 << 5)));
  42. int
  43. main (int argc __attribute__ ((unused)), char** argv __attribute__ ((unused)))
  44. {
  45. assert (&c5[0] > &c4[0]);
  46. assert (&c4[0] > &c3[0]);
  47. assert (&c3[0] > &c2[0]);
  48. assert (&c2[0] > &c1[0]);
  49. assert (&c1[0] > &c6[0]);
  50. assert (&c6[0] > &c7[0]);
  51. assert (&c7[0] > &c8[0]);
  52. assert (&c8[0] > &c9[0]);
  53. assert (&a1 < &a2);
  54. assert (&a2 < &a3);
  55. assert (&a3 < &a4);
  56. assert (&a4 < &a9);
  57. assert (&a9 < &a8);
  58. assert (&a8 < &a7);
  59. assert (&a7 < &a6);
  60. assert (&a6 < &a5);
  61. return 0;
  62. }