common_test_1.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* common_test_1.c -- test common symbol sorting
  2. Copyright (C) 2008-2015 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 > c4);
  46. assert (c4 > c3);
  47. assert (c3 > c2);
  48. assert (c2 > c1);
  49. assert (c1 > c6);
  50. assert (c6 > c7);
  51. assert (c7 > c8);
  52. assert (c8 > c9);
  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. }