xref: /netbsd-src/external/gpl3/binutils.old/dist/ld/scripttempl/i386go32.sc (revision e992f068c547fd6e84b3f104dc2340adcc955732)
1# Linker script for i386 go32 (DJGPP)
2#
3# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4#
5# Copying and distribution of this file, with or without modification,
6# are permitted in any medium without royalty provided the copyright
7# notice and this notice are preserved.
8
9test -z "$ENTRY" && ENTRY=start
10EXE=${CONSTRUCTING+${RELOCATING+-exe}}
11
12# These are substituted in as variables in order to get '}' in a shell
13# conditional expansion.
14CTOR='.ctor : {
15    *(SORT(.ctors.*))
16    *(.ctor)
17  }'
18DTOR='.dtor : {
19    *(SORT(.dtors.*))
20    *(.dtor)
21  }'
22
23cat <<EOF
24/* Copyright (C) 2014-2022 Free Software Foundation, Inc.
25
26   Copying and distribution of this script, with or without modification,
27   are permitted in any medium without royalty provided the copyright
28   notice and this notice are preserved.  */
29
30OUTPUT_FORMAT("${OUTPUT_FORMAT}${EXE}")
31
32${RELOCATING+ENTRY (${ENTRY})}
33
34SECTIONS
35{
36  .text ${RELOCATING+ ${TARGET_PAGE_SIZE}+SIZEOF_HEADERS} : {
37    *(.text)
38    ${RELOCATING+*(.text.*)}
39    ${RELOCATING+*(.gnu.linkonce.t*)}
40    *(.const*)
41    *(.ro*)
42    ${RELOCATING+*(.gnu.linkonce.r*)}
43    ${RELOCATING+etext  =  . ; PROVIDE(_etext = .) ;}
44    ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});}
45  }
46
47  .data ${RELOCATING+ ${DATA_ALIGNMENT}} : {
48    ${RELOCATING+djgpp_first_ctor = . ;
49    *(SORT(.ctors.*))
50    *(.ctor)
51    *(.ctors)
52    djgpp_last_ctor = . ;}
53    ${RELOCATING+djgpp_first_dtor = . ;
54    *(SORT(.dtors.*))
55    *(.dtor)
56    *(.dtors)
57    djgpp_last_dtor = . ;}
58    __environ = . ;
59    PROVIDE(_environ = .) ;
60    LONG(0) ;
61    *(.data)
62    ${RELOCATING+*(.data.*)}
63
64    ${RELOCATING+*(.gcc_exc*)}
65    ${RELOCATING+___EH_FRAME_BEGIN__ = . ;}
66    ${RELOCATING+*(.eh_fram*)}
67    ${RELOCATING+___EH_FRAME_END__ = . ;}
68    ${RELOCATING+LONG(0);}
69
70    ${RELOCATING+*(.gnu.linkonce.d*)}
71    ${RELOCATING+edata  =  . ; PROVIDE(_edata = .) ;}
72    ${RELOCATING+. = ALIGN(${SEGMENT_SIZE});}
73  }
74
75  ${CONSTRUCTING+${RELOCATING-$CTOR}}
76  ${CONSTRUCTING+${RELOCATING-$DTOR}}
77
78  .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
79  {
80    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
81    *(COMMON)
82    ${RELOCATING+ end = . ; PROVIDE(_end = .) ;}
83    ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});}
84  }
85
86  /* Discard LTO sections.  */
87  /DISCARD/ : { *(.gnu.lto_*) }
88
89  /* Stabs debugging sections.  */
90  .stab 0 : { *(.stab) }
91  .stabstr 0 : { *(.stabstr) }
92EOF
93
94. $srcdir/scripttempl/DWARF.sc
95
96cat <<EOF
97}
98EOF
99