ELF ld -r scripts
[deliverable/binutils-gdb.git] / ld / scripttempl / elfm68hc12.sc
index 8a4eb44835504de0bea27b62386f816ef06965d7..4690ab664ba4bf01a543f4d5c699240a172e02b2 100644 (file)
@@ -1,6 +1,11 @@
+# Copyright (C) 2014-2018 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
 #
 # Unusual variables checked by this code:
-#      NOP - two byte opcode for no-op (defaults to 0)
+#      NOP - four byte opcode for no-op (defaults to 0)
 #      DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #      OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
 #              (e.g., .PARISC.global)
@@ -13,7 +18,7 @@
 #              .data section.
 #      OTHER_BSS_SYMBOLS - symbols that appear at the start of the
 #              .bss section besides __bss_start.
-#      EMBEDDED - whether this is for an embedded system. 
+#      EMBEDDED - whether this is for an embedded system.
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -24,35 +29,22 @@ test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
 test "$LD_FLAG" = "N" && DATA_ADDR=.
 
-CTOR=".ctors ${CONSTRUCTING-0} : 
+CTOR=".ctors ${CONSTRUCTING-0} :
   {
-    ${CONSTRUCTING+ __CTOR_LIST__ = .; }
+    ${CONSTRUCTING+ PROVIDE (__CTOR_LIST__ = .); }
     ${CONSTRUCTING+${CTOR_START}}
-    *(.ctors)
-    /* We don't want to include the .ctor section from
-       from the crtend.o file until after the sorted ctors.
-       The .ctor section from the crtend file contains the
-       end of ctors marker and it must be last
-
-    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
-    KEEP (*(SORT(.ctors.*)))
-    KEEP (*(.ctors)) */
+    KEEP (*(.ctors))
 
     ${CONSTRUCTING+${CTOR_END}}
-    ${CONSTRUCTING+ __CTOR_END__ = .; }
-  } ${RELOCATING+ > ${DATA_MEMORY}}"
+    ${CONSTRUCTING+ PROVIDE(__CTOR_END__ = .); }
+  } ${RELOCATING+ > ${TEXT_MEMORY}}"
 
 DTOR="  .dtors ${CONSTRUCTING-0} :
   {
-    ${CONSTRUCTING+ __DTOR_LIST__ = .; }
-    *(.dtors)
-    /*
-    KEEP (*crtbegin.o(.dtors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
-    KEEP (*(SORT(.dtors.*)))
-    KEEP (*(.dtors)) */
-    ${CONSTRUCTING+ __DTOR_END__ = .; }
-  } ${RELOCATING+ > ${DATA_MEMORY}}"
+    ${CONSTRUCTING+ PROVIDE(__DTOR_LIST__ = .); }
+    KEEP (*(.dtors))
+    ${CONSTRUCTING+ PROVIDE(__DTOR_END__ = .); }
+  } ${RELOCATING+ > ${TEXT_MEMORY}}"
 
 
 VECTORS="
@@ -65,7 +57,7 @@ VECTORS="
      Bootstrap         0x00c0
      Test              0xbfc0
 
-     In general, the vectors address is 0xffc0.  This can be overriden 
+     In general, the vectors address is 0xffc0.  This can be overriden
      with the '-defsym vectors_addr=0xbfc0' ld option.
 
      Note: for the bootstrap mode, the interrupt vectors are at 0xbfc0 but
@@ -75,7 +67,7 @@ VECTORS="
   PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0xffc0);
   .vectors DEFINED (vectors_addr) ? vectors_addr : 0xffc0 :
   {
-    *(.vectors)
+    KEEP (*(.vectors))
   }"
 
 #
@@ -100,6 +92,7 @@ MEMORY
   page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
   text  (rx)  : ORIGIN = ${ROM_START_ADDR}, LENGTH = ${ROM_SIZE}
   data        : ORIGIN = ${RAM_START_ADDR}, LENGTH = ${RAM_SIZE}
