image.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Linker script macros to generate Image header fields.
  3. *
  4. * Copyright (C) 2014 ARM Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __ASM_IMAGE_H
  19. #define __ASM_IMAGE_H
  20. #ifndef LINKER_SCRIPT
  21. #error This file should only be included in vmlinux.lds.S
  22. #endif
  23. /*
  24. * There aren't any ELF relocations we can use to endian-swap values known only
  25. * at link time (e.g. the subtraction of two symbol addresses), so we must get
  26. * the linker to endian-swap certain values before emitting them.
  27. */
  28. #ifdef CONFIG_CPU_BIG_ENDIAN
  29. #define DATA_LE64(data) \
  30. ((((data) & 0x00000000000000ff) << 56) | \
  31. (((data) & 0x000000000000ff00) << 40) | \
  32. (((data) & 0x0000000000ff0000) << 24) | \
  33. (((data) & 0x00000000ff000000) << 8) | \
  34. (((data) & 0x000000ff00000000) >> 8) | \
  35. (((data) & 0x0000ff0000000000) >> 24) | \
  36. (((data) & 0x00ff000000000000) >> 40) | \
  37. (((data) & 0xff00000000000000) >> 56))
  38. #else
  39. #define DATA_LE64(data) ((data) & 0xffffffffffffffff)
  40. #endif
  41. #ifdef CONFIG_CPU_BIG_ENDIAN
  42. #define __HEAD_FLAG_BE 1
  43. #else
  44. #define __HEAD_FLAG_BE 0
  45. #endif
  46. #define __HEAD_FLAGS (__HEAD_FLAG_BE << 0)
  47. /*
  48. * These will output as part of the Image header, which should be little-endian
  49. * regardless of the endianness of the kernel. While constant values could be
  50. * endian swapped in head.S, all are done here for consistency.
  51. */
  52. #define HEAD_SYMBOLS \
  53. _kernel_size_le = DATA_LE64(_end - _text); \
  54. _kernel_offset_le = DATA_LE64(TEXT_OFFSET); \
  55. _kernel_flags_le = DATA_LE64(__HEAD_FLAGS);
  56. #endif /* __ASM_IMAGE_H */