Fix the linker scripts again

This commit is contained in:
TuxSH 2018-05-25 23:59:17 +02:00
parent 35ad240018
commit a65f7fbf88
2 changed files with 40 additions and 44 deletions

View File

@ -4,6 +4,11 @@ ENTRY(_start)
/* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */ /* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
PHDRS
{
main PT_LOAD;
}
SECTIONS SECTIONS
{ {
PROVIDE(__start__ = 0x1FF80000); PROVIDE(__start__ = 0x1FF80000);
@ -11,19 +16,11 @@ SECTIONS
PROVIDE(__stack_bottom__ = 0x1FFFD000); PROVIDE(__stack_bottom__ = 0x1FFFD000);
. = __start__; . = __start__;
. = ALIGN(32);
.crt0 :
{
. = ALIGN(32);
KEEP( *(.text.start) )
KEEP( *(.init) )
. = ALIGN(4);
}
.text : .text :
{ {
. = ALIGN(4); KEEP( *(.text.start) )
KEEP( *(.init) )
/* .text */ /* .text */
*(.text) *(.text)
@ -33,12 +30,11 @@ SECTIONS
*(.stub) *(.stub)
*(.gnu.warning) *(.gnu.warning)
*(.gnu.linkonce.t*) *(.gnu.linkonce.t*)
. = ALIGN(4);
/* .fini */ /* .fini */
KEEP( *(.fini) ) KEEP( *(.fini) )
. = ALIGN(4); . = ALIGN(32);
} } :main
.rodata : .rodata :
{ {
@ -48,17 +44,17 @@ SECTIONS
*all.rodata*(*) *all.rodata*(*)
*(.gnu.linkonce.r*) *(.gnu.linkonce.r*)
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
. = ALIGN(4); . = ALIGN(8);
} }
.preinit_array ALIGN(4) : .preinit_array :
{ {
PROVIDE (__preinit_array_start = .); PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(.preinit_array))
PROVIDE (__preinit_array_end = .); PROVIDE (__preinit_array_end = .);
} }
.init_array ALIGN(4) : .init_array :
{ {
PROVIDE (__init_array_start = .); PROVIDE (__init_array_start = .);
KEEP (*(SORT(.init_array.*))) KEEP (*(SORT(.init_array.*)))
@ -66,7 +62,7 @@ SECTIONS
PROVIDE (__init_array_end = .); PROVIDE (__init_array_end = .);
} }
.fini_array ALIGN(4) : .fini_array :
{ {
PROVIDE (__fini_array_start = .); PROVIDE (__fini_array_start = .);
KEEP (*(.fini_array)) KEEP (*(.fini_array))
@ -74,26 +70,26 @@ SECTIONS
PROVIDE (__fini_array_end = .); PROVIDE (__fini_array_end = .);
} }
.ctors ALIGN(4) : .ctors :
{ {
KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */ KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*))) KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} }
.dtors ALIGN(4) : .dtors :
{ {
KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} }
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = .;}
__exidx_start = .; ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = .;}
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
__exidx_end = .;
.data : .data :
{ {
@ -102,10 +98,10 @@ SECTIONS
KEEP (*(.large_patch*)) KEEP (*(.large_patch*))
*(.gnu.linkonce.d*) *(.gnu.linkonce.d*)
CONSTRUCTORS CONSTRUCTORS
. = ALIGN(4); . = ALIGN(32);
} }
.bss : .bss (NOLOAD) :
{ {
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__bss_start__ = ABSOLUTE(.)); PROVIDE (__bss_start__ = ABSOLUTE(.));
@ -116,7 +112,8 @@ SECTIONS
*(COMMON) *(COMMON)
. = ALIGN(8); . = ALIGN(8);
PROVIDE (__bss_end__ = ABSOLUTE(.)); PROVIDE (__bss_end__ = ABSOLUTE(.));
} } :NONE
PROVIDE (__end__ = ABSOLUTE(.)); PROVIDE (__end__ = ABSOLUTE(.));
/* ================== /* ==================

View File

@ -4,15 +4,14 @@ ENTRY(_start)
PHDRS PHDRS
{ {
crt0 PT_LOAD; crt0 PT_LOAD;
itcm PT_LOAD; itcm PT_LOAD;
main PT_LOAD; main PT_LOAD;
} }
/* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */ /* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY MEMORY
{ {
NULL : ORIGIN = 0x00000000, LENGTH = 0x1000
main : ORIGIN = 0x08006000, LENGTH = 0x080F0000 - 0x08006000 main : ORIGIN = 0x08006000, LENGTH = 0x080F0000 - 0x08006000
itcm : ORIGIN = 0x01FF8000, LENGTH = 0x01FFB800 - 0x01FF8000 /* Unused ITCM slice. */ itcm : ORIGIN = 0x01FF8000, LENGTH = 0x01FFB800 - 0x01FF8000 /* Unused ITCM slice. */
} }
@ -57,19 +56,20 @@ SECTIONS
chainloader.o(.data*) chainloader.o(.data*)
i2c.o(.data*) i2c.o(.data*)
arm9_exception_handlers.o(.data*) arm9_exception_handlers.o(.data*)
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__itcm_bss_start__ = ABSOLUTE(.));
} >itcm AT>main :itcm } >itcm AT>main :itcm
.itcm_bss __itcm_bss_start__ (NOLOAD) : .itcm_bss (NOLOAD) :
{ {
. = ALIGN(32);
PROVIDE (__itcm_bss_start__ = ABSOLUTE(.));
*(.arm9_exception_handlers.bss*) *(.arm9_exception_handlers.bss*)
chainloader.o(.bss* COMMON) chainloader.o(.bss* COMMON)
i2c.o(.bss* COMMON) i2c.o(.bss* COMMON)
arm9_exception_handlers.o(.bss* COMMON) arm9_exception_handlers.o(.bss* COMMON)
. = ALIGN(8); . = ALIGN(32);
PROVIDE (__itcm_end__ = .); PROVIDE (__itcm_end__ = ABSOLUTE(.));
} >itcm :NONE } >itcm :NONE
.text : .text :
@ -82,11 +82,10 @@ SECTIONS
*(.stub) *(.stub)
*(.gnu.warning) *(.gnu.warning)
*(.gnu.linkonce.t*) *(.gnu.linkonce.t*)
. = ALIGN(4);
/* .fini */ /* .fini */
KEEP( *(.fini) ) KEEP( *(.fini) )
. = ALIGN(4); . = ALIGN(8);
} >main :main } >main :main
.rodata : .rodata :
@ -97,10 +96,10 @@ SECTIONS
*all.rodata*(*) *all.rodata*(*)
*(.gnu.linkonce.r*) *(.gnu.linkonce.r*)
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
. = ALIGN(4); . = ALIGN(8);
} >main } >main
.preinit_array ALIGN(4) : .preinit_array :
{ {
PROVIDE (__preinit_array_start = .); PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(.preinit_array))
@ -129,6 +128,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*))) KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.dtors ALIGN(4) : .dtors ALIGN(4) :
@ -137,12 +137,11 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = ABSOLUTE(.);} >main
__exidx_start = .; ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = ABSOLUTE(.);} >main
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.data : .data :
{ {
@ -151,7 +150,7 @@ SECTIONS
KEEP (*(.large_patch*)) KEEP (*(.large_patch*))
*(.gnu.linkonce.d*) *(.gnu.linkonce.d*)
CONSTRUCTORS CONSTRUCTORS
. = ALIGN(4); . = ALIGN(32);
} >main } >main
.bss (NOLOAD) : .bss (NOLOAD) :