vmlinux.lds.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2000 Russell King
  4. */
  5. #include <asm/vmlinux.lds.h>
  6. #ifdef CONFIG_CPU_ENDIAN_BE8
  7. #define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
  8. (((x) >> 8) & 0x0000ff00) | \
  9. (((x) << 8) & 0x00ff0000) | \
  10. (((x) << 24) & 0xff000000) )
  11. #else
  12. #define ZIMAGE_MAGIC(x) (x)
  13. #endif
  14. OUTPUT_ARCH(arm)
  15. ENTRY(_start)
  16. SECTIONS
  17. {
  18. /DISCARD/ : {
  19. COMMON_DISCARDS
  20. *(.ARM.exidx*)
  21. *(.ARM.extab*)
  22. *(.modinfo)
  23. *(.note.*)
  24. *(.rel.*)
  25. *(.printk_index)
  26. /*
  27. * Discard any r/w data - this produces a link error if we have any,
  28. * which is required for PIC decompression. Local data generates
  29. * GOTOFF relocations, which prevents it being relocated independently
  30. * of the text/got segments.
  31. */
  32. *(.data)
  33. }
  34. . = TEXT_START;
  35. _text = .;
  36. .text : {
  37. _start = .;
  38. *(.start)
  39. *(.text)
  40. *(.text.*)
  41. ARM_STUBS_TEXT
  42. }
  43. .table : ALIGN(4) {
  44. _table_start = .;
  45. LONG(ZIMAGE_MAGIC(6))
  46. LONG(ZIMAGE_MAGIC(0x5a534c4b))
  47. LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
  48. LONG(ZIMAGE_MAGIC(_kernel_bss_size))
  49. LONG(ZIMAGE_MAGIC(TEXT_OFFSET))
  50. LONG(ZIMAGE_MAGIC(MALLOC_SIZE))
  51. LONG(0)
  52. _table_end = .;
  53. }
  54. .rodata : {
  55. *(.rodata)
  56. *(.rodata.*)
  57. *(.data.rel.ro)
  58. *(.data.rel.ro.*)
  59. }
  60. .piggydata : {
  61. *(.piggydata)
  62. __piggy_size_addr = . - 4;
  63. }
  64. . = ALIGN(4);
  65. _etext = .;
  66. .got.plt : { *(.got.plt) }
  67. #ifndef CONFIG_EFI_STUB
  68. _got_start = .;
  69. .got : { *(.got) }
  70. _got_end = .;
  71. #endif
  72. /* ensure the zImage file size is always a multiple of 64 bits */
  73. /* (without a dummy byte, ld just ignores the empty section) */
  74. .pad : { BYTE(0); . = ALIGN(8); }
  75. #ifdef CONFIG_EFI_STUB
  76. .data : ALIGN(4096) {
  77. __pecoff_data_start = .;
  78. _got_start = .;
  79. *(.got)
  80. _got_end = .;
  81. /*
  82. * The EFI stub always executes from RAM, and runs strictly before the
  83. * decompressor, so we can make an exception for its r/w data, and keep it
  84. */
  85. *(.data.efistub .bss.efistub)
  86. __pecoff_data_end = .;
  87. /*
  88. * PE/COFF mandates a file size which is a multiple of 512 bytes if the
  89. * section size equals or exceeds 4 KB
  90. */
  91. . = ALIGN(512);
  92. }
  93. __pecoff_data_rawsize = . - ADDR(.data);
  94. #endif
  95. _edata = .;
  96. /*
  97. * The image_end section appears after any additional loadable sections
  98. * that the linker may decide to insert in the binary image. Having
  99. * this symbol allows further debug in the near future.
  100. */
  101. .image_end (NOLOAD) : {
  102. /*
  103. * EFI requires that the image is aligned to 512 bytes, and appended
  104. * DTB requires that we know where the end of the image is. Ensure
  105. * that both are satisfied by ensuring that there are no additional
  106. * sections emitted into the decompressor image.
  107. */
  108. _edata_real = .;
  109. }
  110. _magic_sig = ZIMAGE_MAGIC(0x016f2818);
  111. _magic_start = ZIMAGE_MAGIC(_start);
  112. _magic_end = ZIMAGE_MAGIC(_edata);
  113. _magic_table = ZIMAGE_MAGIC(_table_start - _start);
  114. . = BSS_START;
  115. __bss_start = .;
  116. .bss : { *(.bss .bss.*) }
  117. _end = .;
  118. . = ALIGN(8); /* the stack must be 64-bit aligned */
  119. .stack : { *(.stack) }
  120. PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
  121. PROVIDE(__pecoff_end = ALIGN(512));
  122. STABS_DEBUG
  123. DWARF_DEBUG
  124. ARM_DETAILS
  125. ARM_ASSERTS
  126. }
  127. ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");