+  eeprom      : ORIGIN = ${EEPROM_START_ADDR}, LENGTH = ${EEPROM_SIZE}
 }
 
 /* Setup the stack on the top of the data memory bank.  */
@@ -110,11 +103,20 @@ esac
 
 STARTUP_CODE="
     /* Startup code.  */
-    *(.install0)       /* Section should setup the stack pointer.  */
-    *(.install1)       /* Place holder for applications.  */
-    *(.install2)       /* Optional installation of data sections in RAM.  */
-    *(.install3)       /* Place holder for applications.  */
-    *(.install4)       /* Section that calls the main.  */
+    KEEP (*(.install0))        /* Section should setup the stack pointer.  */
+    KEEP (*(.install1))        /* Place holder for applications.  */
+    KEEP (*(.install2))        /* Optional installation of data sections in RAM.  */
+    KEEP (*(.install3))        /* Place holder for applications.  */
+    KEEP (*(.install4))        /* Section that calls the main.  */
+"
+
+FINISH_CODE="
+    /* Finish code.  */
+    KEEP (*(.fini0))   /* Beginning of finish code (_exit symbol).  */
+    KEEP (*(.fini1))   /* Place holder for applications.  */
+    KEEP (*(.fini2))   /* C++ destructors.  */
+    KEEP (*(.fini3))   /* Place holder for applications.  */
+    KEEP (*(.fini4))   /* Runtime exit.  */
 "
 
 PRE_COMPUTE_DATA_SIZE="
@@ -137,6 +139,14 @@ INSTALL_RELOC="
   .install4 0 : { *(.install4) }
 "
 
+FINISH_RELOC="
+  .fini0 0 : { *(.fini0) }
+  .fini1 0 : { *(.fini1) }
+  .fini2 0 : { *(.fini2) }
+  .fini3 0 : { *(.fini3) }
+  .fini4 0 : { *(.fini4) }
+"
+
 BSS_DATA_RELOC="
   .data1 0 : { *(.data1) }
 
@@ -148,14 +158,24 @@ BSS_DATA_RELOC="
   .scommon 0 : { *(.scommon) }
 "
 
+SOFT_REGS_RELOC="
+  .softregs 0 : { *(.softregs) }
+"
+
 cat <<EOF
+/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
+
+   Copying and distribution of this script, with or without modification,
+   are permitted in any medium without royalty provided the copyright
+   notice and this notice are preserved.  */
+
 ${RELOCATING+/* Linker script for 68HC12 executable (PROM).  */}
 ${RELOCATING-/* Linker script for 68HC12 object file (ld -r).  */}
 
 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
              "${LITTLE_OUTPUT_FORMAT}")
 OUTPUT_ARCH(${OUTPUT_ARCH})
-ENTRY(${ENTRY})
+${RELOCATING+ENTRY(${ENTRY})}
 
 ${RELOCATING+${LIB_SEARCH_DIRS}}
 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
@@ -170,44 +190,106 @@ SECTIONS
   .gnu.version_d       ${RELOCATING-0} : { *(.gnu.version_d) }
   .gnu.version_r       ${RELOCATING-0} : { *(.gnu.version_r) }
 
