-cleaned up ld script

git-svn-id: http://moon:8086/svn/mips@113 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-21 13:07:49 +00:00
parent d1c1a04da7
commit 7a49d1e400
+204 -201
View File
@@ -1,3 +1,12 @@
/* Specify the memory areas */
MEMORY
{
rom : ORIGIN = 0xBFC00000, LENGTH = 0x00002000 /* 8K */
ram : ORIGIN = 0x40000000, LENGTH = 0x04000000 /* 64M */
flash : ORIGIN = 0x00000000, LENGTH = 0x00800000 /* 8M */
io : ORIGIN = 0xA0000000, LENGTH = 0x00800000 /* 8M */
}
stack_ptr = 0x7FFFEFF0; stack_ptr = 0x7FFFEFF0;
STARTUP(startup.o) STARTUP(startup.o)
@@ -5,205 +14,199 @@ INPUT(kernel.o)
SECTIONS SECTIONS
{ {
/* Read-only sections, merged into text segment: */ .start :
PROVIDE (__executable_start = 0x40000000); . = 0x40000000; {
.start __executable_start : start = ALIGN(2);
{ entry = ALIGN(2);
start = ALIGN(2); _entry = ALIGN(2);
entry = ALIGN(2); __entry = ALIGN(2);
_entry = ALIGN(2); *(.start)
__entry = ALIGN(2); } >ram
*(.start)
} .exc_vector ORIGIN(ram) + 0x80 :
/* Kernel text with low-level exception handler */ {
.exc_vector __executable_start + 0x080 : *(.exc_vect)
{ } >ram
_exc_vect_start = .; .init :
*(.exc_vect) {
_exc_vect_end = .; KEEP (*(.init))
} } >ram
.init : .text :
{ {
KEEP (*(.init)) _ftext = . ;
} =0 *(.text .stub .text.* .gnu.linkonce.t.*)
.plt : { *(.plt) } *(.gnu.warning)
.text : *(.mips16.fn.*) *(.mips16.call.*)
{ } >ram
_ftext = . ; .fini :
*(.text .stub .text.* .gnu.linkonce.t.*) {
/* .gnu.warning sections are handled specially by elf32.em. */ KEEP (*(.fini))
*(.gnu.warning) } >ram
*(.mips16.fn.*) *(.mips16.call.*) PROVIDE (__etext = .);
} =0 PROVIDE (_etext = .);
.fini : PROVIDE (etext = .);
{ .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } >ram
KEEP (*(.fini)) .rodata1 : { *(.rodata1) } >ram
} =0 .sdata2 :
PROVIDE (__etext = .); {
PROVIDE (_etext = .); *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
PROVIDE (etext = .); } >ram
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } >ram
.rodata1 : { *(.rodata1) } .eh_frame_hdr : { *(.eh_frame_hdr) } >ram
.sdata2 : .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } >ram
{ .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*) /* Adjust the address for the data segment. We want to adjust up to
} the same address within the page on the next page up. */
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
.eh_frame_hdr : { *(.eh_frame_hdr) } /* Exception handling */
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } >ram
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } >ram
/* Adjust the address for the data segment. We want to adjust up to /* Thread Local Storage sections */
the same address within the page on the next page up. */ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } >ram
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } >ram
/* Exception handling */ .preinit_array :
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } {
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } PROVIDE_HIDDEN (__preinit_array_start = .);
/* Thread Local Storage sections */ KEEP (*(.preinit_array))
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } PROVIDE_HIDDEN (__preinit_array_end = .);
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } } >ram
.preinit_array : .init_array :
{ {
PROVIDE_HIDDEN (__preinit_array_start = .); PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(SORT(.init_array.*)))
PROVIDE_HIDDEN (__preinit_array_end = .); KEEP (*(.init_array))
} PROVIDE_HIDDEN (__init_array_end = .);
.init_array : } >ram
{ .fini_array :
PROVIDE_HIDDEN (__init_array_start = .); {
KEEP (*(SORT(.init_array.*))) PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.init_array)) KEEP (*(.fini_array))
PROVIDE_HIDDEN (__init_array_end = .); KEEP (*(SORT(.fini_array.*)))
} PROVIDE_HIDDEN (__fini_array_end = .);
.fini_array : } >ram
{ .ctors :
PROVIDE_HIDDEN (__fini_array_start = .); {
KEEP (*(.fini_array)) /* gcc uses crtbegin.o to find the start of
KEEP (*(SORT(.fini_array.*))) the constructors, so we make sure it is
PROVIDE_HIDDEN (__fini_array_end = .); first. Because this is a wildcard, it
} doesn't matter if the user does not
.ctors : actually link against crtbegin.o; the
{ linker won't look for a file to match a
/* gcc uses crtbegin.o to find the start of wildcard. The wildcard also means that it
the constructors, so we make sure it is doesn't matter which directory crtbegin.o
first. Because this is a wildcard, it is in. */
doesn't matter if the user does not KEEP (*crtbegin.o(.ctors))
actually link against crtbegin.o; the KEEP (*crtbegin?.o(.ctors))
linker won't look for a file to match a /* We don't want to include the .ctor section from
wildcard. The wildcard also means that it the crtend.o file until after the sorted ctors.
doesn't matter which directory crtbegin.o The .ctor section from the crtend file contains the
is in. */ end of ctors marker and it must be last */
KEEP (*crtbegin.o(.ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*crtbegin?.o(.ctors)) KEEP (*(SORT(.ctors.*)))
/* We don't want to include the .ctor section from KEEP (*(.ctors))
the crtend.o file until after the sorted ctors. } >ram
The .ctor section from the crtend file contains the .dtors :
end of ctors marker and it must be last */ {
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*crtbegin.o(.dtors))
KEEP (*(SORT(.ctors.*))) KEEP (*crtbegin?.o(.dtors))
KEEP (*(.ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
} KEEP (*(SORT(.dtors.*)))
.dtors : KEEP (*(.dtors))
{ } >ram
KEEP (*crtbegin.o(.dtors)) .jcr : { KEEP (*(.jcr)) } >ram
KEEP (*crtbegin?.o(.dtors)) .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } >ram
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) . = DATA_SEGMENT_RELRO_END (0, .);
KEEP (*(SORT(.dtors.*))) .data :
KEEP (*(.dtors)) {
} _fdata = . ;
.jcr : { KEEP (*(.jcr)) } *(.data .data.* .gnu.linkonce.d.*)
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } SORT(CONSTRUCTORS)
. = DATA_SEGMENT_RELRO_END (0, .); } >ram
.data : .data1 : { *(.data1) } >ram
{ .got.plt : { *(.got.plt) } >ram
_fdata = . ; . = .;
*(.data .data.* .gnu.linkonce.d.*) _gp = ALIGN(16) + 0x7ff0;
SORT(CONSTRUCTORS) .got : { *(.got) }
} /* We want the small data sections together, so single-instruction offsets
.data1 : { *(.data1) } can access them all, and initialized data all before uninitialized, so
.got.plt : { *(.got.plt) } we can shorten the on-disk segment size. */
. = .; .sdata :
_gp = ALIGN(16) + 0x7ff0; {
.got : { *(.got) } *(.sdata .sdata.* .gnu.linkonce.s.*)
/* We want the small data sections together, so single-instruction offsets } >ram
can access them all, and initialized data all before uninitialized, so .lit8 : { *(.lit8) } >ram
we can shorten the on-disk segment size. */ .lit4 : { *(.lit4) } >ram
.sdata : _edata = .; PROVIDE (edata = .);
{ __bss_start = .;
*(.sdata .sdata.* .gnu.linkonce.s.*) _fbss = .;
} .sbss :
.lit8 : { *(.lit8) } {
.lit4 : { *(.lit4) } *(.dynsbss)
_edata = .; PROVIDE (edata = .); *(.sbss .sbss.* .gnu.linkonce.sb.*)
__bss_start = .; *(.scommon)
_fbss = .; } >ram
.sbss : .bss :
{ {
*(.dynsbss) *(.dynbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*) *(.bss .bss.* .gnu.linkonce.b.*)
*(.scommon) *(COMMON)
} /* Align here to ensure that the .bss section occupies space up to
.bss : _end. Align after .bss to ensure correct alignment even if the
{ .bss section disappears because there are no input sections.
*(.dynbss) FIXME: Why do we need it? When there is no .bss section, we don't
*(.bss .bss.* .gnu.linkonce.b.*) pad the .data section. */
*(COMMON) . = ALIGN(. != 0 ? 32 / 8 : 1);
/* Align here to ensure that the .bss section occupies space up to } >ram
_end. Align after .bss to ensure correct alignment even if the . = ALIGN(32 / 8);
.bss section disappears because there are no input sections. . = ALIGN(32 / 8);
FIXME: Why do we need it? When there is no .bss section, we don't _end = .; PROVIDE (end = .);
pad the .data section. */ . = DATA_SEGMENT_END (.);
. = ALIGN(. != 0 ? 32 / 8 : 1); /* Stabs debugging sections. */
} .stab 0 : { *(.stab) }
. = ALIGN(32 / 8); .stabstr 0 : { *(.stabstr) }
. = ALIGN(32 / 8); .stab.excl 0 : { *(.stab.excl) }
_end = .; PROVIDE (end = .); .stab.exclstr 0 : { *(.stab.exclstr) }
. = DATA_SEGMENT_END (.); .stab.index 0 : { *(.stab.index) }
/* Stabs debugging sections. */ .stab.indexstr 0 : { *(.stab.indexstr) }
.stab 0 : { *(.stab) } .comment 0 : { *(.comment) }
.stabstr 0 : { *(.stabstr) } /* DWARF debug sections.
.stab.excl 0 : { *(.stab.excl) } Symbols in the DWARF debugging sections are relative to the beginning
.stab.exclstr 0 : { *(.stab.exclstr) } of the section so we begin them at 0. */
.stab.index 0 : { *(.stab.index) } /* DWARF 1 */
.stab.indexstr 0 : { *(.stab.indexstr) } .debug 0 : { *(.debug) }
.comment 0 : { *(.comment) } .line 0 : { *(.line) }
/* DWARF debug sections. /* GNU DWARF 1 extensions */
Symbols in the DWARF debugging sections are relative to the beginning .debug_srcinfo 0 : { *(.debug_srcinfo) }
of the section so we begin them at 0. */ .debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1 */ /* DWARF 1.1 and DWARF 2 */
.debug 0 : { *(.debug) } .debug_aranges 0 : { *(.debug_aranges) }
.line 0 : { *(.line) } .debug_pubnames 0 : { *(.debug_pubnames) }
/* GNU DWARF 1 extensions */ /* DWARF 2 */
.debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_sfnames 0 : { *(.debug_sfnames) } .debug_abbrev 0 : { *(.debug_abbrev) }
/* DWARF 1.1 and DWARF 2 */ .debug_line 0 : { *(.debug_line) }
.debug_aranges 0 : { *(.debug_aranges) } .debug_frame 0 : { *(.debug_frame) }
.debug_pubnames 0 : { *(.debug_pubnames) } .debug_str 0 : { *(.debug_str) }
/* DWARF 2 */ .debug_loc 0 : { *(.debug_loc) }
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_macinfo 0 : { *(.debug_macinfo) }
.debug_abbrev 0 : { *(.debug_abbrev) } /* SGI/MIPS DWARF 2 extensions */
.debug_line 0 : { *(.debug_line) } .debug_weaknames 0 : { *(.debug_weaknames) }
.debug_frame 0 : { *(.debug_frame) } .debug_funcnames 0 : { *(.debug_funcnames) }
.debug_str 0 : { *(.debug_str) } .debug_typenames 0 : { *(.debug_typenames) }
.debug_loc 0 : { *(.debug_loc) } .debug_varnames 0 : { *(.debug_varnames) }
.debug_macinfo 0 : { *(.debug_macinfo) } /* DWARF 3 */
/* SGI/MIPS DWARF 2 extensions */ .debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_weaknames 0 : { *(.debug_weaknames) } .debug_ranges 0 : { *(.debug_ranges) }
.debug_funcnames 0 : { *(.debug_funcnames) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
.debug_typenames 0 : { *(.debug_typenames) } .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.debug_varnames 0 : { *(.debug_varnames) } .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
/* DWARF 3 */ .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) }
.debug_pubtypes 0 : { *(.debug_pubtypes) } .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) }
.debug_ranges 0 : { *(.debug_ranges) } .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) }
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) }
.mdebug.abi32 : { KEEP(*(.mdebug.abi32)) } .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
.mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) } .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
.mdebug.abi64 : { KEEP(*(.mdebug.abi64)) } /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
.mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) }
.mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) }
.mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) }
.gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
.gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
} }