Linker scripts & _init, _fini
Derick Hammond
derick at perkinstechnologies.com.au
Tue Jul 15 23:06:34 UTC 2003
Hi Aaron:
The .ctors and .dtors section are being placed in the .text section in the
SECTIONS portion of my linker script. The .text section is being placed
into the bootrom region defined in the linkers MEMORY section.
For clarification I have attached a copy of one of my linker scripts that
produces the output.
Nothing is failing in the program so far, probably due to not using C++
code yet. However, I picked this up in an inspection of the listing, and
thought that it was strange.
Thanks in advance.
Regards,
Derick Hammond
At 03:16 PM 15/07/2003 -0700, Aaron J. Grier wrote:
>On Tue, Jul 15, 2003 at 06:14:02PM +1000, Derick Hammond wrote:
> > It seems to me that the jsr fff00b0c <__do_global_ctors_aux> is
> > unreachable code. Is this correct? If so how do I correct the
> > problem?
>
>first is to figure out if it's really a problem or not. only you know
>the memory map of your device.
>
>what regions does the MEMORY section of your script define, and in the
>SECTIONS section, where are .ctors and .dtors sections being placed?
>
>--
> Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
--- Start of spsize.ld
/*
** Specify that the output is to be elf32-m68k regardless of what
** the native object format is.
*/
OUTPUT_FORMAT(elf32-m68k)
/*
** Declare size of Heap
** A Heap size of 0 means: use all available memory for the heap.
*/
_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x0;
/*
** Set the size of the starting stack used during initialisation
** until the first task switch. After that point, task stacks
** allocated by RTEMS are used.
*/
StackSize = DEFINED(StackSize) ? StackSize : 8K;
/*
** System Clock Frequency.
*/
_SYS_CLOCK_FREQUENCY = 36864000;
/*
** Assign space to common symbols even if a relocatable output
** file is specified.
*/
FORCE_COMMON_ALLOCATION
/*
** Starting addresses and length of RAM, ROM, and FLASH
**
** The addresses must be valid addresses on the board. The Chip
** Selects should be initialised such that the codes addresses
** are valid.
*/
MEMORY
{
ram (w) : ORIGIN = 0x00000000, LENGTH = 128K
rambar (w) : ORIGIN = 0x00020000, LENGTH = 8K
mbar (w) : ORIGIN = 0x10000000, LENGTH = 1K
rtc (w) : ORIGIN = 0x20000000, LENGTH = 64K
canbus (w) : ORIGIN = 0x30000000, LENGTH = 64K
ethernet (w) : ORIGIN = 0x40000000, LENGTH = 64K
nvram (w) : ORIGIN = 0x50000000, LENGTH = 2M
compactflash (w) : ORIGIN = 0x60000000, LENGTH = 64K
prog_flash (rx) : ORIGIN = 0xF0000000, LENGTH = 8M
bootrom (rx) : ORIGIN = 0xFFF00000, LENGTH = 512K
}
/*
** This is for the network driver. See the RTEMS Networking
** documentation for more details.
*/
ETHERNET_ADDRESS = 0x40000000;
/*
** Interrupt Vector table is oocated at start of external static
** RAM.
*/
_VBR = 0x00000000;
/*
** The following defines the order in which the sections should
** go. It also defines a number of variables which can be used
** by the application program.
**
** NOTE: Each variable appears with 1 or 2 leading underscorses
** to ensure that the variable is accessible from C code
** with a single underscore. Some object formats
** automatically add a leading underscore to all C global
** symbols.
*/
SECTIONS
{
/*
** Boot ROM - Set the RomBase variable to the start of the ROM.
*/
bootrom :
{
_RomBase = .;
__RomBase = .;
} >bootrom
/*
** RAM - Set the RamBase variable to the start of the RAM.
*/
ram :
{
_RamBase = .;
__RamBase = .;
} >ram
/*
** Text (code) goes into ROM.
*/
.text :
{
ROM_PADDR = .;
ROMVECS_PADDR = .;
*(DV_ROMVECS)
ROMVECS_PEND = .;
BOOTINIT_PADDR = .;
*(DV_BOOTINIT)
BOOTINIT_PEND = .;
BOOTCRC32_PADDR = .;
*(DV_BOOTCRC32)
BOOTCRC32_PEND = .;
LEAD_PADDR = .;
*(DV_LEAD)
*(.text)
/*
** C++ constructors/destructors
*/
*(.gnu.linkonce.t.*)
/*
** Initialization and finalization code.
*/
. = ALIGN (16);
PROVIDE (_init = .);
*crti.o(.init)
*(.init)
*crtn.o(.init)
. = ALIGN (16);
PROVIDE (_fini = .);
*crti.o(.fini)
*(.fini)
*crtn.o(.fini)
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
/*
** C++ constructors/destructors
*/
. = ALIGN (16);
*crtbegin.o(.ctors)
*(.ctors)
*crtend.o(.ctors)
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
/*
** Exception frame info
*/
. = ALIGN (16);
*(.eh_frame)
/*
** Read-only data
*/
. = ALIGN (16);
_rodata_start = .;
*(.rodata*)
*(.gnu.linkonce.r*)
/*
** Declares where the .text section ends.
*/
. = ALIGN (16);
PROVIDE (_etext = .);
} >bootrom
/*
** Vector section reserve some room for the Vector Table, 256
** vectors of 4 bytes.
*/
.vector :
{
M68Kvec = .;
_M68Kvec = .;
. += (256 * 4);
} >ram
/*
** Data section is linked for base address of 0x00000400, but
** loaded in the Boot ROM after the .text section.
*/
SRAM_PADDR = 0x00000000;
.data : AT (LOADADDR(.text) + SIZEOF(.text))
{
copy_start = .;
. = ALIGN (0x10);
*(.shdata);
. = ALIGN (0x10);
*(.data);
. = ALIGN (0x10);
*(.gcc_exc);
*(.gcc_except_table);
*(.jcr);
. = ALIGN (0x10);
*(.gnu.linkonce.d*)
. = ALIGN (0x10);
_edata = .;
copy_end = .;
} >ram
/*
** BSS section is linked after the .data section, and makes
** _bstart and _bend symbols available for Boot Code to zero
** section.
*/
.bss BLOCK (0x4) :
{
clear_start = .;
*(.shbss);
*(.bss);
*(COMMON);
. = ALIGN (16);
_end = .;
clear_end = .;
/*
** The RTEMS Executive Workspace goes here. RTEMS allocates
** tasks, stacks, semaphores, etc. from this memory.
*/
_WorkspaceBase = .;
__WorkspaceBase = .;
} >ram
SRAM_PEND = 0x00020000;
rambarsec 0x00020000 :
{
RAMBAR_PADDR = .;
/*
** The Starting Stack goes after the Application Heap.
** M68K stack grows down so start at high address.
*/
. += StackSize;
. = ALIGN (16);
stack_init = .;
RAMBAR_PEND = .;
} >rambar
mbarsec 0x10000000 :
{
MBAR_PADDR = .;
} >mbar
rtcsec 0x20000000 :
{
RTC_PADDR = .;
} >rtc
canbussec 0x30000000 :
{
CANBUS_PADDR = .;
} >canbus
ethernetsec 0x40000000 :
{
ETHERNET_PADDR = .;
} >ethernet
nvramsec 0x50000000 :
{
NVRAM_PADDR = .;
} >nvram
compactflash 0x60000000 :
{
CF_CARD_PADDR = .;
} >compactflash
prog_flash_sec 0xF0000000 :
{
PROG_FLASH_PADDR = .;
} >prog_flash
/*
** Tail section is linked after the ROMed .data section. This
** section contains the 'END OF FIRMWARE' marker, and Firmware
** CRC-32.
*/
.tail (ADDR(.text) + SIZEOF(.text) + SIZEOF(.data)) :
{
*(DV_TAIL);
FW_CRC32_PADDR = .;
*(DV_CRC32);
} >bootrom
}
ENTRY(start);
SEARCH_DIR( /home/derickh/cvs_wa/DataVault_Firmware/firmware/../library/core )
SEARCH_DIR(
/home/derickh/cvs_wa/DataVault_Firmware/firmware/../library/rom_objs )
SEARCH_DIR(
/home/derickh/cvs_wa/DataVault_Firmware/firmware/../library/static )
SEARCH_DIR(
/home/derickh/cvs_wa/DataVault_Firmware/firmware/../library/support )
SEARCH_DIR( /opt/rtems/m68k-rtems/lib/m5200 )
SEARCH_DIR( /opt/rtems/lib/gcc-lib/m68k-rtems/3.2.2/m5200 )
SEARCH_DIR(
/home/derickh/cvs_wa/DataVault_Firmware/devtools/rtems/m68k-rtems/lib/m5200 )
GROUP
(
crti.o
crtbegin.o
crtn.o
crtend.o
lead.o
reset.o
tail.o
librom_start.a
libconsole.a
libtod.a
libclock.a
libspsize.a
no-dpmem.rel
no-msg.rel
no-mp.rel
no-part.rel
no-signal.rel
no-timer.rel
no-rtmon.rel
librtemscpu.a
libc.a
libgcc.a
)
--- End of spsize.ld
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20030716/396a1bde/attachment-0001.html>
More information about the users
mailing list