From 5d81ce9b3d3eebde9e48944e94bbc51ef5c58d21 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 18 Nov 2002 00:52:17 +0000 Subject: 2002-11-14 Greg Menke * bsp_specs: Added crtbegin,crtend objects so C++ global objects constructors/destructors run correctly. * startup/linkcmds: Increased code length and updated the ctor/dtor sections to handle crtbegin, crtend objects. > --- .../lib/libbsp/powerpc/motorola_powerpc/ChangeLog | 7 +++ .../lib/libbsp/powerpc/motorola_powerpc/bsp_specs | 6 +- .../powerpc/motorola_powerpc/startup/linkcmds | 67 ++++++++++++++++++++-- 3 files changed, 74 insertions(+), 6 deletions(-) (limited to 'c/src/lib/libbsp') diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog index d8446a6bce..7a417911ac 100644 --- a/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog +++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog @@ -1,3 +1,10 @@ +2002-11-14 Greg Menke + + * bsp_specs: Added crtbegin,crtend objects so C++ global objects + constructors/destructors run correctly. + * startup/linkcmds: Increased code length and updated the ctor/dtor + sections to handle crtbegin, crtend objects. +> 2002-10-21 Ralf Corsepius * .cvsignore: Reformat. diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/bsp_specs b/c/src/lib/libbsp/powerpc/motorola_powerpc/bsp_specs index 6d313f02f3..299fef913f 100644 --- a/c/src/lib/libbsp/powerpc/motorola_powerpc/bsp_specs +++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/bsp_specs @@ -10,14 +10,16 @@ *lib: %{!qrtems: %(old_lib)} %{!nostdlib: %{qrtems: --start-group \ %{!qrtems_debug: -lrtemsbsp -lrtemscpu} %{qrtems_debug: -lrtemsbsp_g -lrtemscpu_g} \ --lc -lgcc --end-group ecrtn%O%s \ +-lc -lgcc --end-group \ %{!qnolinkcmds: -T linkcmds%s}}} *startfile: -%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: ecrti%O%s \ +%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: ecrti%O%s crtbegin.o%s \ %{!qrtems_debug: start.o%s} \ %{qrtems_debug: start_g.o%s}}} *link: %{!qrtems: %(old_link)} %{qrtems: -Qy -dp -Bstatic -e __rtems_entry_point -u __vectors} +*endfile: +%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s ecrtn.o%s} diff --git a/c/src/lib/libbsp/powerpc/motorola_powerpc/startup/linkcmds b/c/src/lib/libbsp/powerpc/motorola_powerpc/startup/linkcmds index bd7e2a6fd7..93a78b06be 100644 --- a/c/src/lib/libbsp/powerpc/motorola_powerpc/startup/linkcmds +++ b/c/src/lib/libbsp/powerpc/motorola_powerpc/startup/linkcmds @@ -7,7 +7,7 @@ ENTRY(_start) PROVIDE (__stack = 0); MEMORY { VECTORS : ORIGIN = 0x0 , LENGTH = 0x3000 - CODE : ORIGIN = 0x3000 , LENGTH = 0x100000 + CODE : ORIGIN = 0x3000 , LENGTH = 0x200000 } SECTIONS { @@ -59,13 +59,32 @@ SECTIONS *(.gnu.warning) *(.gnu.linkonce.t*) } > CODE - .init : { _init = .; *(.init) } >CODE - .fini : { _fini = .; *(.fini) } >CODE + .init : { _init = .; KEEP(*(.init)) } >CODE + .fini : { _fini = .; KEEP(*(.fini)) } >CODE .rodata : { *(.rodata*) *(.gnu.linkonce.r*) } > CODE .rodata1 : { *(.rodata1) } > CODE .eh_frame : { *.(eh_frame) } >CODE _etext = .; PROVIDE (etext = .); + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(0x10000) + (. & (0x10000 - 1)); + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } >CODE + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } >CODE + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } >CODE + PROVIDE (__fini_array_end = .); + .sdata2 : { *(.sdata2) *(.gnu.linkonce.s2.*) } >CODE .sbss2 : { *(.sbss2) *(.gnu.linkonce.sb2.*) } >CODE /* Adjust the address for the data segment. We want to adjust up to @@ -87,7 +106,7 @@ SECTIONS { *(.data) *(.gnu.linkonce.d*) - CONSTRUCTORS + SORT(CONSTRUCTORS) } > CODE .data1 : { *(.data1) } > CODE PROVIDE (__EXCEPT_START__ = .); @@ -100,20 +119,60 @@ SECTIONS The current compiler no longer needs this, but keep it around for 2.7.2 */ PROVIDE (_GOT2_START_ = .); .got2 : { *(.got2) } > CODE + + +/* removed 11/14, gregm PROVIDE (__CTOR_LIST__ = .); .ctors : { *(.ctors) } > CODE PROVIDE (__CTOR_END__ = .); PROVIDE (__DTOR_LIST__ = .); .dtors : { *(.dtors) } > CODE PROVIDE (__DTOR_END__ = .); +*/ + + + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } > CODE + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } > CODE + + PROVIDE (_FIXUP_START_ = .); .fixup : { *(.fixup) } > CODE PROVIDE (_FIXUP_END_ = .); PROVIDE (_GOT2_END_ = .); PROVIDE (_GOT_START_ = .); + .got : { *(.got) } > CODE .got.plt : { *(.got.plt) } > CODE + PROVIDE (_GOT_END_ = .); + + .jcr : { KEEP (*(.jcr)) } > CODE + /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ -- cgit v1.2.3