large.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* large.c -- a test case for gold
  2. Copyright (C) 2009-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. #include <assert.h>
  18. /* Test large sections in gold. */
  19. int v1;
  20. int v2 = 1;
  21. int v3[0x10000];
  22. int v4[0x10000] = { 1 };
  23. const int v5[0x10000] = { 2 };
  24. int v6;
  25. int v7 = 1;
  26. int
  27. main (int argc __attribute__ ((unused)), char** argv __attribute ((unused)))
  28. {
  29. assert (v1 == 0);
  30. assert (v2 == 1);
  31. assert (v3[0] == 0 && v3[0xffff] == 0);
  32. assert (v4[0] == 1 && v4[0xffff] == 0);
  33. assert (v5[0] == 2 && v5[0xffff] == 0);
  34. assert (v6 == 0);
  35. assert (v7 == 1);
  36. /* The large symbols must follow the small ones. */
  37. assert (&v1 < v3 && &v1 < v4 && &v1 < v5);
  38. assert (&v2 < v3 && &v2 < v4 && &v2 < v5);
  39. assert (&v6 < v3 && &v6 < v4 && &v6 < v5);
  40. assert (&v7 < v3 && &v7 < v4 && &v7 < v5);
  41. /* Large symbols should be BSS followed by read-only followed by
  42. read-write. */
  43. assert (v3 < v4);
  44. assert (v3 < v5);
  45. assert (v5 < v4);
  46. return 0;
  47. }