Răsfoiți Sursa

* also use -T when cross-compiling a shared library using a sysroot on
Linux (we want to replace the entire built-in linker script in that case)

git-svn-id: trunk@31450 -

Jonas Maebe 10 ani în urmă
părinte
comite
882421a3ad
1 a modificat fișierele cu 235 adăugiri și 228 ștergeri
  1. 235 228
      compiler/systems/t_linux.pas

+ 235 - 228
compiler/systems/t_linux.pas

@@ -317,11 +317,15 @@ begin
   with Info do
    begin
      ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE';
+     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE';
      { when we want to cross-link we need to override default library paths }
      if length(sysrootpath) > 0 then
-       ExeCmd[1]:=ExeCmd[1]+' -T';
+       begin
+         ExeCmd[1]:=ExeCmd[1]+' -T';
+         DllCmd[1]:=DllCmd[1]+' -T';
+       end;
      ExeCmd[1]:=ExeCmd[1]+' $RES';
-     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
+     DllCmd[1]:=DllCmd[1]+' $RES';
      DllCmd[2]:='strip --strip-unneeded $EXE';
      ExtDbgCmd[1]:='objcopy --only-keep-debug $EXE $DBG';
      ExtDbgCmd[2]:='objcopy --add-gnu-debuglink=$DBG $EXE';
@@ -729,232 +733,235 @@ begin
 
 {$ifdef AArch64}
 {$define LINKERSCRIPT_INCLUDED}
-      if isdll or (sysrootpath='') then begin
-        { On other architectures, supplying a complete linker script
-          without the -T option just results in:
-            warning: link.res contains output sections; did you forget -T?
-          However, with a recent aarch64 linker the result is:
-            /usr/bin/ld: internal error ../../ld/ldlang.c 5221
-          So in these cases, where -T will not be used, we supply a
-          minimal linker script with just the FPC-specific part: }
-        add('SECTIONS');
-        add('{');
-        add('  .data           :');
-        add('  {');
-        { extra by FPC }
-        add('    KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
-        add('  }');
-        add('}');
-      end else begin
-        { 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('}');
-      end;
+      if sysrootpath='' then
+        begin
+          { On other architectures, supplying a complete linker script
+            without the -T option just results in:
+              warning: link.res contains output sections; did you forget -T?
+            However, with a recent aarch64 linker the result is:
+              /usr/bin/ld: internal error ../../ld/ldlang.c 5221
+            So in these cases, where -T will not be used, we supply a
+            minimal linker script with just the FPC-specific part: }
+          add('SECTIONS');
+          add('{');
+          add('  .data           :');
+          add('  {');
+          { extra by FPC }
+          add('    KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
+          add('  }');
+          add('}');
+        end
+      else
+        begin
+          { 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('}');
+        end;
 {$endif AArch64}
 
 {$ifdef ARM}