-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
+42 -39
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,82 +14,76 @@ INPUT(kernel.o)
SECTIONS SECTIONS
{ {
/* Read-only sections, merged into text segment: */ .start :
PROVIDE (__executable_start = 0x40000000); . = 0x40000000;
.start __executable_start :
{ {
start = ALIGN(2); start = ALIGN(2);
entry = ALIGN(2); entry = ALIGN(2);
_entry = ALIGN(2); _entry = ALIGN(2);
__entry = ALIGN(2); __entry = ALIGN(2);
*(.start) *(.start)
} } >ram
/* Kernel text with low-level exception handler */
.exc_vector __executable_start + 0x080 : .exc_vector ORIGIN(ram) + 0x80 :
{ {
_exc_vect_start = .;
*(.exc_vect) *(.exc_vect)
_exc_vect_end = .; } >ram
}
.init : .init :
{ {
KEEP (*(.init)) KEEP (*(.init))
} =0 } >ram
.plt : { *(.plt) }
.text : .text :
{ {
_ftext = . ; _ftext = . ;
*(.text .stub .text.* .gnu.linkonce.t.*) *(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning) *(.gnu.warning)
*(.mips16.fn.*) *(.mips16.call.*) *(.mips16.fn.*) *(.mips16.call.*)
} =0 } >ram
.fini : .fini :
{ {
KEEP (*(.fini)) KEEP (*(.fini))
} =0 } >ram
PROVIDE (__etext = .); PROVIDE (__etext = .);
PROVIDE (_etext = .); PROVIDE (_etext = .);
PROVIDE (etext = .); PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } >ram
.rodata1 : { *(.rodata1) } .rodata1 : { *(.rodata1) } >ram
.sdata2 : .sdata2 :
{ {
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
} } >ram
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } >ram
.eh_frame_hdr : { *(.eh_frame_hdr) } .eh_frame_hdr : { *(.eh_frame_hdr) } >ram
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } >ram
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to /* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */ the same address within the page on the next page up. */
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */ /* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } >ram
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } >ram
/* Thread Local Storage sections */ /* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } >ram
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } >ram
.preinit_array : .preinit_array :
{ {
PROVIDE_HIDDEN (__preinit_array_start = .); PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .); PROVIDE_HIDDEN (__preinit_array_end = .);
} } >ram
.init_array : .init_array :
{ {
PROVIDE_HIDDEN (__init_array_start = .); PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*))) KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array)) KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .); PROVIDE_HIDDEN (__init_array_end = .);
} } >ram
.fini_array : .fini_array :
{ {
PROVIDE_HIDDEN (__fini_array_start = .); PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array)) KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*))) KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .); PROVIDE_HIDDEN (__fini_array_end = .);
} } >ram
.ctors : .ctors :
{ {
/* gcc uses crtbegin.o to find the start of /* gcc uses crtbegin.o to find the start of
@@ -101,7 +104,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*))) KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
} } >ram
.dtors : .dtors :
{ {
KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin.o(.dtors))
@@ -109,18 +112,18 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
} } >ram
.jcr : { KEEP (*(.jcr)) } .jcr : { KEEP (*(.jcr)) } >ram
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } >ram
. = DATA_SEGMENT_RELRO_END (0, .); . = DATA_SEGMENT_RELRO_END (0, .);
.data : .data :
{ {
_fdata = . ; _fdata = . ;
*(.data .data.* .gnu.linkonce.d.*) *(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
} } >ram
.data1 : { *(.data1) } .data1 : { *(.data1) } >ram
.got.plt : { *(.got.plt) } .got.plt : { *(.got.plt) } >ram
. = .; . = .;
_gp = ALIGN(16) + 0x7ff0; _gp = ALIGN(16) + 0x7ff0;
.got : { *(.got) } .got : { *(.got) }
@@ -130,9 +133,9 @@ SECTIONS
.sdata : .sdata :
{ {
*(.sdata .sdata.* .gnu.linkonce.s.*) *(.sdata .sdata.* .gnu.linkonce.s.*)
} } >ram
.lit8 : { *(.lit8) } .lit8 : { *(.lit8) } >ram
.lit4 : { *(.lit4) } .lit4 : { *(.lit4) } >ram
_edata = .; PROVIDE (edata = .); _edata = .; PROVIDE (edata = .);
__bss_start = .; __bss_start = .;
_fbss = .; _fbss = .;
@@ -141,7 +144,7 @@ SECTIONS
*(.dynsbss) *(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*) *(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon) *(.scommon)
} } >ram
.bss : .bss :
{ {
*(.dynbss) *(.dynbss)
@@ -153,7 +156,7 @@ SECTIONS
FIXME: Why do we need it? When there is no .bss section, we don't FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */ pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1); . = ALIGN(. != 0 ? 32 / 8 : 1);
} } >ram
. = ALIGN(32 / 8); . = ALIGN(32 / 8);
. = ALIGN(32 / 8); . = ALIGN(32 / 8);
_end = .; PROVIDE (end = .); _end = .; PROVIDE (end = .);