Use default linker script and only add FPC specific sections for Linux OS

git-svn-id: trunk@47374 -
This commit is contained in:
pierre 2020-11-10 17:21:00 +00:00
parent da042f7700
commit bcd52d66ee

View File

@ -686,768 +686,23 @@ begin
else
info.ExeCmd[1]:=info.ExeCmd[1]+' -e _start';
{ If we are using the default sysroot, use the default linker script and
just augment it with the FPC-specific parts.
}
if sysrootpath='' then
begin
add('SECTIONS');
add('{');
if not(cs_link_pre_binutils_2_19 in current_settings.globalswitches) then
{ we can't use ".data", as that would hide the .data from the
original linker script in combination with the INSERT at the end }
add(' .fpcdata :')
else
add(' .data :');
add(' {');
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' }');
add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
add('}');
{ this "INSERT" means "merge into the original linker script, even if
-T is used" }
if not(cs_link_pre_binutils_2_19 in current_settings.globalswitches) then
add('INSERT AFTER .data;');
end
add('SECTIONS');
add('{');
if not(cs_link_pre_binutils_2_19 in current_settings.globalswitches) then
{ we can't use ".data", as that would hide the .data from the
original linker script in combination with the INSERT at the end }
add(' .fpcdata :')
else
begin
{$ifdef x86_64}
{$define LINKERSCRIPT_INCLUDED}
add('SECTIONS');
add('{');
{Read-only sections, merged into text segment:}
if current_module.islibrary then
add(' . = 0 + SIZEOF_HEADERS;')
else
add(' PROVIDE (__executable_start = 0x0400000); . = 0x0400000 + SIZEOF_HEADERS;');
add(' .interp : { *(.interp) }');
add(' .hash : { *(.hash) }');
add(' .dynsym : { *(.dynsym) }');
add(' .dynstr : { *(.dynstr) }');
add(' .gnu.version : { *(.gnu.version) }');
add(' .gnu.version_d : { *(.gnu.version_d) }');
add(' .gnu.version_r : { *(.gnu.version_r) }');
add(' .rel.dyn :');
add(' {');
add(' *(.rel.init)');
add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
add(' *(.rel.fini)');
add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
add(' *(.rel.data.rel.ro*)');
add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
add(' *(.rel.got)');
add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
add(' }');
add(' .rela.dyn :');
add(' {');
add(' *(.rela.init)');
add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
add(' *(.rela.fini)');
add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
add(' *(.rela.got)');
add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
add(' }');
add(' .rel.plt : { *(.rel.plt) }');
add(' .rela.plt : { *(.rela.plt) }');
add(' .init :');
add(' {');
add(' KEEP (*(.init))');
add(' } =0x90909090');
add(' .plt : { *(.plt) }');
add(' .text :');
add(' {');
add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
add(' KEEP (*(.text.*personality*))');
{.gnu.warning sections are handled specially by elf32.em.}
add(' *(.gnu.warning)');
add(' } =0x90909090');
add(' .fini :');
add(' {');
add(' KEEP (*(.fini))');
add(' } =0x90909090');
add(' PROVIDE (_etext = .);');
add(' .rodata :');
add(' {');
add(' *(.rodata .rodata.* .gnu.linkonce.r.*)');
add(' }');
{Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up.}
add(' . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1));');
add(' .dynamic : { *(.dynamic) }');
add(' .got : { *(.got .toc) }');
add(' .got.plt : { *(.got.plt .toc.plt) }');
add(' .data :');
add(' {');
add(' *(.data .data.* .gnu.linkonce.d.*)');
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' KEEP (*(.gnu.linkonce.d.*personality*))');
add(' }');
add(' PROVIDE (_edata = .);');
add(' PROVIDE (edata = .);');
{$ifdef zsegment_threadvars}
add(' _z = .;');
add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
add(' . = _z + SIZEOF (.threadvar);');
{$else}
add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
{$endif}
add(' __bss_start = .;');
add(' .bss :');
add(' {');
add(' *(.dynbss)');
add(' *(.bss .bss.* .gnu.linkonce.b.*)');
add(' *(COMMON)');
{Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.}
add(' . = ALIGN(32 / 8);');
add('}');
add(' . = ALIGN(32 / 8);');
add(' PROVIDE (_end = .);');
add(' PROVIDE (end = .);');
{Stabs debugging sections.}
add(' .stab 0 : { *(.stab) }');
add(' .stabstr 0 : { *(.stabstr) }');
add(' /* DWARF debug sections.');
add(' Symbols in the DWARF debugging sections are relative to the beginning');
add(' of the section so we begin them at 0. */');
add(' /* DWARF 1 */');
add(' .debug 0 : { *(.debug) }');
add(' .line 0 : { *(.line) }');
add(' /* GNU DWARF 1 extensions */');
add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
add(' /* DWARF 1.1 and DWARF 2 */');
add(' .debug_aranges 0 : { *(.debug_aranges) }');
add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
add(' /* DWARF 2 */');
add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
add(' .debug_line 0 : { *(.debug_line) }');
add(' .debug_frame 0 : { *(.debug_frame) }');
add(' .debug_str 0 : { *(.debug_str) }');
add(' .debug_loc 0 : { *(.debug_loc) }');
add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
add(' /* SGI/MIPS DWARF 2 extensions */');
add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
add(' .debug_typenames 0 : { *(.debug_typenames) }');
add(' .debug_varnames 0 : { *(.debug_varnames) }');
add(' /DISCARD/ : { *(.note.GNU-stack) }');
add('}');
{$endif x86_64}
{$ifdef AArch64}
{$define LINKERSCRIPT_INCLUDED}
{ Complete linker script for aarch64-linux: }
add('SECTIONS');
add('{');
add(' /* Read-only sections, merged into text segment: */');
add(' PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;');
add(' .interp : { *(.interp) }');
add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
add(' .hash : { *(.hash) }');
add(' .gnu.hash : { *(.gnu.hash) }');
add(' .dynsym : { *(.dynsym) }');
add(' .dynstr : { *(.dynstr) }');
add(' .gnu.version : { *(.gnu.version) }');
add(' .gnu.version_d : { *(.gnu.version_d) }');
add(' .gnu.version_r : { *(.gnu.version_r) }');
add(' .rela.dyn :');
add(' {');
add(' *(.rela.init)');
add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
add(' *(.rela.fini)');
add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
add(' *(.rela.ctors)');
add(' *(.rela.dtors)');
add(' *(.rela.got)');
add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
add(' *(.rela.ifunc)');
add(' }');
add(' .rela.plt :');
add(' {');
add(' *(.rela.plt)');
add(' PROVIDE_HIDDEN (__rela_iplt_start = .);');
add(' *(.rela.iplt)');
add(' PROVIDE_HIDDEN (__rela_iplt_end = .);');
add(' }');
add(' .init :');
add(' {');
add(' KEEP (*(SORT_NONE(.init)))');
add(' } =0');
add(' .plt : ALIGN(16) { *(.plt) *(.iplt) }');
add(' .text :');
add(' {');
add(' *(.text.unlikely .text.*_unlikely .text.unlikely.*)');
add(' *(.text.exit .text.exit.*)');
add(' *(.text.startup .text.startup.*)');
add(' *(.text.hot .text.hot.*)');
add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
add(' /* .gnu.warning sections are handled specially by elf32.em. */');
add(' *(.gnu.warning)');
add(' } =0');
add(' .fini :');
add(' {');
add(' KEEP (*(SORT_NONE(.fini)))');
add(' } =0');
add(' PROVIDE (__etext = .);');
add(' PROVIDE (_etext = .);');
add(' PROVIDE (etext = .);');
add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
add(' .rodata1 : { *(.rodata1) }');
add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table');
add(' .gcc_except_table.*) }');
add(' /* These sections are generated by the Sun/Oracle C++ compiler. */');
add(' .exception_ranges : ONLY_IF_RO { *(.exception_ranges');
add(' .exception_ranges*) }');
add(' /* Adjust the address for the data segment. We want to adjust up to');
add(' the same address within the page on the next page up. */');
add(' . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));');
add(' /* Exception handling */');
add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
add(' .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }');
add(' /* Thread Local Storage sections */');
add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
add(' .preinit_array :');
add(' {');
add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
add(' KEEP (*(.preinit_array))');
add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
add(' }');
add(' .init_array :');
add(' {');
add(' PROVIDE_HIDDEN (__init_array_start = .);');
add(' KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))');
add(' KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))');
add(' PROVIDE_HIDDEN (__init_array_end = .);');
add(' }');
add(' .fini_array :');
add(' {');
add(' PROVIDE_HIDDEN (__fini_array_start = .);');
add(' KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))');
add(' KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))');
add(' PROVIDE_HIDDEN (__fini_array_end = .);');
add(' }');
add(' .ctors :');
add(' {');
add(' /* gcc uses crtbegin.o to find the start of');
add(' the constructors, so we make sure it is');
add(' first. Because this is a wildcard, it');
add(' doesn''t matter if the user does not');
add(' actually link against crtbegin.o; the');
add(' linker won''t look for a file to match a');
add(' wildcard. The wildcard also means that it');
add(' doesn''t matter which directory crtbegin.o');
add(' is in. */');
add(' KEEP (*crtbegin.o(.ctors))');
add(' KEEP (*crtbegin?.o(.ctors))');
add(' /* We don''t want to include the .ctor section from');
add(' the crtend.o file until after the sorted ctors.');
add(' The .ctor section from the crtend file contains the');
add(' end of ctors marker and it must be last */');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
add(' KEEP (*(SORT(.ctors.*)))');
add(' KEEP (*(.ctors))');
add(' }');
add(' .dtors :');
add(' {');
add(' KEEP (*crtbegin.o(.dtors))');
add(' KEEP (*crtbegin?.o(.dtors))');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
add(' KEEP (*(SORT(.dtors.*)))');
add(' KEEP (*(.dtors))');
add(' }');
add(' .jcr : { KEEP (*(.jcr)) }');
add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }');
add(' .dynamic : { *(.dynamic) }');
add(' .got : { *(.got) *(.igot) }');
add(' . = DATA_SEGMENT_RELRO_END (24, .);');
add(' .got.plt : { *(.got.plt) *(.igot.plt) }');
add(' .data :');
add(' {');
add(' PROVIDE (__data_start = .);');
{ extra by FPC }
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' *(.data .data.* .gnu.linkonce.d.*)');
add(' SORT(CONSTRUCTORS)');
add(' }');
add(' .data1 : { *(.data1) }');
add(' _edata = .; PROVIDE (edata = .);');
add(' . = .;');
add(' __bss_start = .;');
add(' __bss_start__ = .;');
add(' .bss :');
add(' {');
add(' *(.dynbss)');
add(' *(.bss .bss.* .gnu.linkonce.b.*)');
add(' *(COMMON)');
add(' /* Align here to ensure that the .bss section occupies space up to');
add(' _end. Align after .bss to ensure correct alignment even if the');
add(' .bss section disappears because there are no input sections.');
add(' FIXME: Why do we need it? When there is no .bss section, we don''t');
add(' pad the .data section. */');
add(' . = ALIGN(. != 0 ? 64 / 8 : 1);');
add(' }');
add(' _bss_end__ = . ; __bss_end__ = . ;');
add(' . = ALIGN(64 / 8);');
add(' . = SEGMENT_START("ldata-segment", .);');
add(' . = ALIGN(64 / 8);');
add(' __end__ = . ;');
add(' _end = .; PROVIDE (end = .);');
add(' . = DATA_SEGMENT_END (.);');
add(' /* Stabs debugging sections. */');
add(' .stab 0 : { *(.stab) }');
add(' .stabstr 0 : { *(.stabstr) }');
add(' .stab.excl 0 : { *(.stab.excl) }');
add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
add(' .stab.index 0 : { *(.stab.index) }');
add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
add(' .comment 0 : { *(.comment) }');
add(' /* DWARF debug sections.');
add(' Symbols in the DWARF debugging sections are relative to the beginning');
add(' of the section so we begin them at 0. */');
add(' /* DWARF 1 */');
add(' .debug 0 : { *(.debug) }');
add(' .line 0 : { *(.line) }');
add(' /* GNU DWARF 1 extensions */');
add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
add(' /* DWARF 1.1 and DWARF 2 */');
add(' .debug_aranges 0 : { *(.debug_aranges) }');
add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
add(' /* DWARF 2 */');
add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
add(' .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }');
add(' .debug_frame 0 : { *(.debug_frame) }');
add(' .debug_str 0 : { *(.debug_str) }');
add(' .debug_loc 0 : { *(.debug_loc) }');
add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
add(' /* SGI/MIPS DWARF 2 extensions */');
add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
add(' .debug_typenames 0 : { *(.debug_typenames) }');
add(' .debug_varnames 0 : { *(.debug_varnames) }');
add(' /* DWARF 3 */');
add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
add(' .debug_ranges 0 : { *(.debug_ranges) }');
add(' /* DWARF Extension. */');
add(' .debug_macro 0 : { *(.debug_macro) }');
add(' .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }');
add(' .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }');
add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }');
add('}');
{$endif AArch64}
{$ifdef ARM}
if target_info.abi in [abi_eabi,abi_eabihf] then
begin
{ from GNU ld (CodeSourcery Sourcery G++ Lite 2007q3-53) 2.18.50.20070820 }
add('/* Script for -z combreloc: combine and sort reloc sections */');
add('OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",');
add(' "elf32-littlearm")');
add('OUTPUT_ARCH(arm)');
add('SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");');
add('SECTIONS');
add('{');
add(' /* Read-only sections, merged into text segment: */');
add(' PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x10000)); . = SEGMENT_START("text-segment", 0x10000) + SIZEOF_HEADERS;');
add(' .interp : { *(.interp) }');
add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
add(' .hash : { *(.hash) }');
add(' .gnu.hash : { *(.gnu.hash) }');
add(' .dynsym : { *(.dynsym) }');
add(' .dynstr : { *(.dynstr) }');
add(' .gnu.version : { *(.gnu.version) }');
add(' .gnu.version_d : { *(.gnu.version_d) }');
add(' .gnu.version_r : { *(.gnu.version_r) }');
add(' .rel.dyn :');
add(' {');
add(' *(.rel.init)');
add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
add(' *(.rel.fini)');
add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
add(' *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)');
add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
add(' *(.rel.ctors)');
add(' *(.rel.dtors)');
add(' *(.rel.got)');
add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
add(' }');
add(' .rela.dyn :');
add(' {');
add(' *(.rela.init)');
add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
add(' *(.rela.fini)');
add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
add(' *(.rela.ctors)');
add(' *(.rela.dtors)');
add(' *(.rela.got)');
add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
add(' }');
add(' .rel.plt : { *(.rel.plt) }');
add(' .rela.plt : { *(.rela.plt) }');
add(' .init :');
add(' {');
add(' KEEP (*(.init))');
add(' } =0');
add(' .plt : { *(.plt) }');
add(' .text :');
add(' {');
add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
add(' KEEP (*(.text.*personality*))');
add(' /* .gnu.warning sections are handled specially by elf32.em. */');
add(' *(.gnu.warning)');
add(' *(.glue_7t) *(.glue_7) *(.vfp11_veneer)');
add(' } =0');
add(' .fini :');
add(' {');
add(' KEEP (*(.fini))');
add(' } =0');
add(' PROVIDE (__etext = .);');
add(' PROVIDE (_etext = .);');
add(' PROVIDE (etext = .);');
add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
add(' .rodata1 : { *(.rodata1) }');
add(' .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }');
add(' __exidx_start = .;');
add(' .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }');
add(' __exidx_end = .;');
add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }');
add(' /* Adjust the address for the data segment. We want to adjust up to');
add(' the same address within the page on the next page up. */');
add(' . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));');
add(' /* Exception handling */');
add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
add(' /* Thread Local Storage sections */');
add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
add(' .preinit_array :');
add(' {');
add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
add(' KEEP (*(.preinit_array))');
add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
add(' }');
add(' .init_array :');
add(' {');
add(' PROVIDE_HIDDEN (__init_array_start = .);');
add(' KEEP (*(SORT(.init_array.*)))');
add(' KEEP (*(.init_array))');
add(' PROVIDE_HIDDEN (__init_array_end = .);');
add(' }');
add(' .fini_array :');
add(' {');
add(' PROVIDE_HIDDEN (__fini_array_start = .);');
add(' KEEP (*(.fini_array))');
add(' KEEP (*(SORT(.fini_array.*)))');
add(' PROVIDE_HIDDEN (__fini_array_end = .);');
add(' }');
add(' .ctors :');
add(' {');
add(' /* gcc uses crtbegin.o to find the start of');
add(' the constructors, so we make sure it is');
add(' first. Because this is a wildcard, it');
add(' doesn''t matter if the user does not');
add(' actually link against crtbegin.o; the');
add(' linker won''t look for a file to match a');
add(' wildcard. The wildcard also means that it');
add(' doesn''t matter which directory crtbegin.o');
add(' is in. */');
add(' KEEP (*crtbegin.o(.ctors))');
add(' KEEP (*crtbegin?.o(.ctors))');
add(' /* We don''t want to include the .ctor section from');
add(' the crtend.o file until after the sorted ctors.');
add(' The .ctor section from the crtend file contains the');
add(' end of ctors marker and it must be last */');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
add(' KEEP (*(SORT(.ctors.*)))');
add(' KEEP (*(.ctors))');
add(' }');
add(' .dtors :');
add(' {');
add(' KEEP (*crtbegin.o(.dtors))');
add(' KEEP (*crtbegin?.o(.dtors))');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
add(' KEEP (*(SORT(.dtors.*)))');
add(' KEEP (*(.dtors))');
add(' }');
add(' .jcr : { KEEP (*(.jcr)) }');
add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }');
add(' .dynamic : { *(.dynamic) }');
add(' .got : { *(.got.plt) *(.got) }');
add(' .data :');
add(' {');
add(' __data_start = . ;');
add(' *(.data .data.* .gnu.linkonce.d.*)');
{ extra by FPC }
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' KEEP (*(.gnu.linkonce.d.*personality*))');
add(' SORT(CONSTRUCTORS)');
add(' }');
add(' .data1 : { *(.data1) }');
add(' _edata = .; PROVIDE (edata = .);');
add(' __bss_start = .;');
add(' __bss_start__ = .;');
add(' .bss :');
add(' {');
add(' *(.dynbss)');
add(' *(.bss .bss.* .gnu.linkonce.b.*)');
add(' *(COMMON)');
add(' /* Align here to ensure that the .bss section occupies space up to');
add(' _end. Align after .bss to ensure correct alignment even if the');
add(' .bss section disappears because there are no input sections.');
add(' FIXME: Why do we need it? When there is no .bss section, we don''t');
add(' pad the .data section. */');
add(' . = ALIGN(. != 0 ? 32 / 8 : 1);');
add(' }');
add(' _bss_end__ = . ; __bss_end__ = . ;');
add(' . = ALIGN(32 / 8);');
add(' . = ALIGN(32 / 8);');
add(' __end__ = . ;');
add(' _end = .; PROVIDE (end = .);');
add(' /* Stabs debugging sections. */');
add(' .stab 0 : { *(.stab) }');
add(' .stabstr 0 : { *(.stabstr) }');
add(' .stab.excl 0 : { *(.stab.excl) }');
add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
add(' .stab.index 0 : { *(.stab.index) }');
add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
add(' .comment 0 : { *(.comment) }');
add(' /* DWARF debug sections.');
add(' Symbols in the DWARF debugging sections are relative to the beginning');
add(' of the section so we begin them at 0. */');
add(' /* DWARF 1 */');
add(' .debug 0 : { *(.debug) }');
add(' .line 0 : { *(.line) }');
add(' /* GNU DWARF 1 extensions */');
add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
add(' /* DWARF 1.1 and DWARF 2 */');
add(' .debug_aranges 0 : { *(.debug_aranges) }');
add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
add(' /* DWARF 2 */');
add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
add(' .debug_line 0 : { *(.debug_line) }');
add(' .debug_frame 0 : { *(.debug_frame) }');
add(' .debug_str 0 : { *(.debug_str) }');
add(' .debug_loc 0 : { *(.debug_loc) }');
add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
add(' /* SGI/MIPS DWARF 2 extensions */');
add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
add(' .debug_typenames 0 : { *(.debug_typenames) }');
add(' .debug_varnames 0 : { *(.debug_varnames) }');
add(' /* DWARF 3 */');
add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
add(' .debug_ranges 0 : { *(.debug_ranges) }');
add(' .stack 0x80000 :');
add(' {');
add(' _stack = .;');
add(' *(.stack)');
add(' }');
add(' .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }');
add(' .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }');
add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }');
add('}');
end
else
{$endif ARM}
{$ifndef LINKERSCRIPT_INCLUDED}
begin
{Sections.}
add('SECTIONS');
add('{');
{Read-only sections, merged into text segment:}
add(' PROVIDE (__executable_start = 0x010000); . = 0x010000 + SIZEOF_HEADERS;');
add(' .interp : { *(.interp) }');
add(' .hash : { *(.hash) }');
add(' .dynsym : { *(.dynsym) }');
add(' .dynstr : { *(.dynstr) }');
add(' .gnu.version : { *(.gnu.version) }');
add(' .gnu.version_d : { *(.gnu.version_d) }');
add(' .gnu.version_r : { *(.gnu.version_r) }');
add(' .rel.dyn :');
add(' {');
add(' *(.rel.init)');
add(' *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)');
add(' *(.rel.fini)');
add(' *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)');
add(' *(.rel.data.rel.ro*)');
add(' *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)');
add(' *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)');
add(' *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)');
add(' *(.rel.got)');
add(' *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)');
add(' }');
add(' .rela.dyn :');
add(' {');
add(' *(.rela.init)');
add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
add(' *(.rela.fini)');
add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
add(' *(.rela.got)');
add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
add(' }');
add(' .rel.plt : { *(.rel.plt) }');
add(' .rela.plt : { *(.rela.plt) }');
add(' .init :');
add(' {');
add(' KEEP (*(.init))');
add(' } =0x90909090');
add(' .plt : { *(.plt) }');
add(' .text :');
add(' {');
add(' *(.text .stub .text.* .gnu.linkonce.t.*)');
add(' KEEP (*(.text.*personality*))');
{.gnu.warning sections are handled specially by elf32.em.}
add(' *(.gnu.warning)');
add(' } =0x90909090');
add(' .fini :');
add(' {');
add(' KEEP (*(.fini))');
add(' } =0x90909090');
add(' PROVIDE (_etext = .);');
add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
add(' .rodata1 : { *(.rodata1) }');
add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table');
add(' .gcc_except_table.*) }');
add(' /* These sections are generated by the Sun/Oracle C++ compiler. */');
add(' .exception_ranges : ONLY_IF_RO { *(.exception_ranges');
add(' .exception_ranges*) }');
add(' /* Adjust the address for the data segment. We want to adjust up to');
add(' the same address within the page on the next page up. */');
add(' . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));');
add(' /* Exception handling */');
add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
add(' .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }');
add(' /* Thread Local Storage sections */');
add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
add(' .preinit_array :');
add(' {');
add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
add(' KEEP (*(.preinit_array))');
add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
add(' }');
add(' .init_array :');
add(' {');
add(' PROVIDE_HIDDEN (__init_array_start = .);');
add(' KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))');
add(' KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))');
add(' PROVIDE_HIDDEN (__init_array_end = .);');
add(' }');
add(' .fini_array :');
add(' {');
add(' PROVIDE_HIDDEN (__fini_array_start = .);');
add(' KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))');
add(' KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))');
add(' PROVIDE_HIDDEN (__fini_array_end = .);');
add(' }');
add(' .ctors :');
add(' {');
add(' /* gcc uses crtbegin.o to find the start of');
add(' the constructors, so we make sure it is');
add(' first. Because this is a wildcard, it');
add(' doesn''t matter if the user does not');
add(' actually link against crtbegin.o; the');
add(' linker won''t look for a file to match a');
add(' wildcard. The wildcard also means that it');
add(' doesn''t matter which directory crtbegin.o');
add(' is in. */');
add(' KEEP (*crtbegin.o(.ctors))');
add(' KEEP (*crtbegin?.o(.ctors))');
add(' /* We don''t want to include the .ctor section from');
add(' the crtend.o file until after the sorted ctors.');
add(' The .ctor section from the crtend file contains the');
add(' end of ctors marker and it must be last */');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
add(' KEEP (*(SORT(.ctors.*)))');
add(' KEEP (*(.ctors))');
add(' }');
add(' .dtors :');
add(' {');
add(' KEEP (*crtbegin.o(.dtors))');
add(' KEEP (*crtbegin?.o(.dtors))');
add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
add(' KEEP (*(SORT(.dtors.*)))');
add(' KEEP (*(.dtors))');
add(' }');
add(' .jcr : { KEEP (*(.jcr)) }');
add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }');
add(' .dynamic : { *(.dynamic) }');
add(' .got : { *(.got) }');
add(' .got.plt : { *(.got.plt) }');
add(' .data :');
add(' {');
add(' *(.data .data.* .gnu.linkonce.d.*)');
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' KEEP (*(.gnu.linkonce.d.*personality*))');
add(' }');
add(' PROVIDE (_edata = .);');
add(' PROVIDE (edata = .);');
{$ifdef zsegment_threadvars}
add(' _z = .;');
add(' .threadvar 0 : AT (_z) { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
add(' PROVIDE (_threadvar_size = SIZEOF(.threadvar));');
add(' . = _z + SIZEOF (.threadvar);');
{$else}
add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
{$endif}
add(' __bss_start = .;');
add(' .bss :');
add(' {');
add(' *(.dynbss)');
add(' *(.bss .bss.* .gnu.linkonce.b.*)');
add(' *(COMMON)');
{Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.}
add(' . = ALIGN(32 / 8);');
add(' }');
add(' . = ALIGN(32 / 8);');
add(' PROVIDE (_end = .);');
add(' PROVIDE (end = .);');
{Stabs debugging sections.}
add(' .stab 0 : { *(.stab) }');
add(' .stabstr 0 : { *(.stabstr) }');
add('}');
end;
{$endif LINKERSCRIPT_INCLUDED}
end;
add(' .data :');
add(' {');
add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
add(' }');
add(' .threadvar : { *(.threadvar .threadvar.* .gnu.linkonce.tv.*) }');
add('}');
{ this "INSERT" means "merge into the original linker script, even if
-T is used" }
if not(cs_link_pre_binutils_2_19 in current_settings.globalswitches) then
add('INSERT AFTER .data;');
{ Write and Close response }
writetodisk;
Free;