vmlinux.lds.S 3.3 KB

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