-  .rela.text           ${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
-  .rela.data           ${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
-  .rela.rodata         ${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+  .rel.text    ${RELOCATING-0} :
+    {
+      *(.rel.text)
+      ${RELOCATING+*(.rel.text.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
+    }
+  .rela.text   ${RELOCATING-0} :
+    {
+      *(.rela.text)
+      ${RELOCATING+*(.rela.text.*)}
+      ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
+    }
+  .rel.data    ${RELOCATING-0} :
+    {
+      *(.rel.data)
+      ${RELOCATING+*(.rel.data.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
+    }
+  .rela.data   ${RELOCATING-0} :
+    {
+      *(.rela.data)
+      ${RELOCATING+*(.rela.data.*)}
+      ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
+    }
+  .rel.rodata  ${RELOCATING-0} :
+    {
+      *(.rel.rodata)
+      ${RELOCATING+*(.rel.rodata.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
+    }
+  .rela.rodata ${RELOCATING-0} :
+    {
+      *(.rela.rodata)
+      ${RELOCATING+*(.rela.rodata.*)}
+      ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
+    }
+  .rel.sdata   ${RELOCATING-0} :
+    {
+      *(.rel.sdata)
+      ${RELOCATING+*(.rel.sdata.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
+    }
+  .rela.sdata   ${RELOCATING-0} :
+    {
+      *(.rela.sdata)
+      ${RELOCATING+*(.rela.sdata.*)}
+      ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
+    }
+  .rel.sbss    ${RELOCATING-0} :
+    {
+      *(.rel.sbss)
+      ${RELOCATING+*(.rel.sbss.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
+    }
+  .rela.sbss   ${RELOCATING-0} :
+    {
+      *(.rela.sbss)
+      ${RELOCATING+*(.rela.sbss.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
+    }
+  .rel.bss     ${RELOCATING-0} :
+    {
+      *(.rel.bss)
+      ${RELOCATING+*(.rel.bss.*)}
+      ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
+    }
+  .rela.bss    ${RELOCATING-0} :
+    {
+      *(.rela.bss)
+      ${RELOCATING+*(.rela.bss.*)}
+      ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
+    }
+  .rel.stext           ${RELOCATING-0} : { *(.rel.stest) }
   .rela.stext          ${RELOCATING-0} : { *(.rela.stest) }
+  .rel.etext           ${RELOCATING-0} : { *(.rel.etest) }
   .rela.etext          ${RELOCATING-0} : { *(.rela.etest) }
+  .rel.sdata           ${RELOCATING-0} : { *(.rel.sdata) }
   .rela.sdata          ${RELOCATING-0} : { *(.rela.sdata) }
+  .rel.edata           ${RELOCATING-0} : { *(.rel.edata) }
   .rela.edata          ${RELOCATING-0} : { *(.rela.edata) }
+  .rel.eit_v           ${RELOCATING-0} : { *(.rel.eit_v) }
   .rela.eit_v          ${RELOCATING-0} : { *(.rela.eit_v) }
-  .rela.sbss           ${RELOCATING-0} : { *(.rela.sbss) }
-  .rela.ebss           ${RELOCATING-0} : { *(.rela.ebss) }
-  .rela.srodata                ${RELOCATING-0} : { *(.rela.srodata) }
-  .rela.erodata                ${RELOCATING-0} : { *(.rela.erodata) }
-  .rela.got            ${RELOCATING-0} : { *(.rela.got) }
-  .rela.ctors          ${RELOCATING-0} : { *(.rela.ctors) }
-  .rela.dtors          ${RELOCATING-0} : { *(.rela.dtors) }
-  .rela.init           ${RELOCATING-0} : { *(.rela.init) }
-  .rela.fini           ${RELOCATING-0} : { *(.rela.fini) }
-  .rela.bss            ${RELOCATING-0} : { *(.rela.bss) }
-  .rela.plt            ${RELOCATING-0} : { *(.rela.plt) }
-
-  .rel.data            ${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
-  .rel.rodata          ${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
-  .rel.stext           ${RELOCATING-0} : { *(.rel.stest) }
-  .rel.etext           ${RELOCATING-0} : { *(.rel.etest) }
-  .rel.sdata           ${RELOCATING-0} : { *(.rel.sdata) }
-  .rel.edata           ${RELOCATING-0} : { *(.rel.edata) }
-  .rel.sbss            ${RELOCATING-0} : { *(.rel.sbss) }
   .rel.ebss            ${RELOCATING-0} : { *(.rel.ebss) }
-  .rel.eit_v           ${RELOCATING-0} : { *(.rel.eit_v) }
+  .rela.ebss           ${RELOCATING-0} : { *(.rela.ebss) }
   .rel.srodata         ${RELOCATING-0} : { *(.rel.srodata) }
+  .rela.srodata                ${RELOCATING-0} : { *(.rela.srodata) }
   .rel.erodata         ${RELOCATING-0} : { *(.rel.erodata) }
+  .rela.erodata                ${RELOCATING-0} : { *(.rela.erodata) }
   .rel.got             ${RELOCATING-0} : { *(.rel.got) }
+  .rela.got            ${RELOCATING-0} : { *(.rela.got) }
   .rel.ctors           ${RELOCATING-0} : { *(.rel.ctors) }
+  .rela.ctors          ${RELOCATING-0} : { *(.rela.ctors) }
   .rel.dtors           ${RELOCATING-0} : { *(.rel.dtors) }
+  .rela.dtors          ${RELOCATING-0} : { *(.rela.dtors) }
   .rel.init            ${RELOCATING-0} : { *(.rel.init) }
+  .rela.init           ${RELOCATING-0} : { *(.rela.init) }
   .rel.fini            ${RELOCATING-0} : { *(.rel.fini) }
-  .rel.bss             ${RELOCATING-0} : { *(.rel.bss) }
+  .rela.fini           ${RELOCATING-0} : { *(.rela.fini) }
   .rel.plt             ${RELOCATING-0} : { *(.rel.plt) }
+  .rela.plt            ${RELOCATING-0} : { *(.rela.plt) }
 
   /* Concatenate .page0 sections.  Put them in the page0 memory bank
      unless we are creating a relocatable file.  */
@@ -217,17 +299,18 @@ SECTIONS
   } ${RELOCATING+ > page0}
 
   /* Start of text section.  */
-  .stext ${RELOCATING-0} : 
+  .stext ${RELOCATING-0} :
   {
     *(.stext)
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 
   .init        ${RELOCATING-0} :
   {
-    *(.init) 
+    *(.init)
   } ${RELOCATING+=${NOP-0}}
 
   ${RELOCATING-${INSTALL_RELOC}}
+  ${RELOCATING-${FINISH_RELOC}}
 
   .text ${RELOCATING-0}:
   {
@@ -236,30 +319,51 @@ SECTIONS
 
     ${RELOCATING+*(.init)}
     *(.text)
-    *(.fini)
+    ${RELOCATING+*(.text.*)}
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
-    *(.gnu.linkonce.t*)
+    ${RELOCATING+*(.gnu.linkonce.t.*)}
+    ${RELOCATING+*(.tramp)}
+    ${RELOCATING+*(.tramp.*)}
+
+    ${RELOCATING+${FINISH_CODE}}
 
     ${RELOCATING+_etext = .;}
     ${RELOCATING+PROVIDE (etext = .);}
+    ${RELOCATING+. = ALIGN(2);}
+  } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7}
 
+  .eh_frame ${RELOCATING-0} :
+  {
+    KEEP (*(.eh_frame))
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 
-  .eh_frame ${RELOCATING-0} :
+  .gcc_except_table ${RELOCATING-0} :
   {
-    *(.eh_frame)
+    *(.gcc_except_table)
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 
   .rodata  ${RELOCATING-0} :
   {
     *(.rodata)
-    *(.gnu.linkonce.r*)
-  } ${RELOCATING+ > ${TEXT_MEMORY}}
+    ${RELOCATING+*(.rodata.*)}
+    ${RELOCATING+*(.gnu.linkonce.r*)}
+    ${RELOCATING+. = ALIGN(2);}
+  } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
 
   .rodata1 ${RELOCATING-0} :
   {
     *(.rodata1)
+    ${RELOCATING+. = ALIGN(2);}
+  } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
+
+  /* Constructor and destructor tables are in ROM.  */
+  ${RELOCATING+${CTOR}}
+  ${RELOCATING+${DTOR}}
+
+  .jcr ${RELOCATING-0} :
+  {
+    KEEP (*(.jcr))
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 
   /* Start of the data section image in ROM.  */
@@ -278,13 +382,15 @@ SECTIONS
     ${RELOCATING+${DATA_START_SYMBOLS}}
     ${RELOCATING+*(.sdata)}
     *(.data)
+    ${RELOCATING+*(.data.*)}
     ${RELOCATING+*(.data1)}
-    *(.gnu.linkonce.d*)
+    ${RELOCATING+*(.gnu.linkonce.d.*)}
     ${CONSTRUCTING+CONSTRUCTORS}
 
     ${RELOCATING+_edata  =  .;}
     ${RELOCATING+PROVIDE (edata = .);}
-  } ${RELOCATING+ > ${DATA_MEMORY}}
+    ${RELOCATING+. = ALIGN(2);}
+  } ${RELOCATING+ > ${DATA_MEMORY} =0xffffffff}
 
   ${RELOCATING+__data_section_size = SIZEOF(.data);}
   ${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
@@ -299,21 +405,29 @@ SECTIONS
 
   /* Relocation for some bss and data sections.  */
   ${RELOCATING-${BSS_DATA_RELOC}}
+  ${RELOCATING-${SOFT_REGS_RELOC}}
 
   .bss ${RELOCATING-0} :
   {
     ${RELOCATING+__bss_start = .;}
+    ${RELOCATING+*(.softregs)}
     ${RELOCATING+*(.sbss)}
     ${RELOCATING+*(.scommon)}
-
-    *(.dynbss)
+    ${RELOCATING+*(.dynbss)}
     *(.bss)
-    *(COMMON)
+    ${RELOCATING+*(.bss.*)}
+    ${RELOCATING+*(.gnu.linkonce.b.*)}
+    ${RELOCATING+*(COMMON)}
     ${RELOCATING+PROVIDE (_end = .);}
   } ${RELOCATING+ > ${DATA_MEMORY}}
+  ${RELOCATING+__bss_size = SIZEOF(.bss);}
+  ${RELOCATING+PROVIDE (__bss_size = SIZEOF(.bss));}
 
-  ${RELOCATING+${CTOR}}
-  ${RELOCATING+${DTOR}}
+  .eeprom ${RELOCATING-0} :
+  {
+    *(.eeprom)
+    ${RELOCATING+*(.eeprom.*)}
+  } ${RELOCATING+ > ${EEPROM_MEMORY}}
 
   ${RELOCATING+${VECTORS}}
 
@@ -327,33 +441,14 @@ SECTIONS
 
   .comment      0 : { *(.comment) }
 
-  /* DWARF debug sections.
-     Symbols in the DWARF debugging sections are relative to the beginning
-     of the section so we begin them at 0.
-     Treatment of DWARF debug section must be at end of the linker
+  /* Treatment of DWARF debug section must be at end of the linker
      script to avoid problems when there are undefined symbols. It's necessary
      to avoid that the DWARF section is relocated before such undefined
      symbols are found.  */
+EOF
+
+. $srcdir/scripttempl/DWARF.sc
 
-  /* DWARF 1 */
-  .debug        0 : { *(.debug) }
-  .line                 0 : { *(.line) }
-
-  /* GNU DWARF 1 extensions */
-  .debug_srcinfo 0 : { *(.debug_srcinfo) }
-  .debug_sfnames 0 : { *(.debug_sfnames) }
-
-  /* DWARF 1.1 and DWARF 2 */
-  .debug_aranges  0 : { *(.debug_aranges) }
-  .debug_pubnames 0 : { *(.debug_pubnames) }
-
-  /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info) }
-  .debug_abbrev   0 : { *(.debug_abbrev) }
-  .debug_line     0 : { *(.debug_line) }
-  .debug_frame    0 : { *(.debug_frame) }
-  .debug_str      0 : { *(.debug_str) }
-  .debug_loc      0 : { *(.debug_loc) }
-  .debug_macinfo  0 : { *(.debug_macinfo) }
+cat <<EOF
 }
 EOF
This page took 0.029305 seconds and 4 git commands to generate.