summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/ld/scripttempl/elf.sc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/binutils/ld/scripttempl/elf.sc')
-rw-r--r--contrib/binutils/ld/scripttempl/elf.sc125
1 files changed, 102 insertions, 23 deletions
diff --git a/contrib/binutils/ld/scripttempl/elf.sc b/contrib/binutils/ld/scripttempl/elf.sc
index 6c4741b..3c1bfb4 100644
--- a/contrib/binutils/ld/scripttempl/elf.sc
+++ b/contrib/binutils/ld/scripttempl/elf.sc
@@ -21,6 +21,7 @@
# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
# .bss section besides __bss_start.
# DATA_PLT - .plt should be in data segment, not text segment.
+# BSS_PLT - .plt should be in bss segment
# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
# EMBEDDED - whether this is for an embedded system.
# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
@@ -36,6 +37,26 @@
# when specifying the start address of the next.
#
+# Many sections come in three flavours. There is the 'real' section,
+# like ".data". Then there are the per-procedure or per-variable
+# sections, generated by -ffunction-sections and -fdata-sections in GCC,
+# and useful for --gc-sections, which for a variable "foo" might be
+# ".data.foo". Then there are the linkonce sections, for which the linker
+# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
+# The exact correspondences are:
+#
+# Section Linkonce section
+# .text .gnu.linkonce.t.foo
+# .rodata .gnu.linkonce.r.foo
+# .data .gnu.linkonce.d.foo
+# .bss .gnu.linkonce.b.foo
+# .sdata .gnu.linkonce.s.foo
+# .sbss .gnu.linkonce.sb.foo
+# .sdata2 .gnu.linkonce.s2.foo
+# .sbss2 .gnu.linkonce.sb2.foo
+#
+# Each of these can also have corresponding .rel.* and .rela.* sections.
+
test -z "$ENTRY" && ENTRY=_start
test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
@@ -46,7 +67,9 @@ test "$LD_FLAG" = "N" && DATA_ADDR=.
INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
PLT=".plt ${RELOCATING-0} : { *(.plt) }"
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
-RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r*)} }"
+RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
+SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
+SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"
CTOR=".ctors ${CONSTRUCTING-0} :
{
${CONSTRUCTING+${CTOR_START}}
@@ -127,13 +150,13 @@ SECTIONS
{
*(.rel.text)
${RELOCATING+*(.rel.text.*)}
- ${RELOCATING+*(.rel.gnu.linkonce.t*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
}
.rela.text ${RELOCATING-0} :
{
*(.rela.text)
${RELOCATING+*(.rela.text.*)}
- ${RELOCATING+*(.rela.gnu.linkonce.t*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
}
.rel.fini ${RELOCATING-0} : { *(.rel.fini) }
.rela.fini ${RELOCATING-0} : { *(.rela.fini) }
@@ -141,26 +164,26 @@ SECTIONS
{
*(.rel.rodata)
${RELOCATING+*(.rel.rodata.*)}
- ${RELOCATING+*(.rel.gnu.linkonce.r*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
}
.rela.rodata ${RELOCATING-0} :
{
*(.rela.rodata)
${RELOCATING+*(.rela.rodata.*)}
- ${RELOCATING+*(.rela.gnu.linkonce.r*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
}
${OTHER_READONLY_RELOC_SECTIONS}
.rel.data ${RELOCATING-0} :
{
*(.rel.data)
${RELOCATING+*(.rel.data.*)}
- ${RELOCATING+*(.rel.gnu.linkonce.d*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
}
.rela.data ${RELOCATING-0} :
{
*(.rela.data)
${RELOCATING+*(.rela.data.*)}
- ${RELOCATING+*(.rela.gnu.linkonce.d*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
}
.rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
.rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
@@ -173,30 +196,74 @@ SECTIONS
{
*(.rel.sdata)
${RELOCATING+*(.rel.sdata.*)}
- ${RELOCATING+*(.rel.gnu.linkonce.s*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
}
.rela.sdata ${RELOCATING-0} :
{
*(.rela.sdata)
${RELOCATING+*(.rela.sdata.*)}
- ${RELOCATING+*(.rela.gnu.linkonce.s*)}
+ ${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.sdata2 ${RELOCATING-0} :
+ {
+ *(.rel.sdata2)
+ ${RELOCATING+*(.rel.sdata2.*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.s2.*)}
+ }
+ .rela.sdata2 ${RELOCATING-0} :
+ {
+ *(.rela.sdata2)
+ ${RELOCATING+*(.rela.sdata2.*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.s2.*)}
+ }
+ .rel.sbss2 ${RELOCATING-0} :
+ {
+ *(.rel.sbss2)
+ ${RELOCATING+*(.rel.sbss2.*)}
+ ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)}
+ }
+ .rela.sbss2 ${RELOCATING-0} :
+ {
+ *(.rela.sbss2)
+ ${RELOCATING+*(.rela.sbss2.*)}
+ ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)}
+ }
+ .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.sbss ${RELOCATING-0} : { *(.rel.sbss) }
- .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
- .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
- .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
.rel.plt ${RELOCATING-0} : { *(.rel.plt) }
.rela.plt ${RELOCATING-0} : { *(.rela.plt) }
${OTHER_PLT_RELOC_SECTIONS}
.init ${RELOCATING-0} :
{
- ${INIT_START}
+ ${RELOCATING+${INIT_START}}
KEEP (*(.init))
- ${INIT_END}
+ ${RELOCATING+${INIT_END}}
} =${NOP-0}
- ${DATA_PLT-${PLT}}
+ ${DATA_PLT-${BSS_PLT-${PLT}}}
.text ${RELOCATING-0} :
{
${RELOCATING+${TEXT_START_SYMBOLS}}
@@ -205,19 +272,22 @@ SECTIONS
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
- ${RELOCATING+*(.gnu.linkonce.t*)}
+ ${RELOCATING+*(.gnu.linkonce.t.*)}
${RELOCATING+${OTHER_TEXT_SECTIONS}}
} =${NOP-0}
- ${RELOCATING+_etext = .;}
- ${RELOCATING+PROVIDE (etext = .);}
.fini ${RELOCATING-0} :
{
- ${FINI_START}
+ ${RELOCATING+${FINI_START}}
KEEP (*(.fini))
- ${FINI_END}
+ ${RELOCATING+${FINI_END}}
} =${NOP-0}
+ ${RELOCATING+PROVIDE (__etext = .);}
+ ${RELOCATING+PROVIDE (_etext = .);}
+ ${RELOCATING+PROVIDE (etext = .);}
${WRITABLE_RODATA-${RODATA}}
.rodata1 ${RELOCATING-0} : { *(.rodata1) }
+ ${CREATE_SHLIB-${SDATA2}}
+ ${CREATE_SHLIB-${SBSS2}}
${RELOCATING+${OTHER_READONLY_SECTIONS}}
/* Adjust the address for the data segment. We want to adjust up to
@@ -230,7 +300,7 @@ SECTIONS
${RELOCATING+${DATA_START_SYMBOLS}}
*(.data)
${RELOCATING+*(.data.*)}
- ${RELOCATING+*(.gnu.linkonce.d*)}
+ ${RELOCATING+*(.gnu.linkonce.d.*)}
${CONSTRUCTING+SORT(CONSTRUCTORS)}
}
.data1 ${RELOCATING-0} : { *(.data1) }
@@ -243,6 +313,8 @@ SECTIONS
${DATA_PLT+${PLT}}
${RELOCATING+${OTHER_GOT_SYMBOLS}}
.got ${RELOCATING-0} : { *(.got.plt) *(.got) }
+ ${CREATE_SHLIB+${SDATA2}}
+ ${CREATE_SHLIB+${SBSS2}}
${TEXT_DYNAMIC-${DYNAMIC}}
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
@@ -261,16 +333,23 @@ SECTIONS
${RELOCATING+${OTHER_BSS_SYMBOLS}}
.sbss ${RELOCATING-0} :
{
+ ${RELOCATING+PROVIDE (__sbss_start = .);}
+ ${RELOCATING+PROVIDE (___sbss_start = .);}
*(.dynsbss)
*(.sbss)
${RELOCATING+*(.sbss.*)}
+ ${RELOCATING+*(.gnu.linkonce.sb.*)}
*(.scommon)
+ ${RELOCATING+PROVIDE (__sbss_end = .);}
+ ${RELOCATING+PROVIDE (___sbss_end = .);}
}
+ ${BSS_PLT+${PLT}}
.bss ${RELOCATING-0} :
{
*(.dynbss)
*(.bss)
${RELOCATING+*(.bss.*)}
+ ${RELOCATING+*(.gnu.linkonce.b.*)}
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
@@ -310,7 +389,7 @@ SECTIONS
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
+ .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
OpenPOWER on IntegriCloud