sections.c 1.2 KB

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. /**
  7. * These two symbols are declared in a C file so that the linker
  8. * uses R_ARM_RELATIVE relocation, rather than the R_ARM_ABS32 one
  9. * it would use if the symbols were defined in the linker file.
  10. * Using only R_ARM_RELATIVE relocation ensures that references to
  11. * the symbols are correct after as well as before relocation.
  12. *
  13. * We need a 0-byte-size type for these symbols, and the compiler
  14. * does not allow defining objects of C type 'void'. Using an empty
  15. * struct is allowed by the compiler, but causes gcc versions 4.4 and
  16. * below to complain about aliasing. Therefore we use the next best
  17. * thing: zero-sized arrays, which are both 0-byte-size and exempt from
  18. * aliasing warnings.
  19. */
  20. char __bss_start[0] __attribute__((section(".__bss_start")));
  21. char __bss_end[0] __attribute__((section(".__bss_end")));
  22. char __image_copy_start[0] __attribute__((section(".__image_copy_start")));
  23. char __image_copy_end[0] __attribute__((section(".__image_copy_end")));
  24. char __rel_dyn_start[0] __attribute__((section(".__rel_dyn_start")));
  25. char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end")));
  26. char _end[0] __attribute__((section(".__end")));