elfd10v.sc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # Copyright (C) 2014-2022 Free Software Foundation, Inc.
  2. #
  3. # Copying and distribution of this file, with or without modification,
  4. # are permitted in any medium without royalty provided the copyright
  5. # notice and this notice are preserved.
  6. test -z "$ENTRY" && ENTRY=_start
  7. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  8. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  9. if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
  10. test "$LD_FLAG" = "N" && DATA_ADDR=.
  11. INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
  12. PLT=".plt ${RELOCATING-0} : { *(.plt) }"
  13. CTOR=".ctors ${CONSTRUCTING-0} :
  14. {
  15. ${CONSTRUCTING+${CTOR_START}}
  16. /* gcc uses crtbegin.o to find the start of
  17. the constructors, so we make sure it is
  18. first. Because this is a wildcard, it
  19. doesn't matter if the user does not
  20. actually link against crtbegin.o; the
  21. linker won't look for a file to match a
  22. wildcard. The wildcard also means that it
  23. doesn't matter which directory crtbegin.o
  24. is in. */
  25. KEEP (*crtbegin.o(.ctors))
  26. KEEP (*crtbegin?.o(.ctors))
  27. /* We don't want to include the .ctor section from
  28. the crtend.o file until after the sorted ctors.
  29. The .ctor section from the crtend file contains the
  30. end of ctors marker and it must be last */
  31. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))
  32. KEEP (*(SORT(.ctors.*)))
  33. KEEP (*(.ctors))
  34. ${CONSTRUCTING+${CTOR_END}}
  35. }"
  36. DTOR=" .dtors ${CONSTRUCTING-0} :
  37. {
  38. ${CONSTRUCTING+${DTOR_START}}
  39. KEEP (*crtbegin.o(.dtors))
  40. KEEP (*crtbegin?.o(.dtors))
  41. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))
  42. KEEP (*(SORT(.dtors.*)))
  43. KEEP (*(.dtors))
  44. ${CONSTRUCTING+${DTOR_END}}
  45. }"
  46. STACK=" .stack : { _stack = .; *(.stack) } >STACK "
  47. # if this is for an embedded system, don't add SIZEOF_HEADERS.
  48. if [ -z "$EMBEDDED" ]; then
  49. test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR} + SIZEOF_HEADERS"
  50. else
  51. test -z "${READONLY_BASE_ADDRESS}" && READONLY_BASE_ADDRESS="${READONLY_START_ADDR}"
  52. fi
  53. cat <<EOF
  54. /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
  55. Copying and distribution of this script, with or without modification,
  56. are permitted in any medium without royalty provided the copyright
  57. notice and this notice are preserved. */
  58. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  59. "${LITTLE_OUTPUT_FORMAT}")
  60. OUTPUT_ARCH(${OUTPUT_ARCH})
  61. EOF
  62. test -n "${RELOCATING}" && cat <<EOF
  63. ENTRY(${ENTRY})
  64. ${LIB_SEARCH_DIRS}
  65. /* Do we need any of these for elf?
  66. __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */
  67. ${EXECUTABLE_SYMBOLS}
  68. MEMORY
  69. {
  70. /* These are the values for the D10V-TS3 board.
  71. There are other memory regions available on
  72. the TS3 (eg ROM, FLASH, etc) but these are not
  73. used by this script. */
  74. INSN : org = 0x01000000, len = 256K
  75. DATA : org = 0x02000000, len = 48K
  76. /* This is a fake memory region at the top of the
  77. on-chip RAM, used as the start of the
  78. (descending) stack. */
  79. STACK : org = 0x0200BFFC, len = 4
  80. }
  81. EOF
  82. cat <<EOF
  83. SECTIONS
  84. {
  85. .text ${RELOCATING+${TEXT_START_ADDR}} :
  86. {
  87. ${RELOCATING+${TEXT_START_SYMBOLS}
  88. KEEP (*(SORT_NONE(.init)))
  89. KEEP (*(SORT_NONE(.init.*)))
  90. KEEP (*(SORT_NONE(.fini)))
  91. KEEP (*(SORT_NONE(.fini.*)))}
  92. *(.text)
  93. ${RELOCATING+*(.text.*)}
  94. /* .gnu.warning sections are handled specially by elf.em. */
  95. *(.gnu.warning)
  96. ${RELOCATING+*(.gnu.linkonce.t*)
  97. _etext = .;
  98. PROVIDE (etext = .);}
  99. } ${RELOCATING+ >INSN} =${NOP-0}
  100. .rodata ${RELOCATING+${READONLY_START_ADDR}} : {
  101. *(.rodata)
  102. ${RELOCATING+*(.gnu.linkonce.r*)
  103. *(.rodata.*)}
  104. } ${RELOCATING+ >DATA}
  105. .rodata1 ${RELOCATING-0} : {
  106. *(.rodata1)
  107. ${RELOCATING+*(.rodata1.*)}
  108. } ${RELOCATING+ >DATA}
  109. .data ${RELOCATING-0} :
  110. {
  111. ${RELOCATING+${DATA_START_SYMBOLS}}
  112. *(.data)
  113. ${RELOCATING+*(.data.*)
  114. *(.gnu.linkonce.d*)}
  115. ${CONSTRUCTING+CONSTRUCTORS}
  116. } ${RELOCATING+ >DATA}
  117. .data1 ${RELOCATING-0} : {
  118. *(.data1)
  119. ${RELOCATING+*(.data1.*)}
  120. } ${RELOCATING+ >DATA}
  121. ${RELOCATING+${CTOR} >DATA}
  122. ${RELOCATING+${DTOR} >DATA}
  123. /* We want the small data sections together, so single-instruction offsets
  124. can access them all, and initialized data all before uninitialized, so
  125. we can shorten the on-disk segment size. */
  126. .sdata ${RELOCATING-0} : {
  127. *(.sdata)
  128. ${RELOCATING+*(.sdata.*)}
  129. } ${RELOCATING+ >DATA}
  130. ${RELOCATING+_edata = .;}
  131. ${RELOCATING+PROVIDE (edata = .);}
  132. ${RELOCATING+__bss_start = .;}
  133. .sbss ${RELOCATING-0} : { *(.sbss)${RELOCATING+ *(.scommon)} } ${RELOCATING+ >DATA}
  134. .bss ${RELOCATING-0} :
  135. {
  136. ${RELOCATING+*(.dynbss)
  137. *(.dynbss.*)}
  138. *(.bss)
  139. ${RELOCATING+*(.bss.*)
  140. *(COMMON)}
  141. } ${RELOCATING+ >DATA}
  142. ${RELOCATING+_end = . ;}
  143. ${RELOCATING+PROVIDE (end = .);}
  144. ${RELOCATING+$STACK}
  145. /* Stabs debugging sections. */
  146. .stab 0 : { *(.stab) }
  147. .stabstr 0 : { *(.stabstr) }
  148. .stab.excl 0 : { *(.stab.excl) }
  149. .stab.exclstr 0 : { *(.stab.exclstr) }
  150. .stab.index 0 : { *(.stab.index) }
  151. .stab.indexstr 0 : { *(.stab.indexstr) }
  152. .comment 0 : { *(.comment) }
  153. EOF
  154. . $srcdir/scripttempl/DWARF.sc
  155. cat <<EOF
  156. }
  157. EOF