plugin_layout_with_alignment.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // plugin_layout_with_alignment.cc -- a test case for gold
  2. // Copyright (C) 2016-2022 Free Software Foundation, Inc.
  3. // Written by Than McIntosh <thanm@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. // Verify that plugin interfaces for section size and alignment work
  18. // correctly, and that section ordering via plugins is working
  19. // for .bss/.rodata/.data sections.
  20. // --- Initialized .rodata items
  21. __attribute__ ((section(".rodata.v1_a2"), aligned(2)))
  22. const short rodata_item1 = 101;
  23. __attribute__ ((section(".rodata.v2_a1"), aligned(1)))
  24. const char rodata_item2 = 'a';
  25. __attribute__ ((section(".rodata.v3_a8"), aligned(8)))
  26. const double rodata_item3 = 777.777;
  27. __attribute__ ((section(".rodata.v4_a1"), aligned(1)))
  28. const char rodata_item4[7] = {'1', '2', '3', '4', '5', '6', '7'};
  29. // --- Initialized .data items
  30. __attribute__ ((section(".data.v1_a2"), aligned(2)))
  31. short rwdata_item1 = 101;
  32. __attribute__ ((section(".data.v2_a1"), aligned(1)))
  33. char rwdata_item2 = 'a';
  34. __attribute__ ((section(".data.v3_a8"), aligned(8)))
  35. double rwdata_item3 = 'b';
  36. __attribute__ ((section(".data.v4_a1"), aligned(1)))
  37. char rwdata_item4[3] = {'a', 'b', 'c'};
  38. // --- Uninitialized .data items
  39. __attribute__ ((section(".bss.v1_a2"), aligned(2)))
  40. short bss_item1;
  41. __attribute__ ((section(".bss.v2_a1"), aligned(1)))
  42. char bss_item2;
  43. __attribute__ ((section(".bss.v3_a8"), aligned(8)))
  44. struct blah { union { double d; char c; } u; } bss_item3;
  45. __attribute__ ((section(".bss.v4_a1"), aligned(1)))
  46. char bss_item4[3];
  47. int main (void)
  48. {
  49. return 0;
  50. }