app_flashimg.ld 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #include "hal_config.h"
  13. #ifdef CONFIG_CPU_ARM
  14. OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
  15. OUTPUT_ARCH(arm)
  16. #endif
  17. ENTRY(appimg_enter)
  18. EXTERN(appimg_enter)
  19. EXTERN(appimg_exit)
  20. EXTERN(appimg_get_param)
  21. EXTERN(appimg_set_param)
  22. PROVIDE(appimg_get_param = 0);
  23. PROVIDE(appimg_set_param = 0);
  24. #define ALIGNMENT ALIGN(0x20)
  25. #define HEADER_APP_IMG LONG(0x41505032) \
  26. LONG(0) \
  27. LONG(0) \
  28. KEEP(*(.rodata.core_stub.header))
  29. #define HEADER_LOAD(t, n) LONG(t) \
  30. LONG(__##n##_load_start - __flash_start) \
  31. LONG(__##n##_end - __##n##_start) \
  32. LONG(__##n##_start)
  33. #define HEADER_CLEAR(n) LONG(3) \
  34. LONG(0) \
  35. LONG(__##n##_end - __##n##_start) \
  36. LONG(__##n##_start)
  37. #define HEADER_DUMMY LONG(0) LONG(0) LONG(0) LONG(0)
  38. #define DEF_RO .text .text.* .gnu.linkonce.t.* .rdata .rodata .rodata.* .gnu.linkonce.r.* .glue_7 .glue_7t .vfp11_veneer .v4_bx
  39. #define DEF_RW .data .data.* .gnu.linkonce.d.*
  40. #define DEF_ZI .bss .bss.* COMMON .scommon .sbss .sbss.* .sbss2 .sbss2.* .gnu.linkonce.b.*
  41. #ifdef CONFIG_SOC_8850
  42. #define APPIMG_FLASH_OFFSET 256
  43. #else
  44. #define APPIMG_FLASH_OFFSET 0
  45. #endif
  46. MEMORY {
  47. flash (rx): ORIGIN = CONFIG_APPIMG_FLASH_ADDRESS + APPIMG_FLASH_OFFSET, LENGTH = CONFIG_APPIMG_FLASH_SIZE - APPIMG_FLASH_OFFSET
  48. ram (rwx): ORIGIN = CONFIG_APP_FLASHIMG_RAM_ADDRESS, LENGTH = CONFIG_APP_FLASHIMG_RAM_SIZE
  49. }
  50. SECTIONS {
  51. . = ORIGIN(flash);
  52. __flash_start = .;
  53. .imageheader : {
  54. HEADER_APP_IMG
  55. HEADER_LOAD(2, corestub)
  56. HEADER_LOAD(4, text)
  57. HEADER_LOAD(4, init_array)
  58. HEADER_LOAD(1, data)
  59. HEADER_CLEAR(bss)
  60. HEADER_DUMMY
  61. } > flash
  62. ASSERT(SIZEOF(.imageheader) == 128, "invalid app image header")
  63. . = ORIGIN(ram);
  64. __ram_start = .;
  65. .corestub ALIGNMENT : {
  66. __corestub_start = .;
  67. *(.text.core_stub.*)
  68. __corestub_end = .;
  69. . = ALIGNMENT;
  70. __corestub_load_start = LOADADDR(.corestub);
  71. } AT>flash
  72. .data ALIGNMENT : {
  73. __data_start = .;
  74. *(DEF_RW)
  75. __data_end = .;
  76. . = ALIGNMENT;
  77. __data_load_start = LOADADDR(.data);
  78. } AT>flash
  79. .bss ALIGNMENT : {
  80. __bss_start = .;
  81. *(DEF_ZI)
  82. __bss_end = .;
  83. . = ALIGNMENT;
  84. }
  85. . = LOADADDR(.corestub) + SIZEOF(.corestub) + SIZEOF(.data);
  86. .text ALIGNMENT : {
  87. __text_start = .;
  88. *(DEF_RO)
  89. __text_end = .;
  90. . = ALIGNMENT;
  91. __text_load_start = LOADADDR(.text);
  92. } > flash
  93. .init_array ALIGNMENT : {
  94. __init_array_start = .;
  95. KEEP(*(.init_array*))
  96. __init_array_end = .;
  97. . = ALIGNMENT;
  98. __init_array_load_start = LOADADDR(.init_array);
  99. } > flash
  100. __flash_end = ADDR(.init_array) + SIZEOF(.init_array);
  101. __ram_end = ADDR(.bss) + SIZEOF(.bss);
  102. ASSERT(__flash_end <= ORIGIN(flash) + LENGTH(flash), "FLASH overflow")
  103. ASSERT(__ram_end <= ORIGIN(ram) + LENGTH(ram), "RAM overflow")
  104. .comment 0 : { *(.comment) }
  105. /DISCARD/ : { *(.dynstr*) }
  106. /DISCARD/ : { *(.dynamic*) }
  107. /DISCARD/ : { *(.plt*) }
  108. /DISCARD/ : { *(.interp*) }
  109. /DISCARD/ : { *(.gnu*) }
  110. }