app2_fileimg.ld 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. MEMORY {
  42. ram (rwx): ORIGIN = CONFIG_APP2_FILEIMG_RAM_ADDRESS, LENGTH = CONFIG_APP2_FILEIMG_RAM_SIZE
  43. }
  44. SECTIONS {
  45. . = ORIGIN(ram);
  46. __flash_start = .;
  47. __ram_start = .;
  48. .imageheader : {
  49. HEADER_APP_IMG
  50. HEADER_LOAD(2, corestub)
  51. HEADER_LOAD(1, text)
  52. HEADER_LOAD(1, init_array)
  53. HEADER_LOAD(1, data)
  54. HEADER_CLEAR(bss)
  55. HEADER_DUMMY
  56. } > ram
  57. ASSERT(SIZEOF(.imageheader) == 128, "invalid app image header")
  58. .corestub ALIGNMENT : {
  59. __corestub_start = .;
  60. *(.text.core_stub.*)
  61. __corestub_end = .;
  62. . = ALIGNMENT;
  63. __corestub_load_start = LOADADDR(.corestub);
  64. } > ram
  65. .text ALIGNMENT : {
  66. __text_start = .;
  67. *(DEF_RO)
  68. __text_end = .;
  69. . = ALIGNMENT;
  70. __text_load_start = LOADADDR(.text);
  71. } > ram
  72. .init_array ALIGNMENT : {
  73. __init_array_start = .;
  74. KEEP(*(.init_array*))
  75. __init_array_end = .;
  76. . = ALIGNMENT;
  77. __init_array_load_start = LOADADDR(.init_array);
  78. } > ram
  79. .data ALIGNMENT : {
  80. __data_start = .;
  81. *(DEF_RW)
  82. __data_end = .;
  83. . = ALIGNMENT;
  84. __data_load_start = LOADADDR(.data);
  85. } > ram
  86. .bss ALIGNMENT : {
  87. __bss_start = .;
  88. *(DEF_ZI)
  89. __bss_end = .;
  90. . = ALIGNMENT;
  91. }
  92. __flash_end = ADDR(.data) + SIZEOF(.data);
  93. __ram_end = ADDR(.bss) + SIZEOF(.bss);
  94. ASSERT(__ram_end <= ORIGIN(ram) + LENGTH(ram), "RAM overflow")
  95. .comment 0 : { *(.comment) }
  96. /DISCARD/ : { *(.dynstr*) }
  97. /DISCARD/ : { *(.dynamic*) }
  98. /DISCARD/ : { *(.plt*) }
  99. /DISCARD/ : { *(.interp*) }
  100. /DISCARD/ : { *(.gnu*) }
  101. }