99 lines
2.1 KiB
Plaintext
99 lines
2.1 KiB
Plaintext
/*
|
|
Linker script for the dynamic version of Vhex (fxcg50)
|
|
*/
|
|
|
|
OUTPUT_FORMAT("elf32-sh", "elf32-sh", "elf32-sh")
|
|
OUTPUT_ARCH(sh4)
|
|
ENTRY(_main)
|
|
|
|
|
|
/*
|
|
** Linker script for user executables.
|
|
*/
|
|
MEMORY
|
|
{
|
|
/* virtual memory, read-write segment */
|
|
userram (WX) : o = 0x00000000, l = 1M
|
|
}
|
|
|
|
SECTIONS
|
|
{ /* Code */
|
|
.text : {
|
|
*(.text);
|
|
*(.text.*);
|
|
|
|
_bctors = . ;
|
|
*(.ctors .ctors.*)
|
|
_ectors = . ;
|
|
|
|
_bdtors = . ;
|
|
*(.dtors .dtors.*)
|
|
_edtors = . ;
|
|
|
|
} > userram
|
|
|
|
/* Read-only sections */
|
|
.rodata : {
|
|
/* Read-Only data */
|
|
*(.rodata);
|
|
*(.rodata.*);
|
|
} > userram
|
|
|
|
|
|
/* The GOT section is a bit exotic.
|
|
When I generate the PIE executable, all global variables are stored
|
|
is the *(.got) section and the __GLOBAL_OFFSET_TABLE__ object is
|
|
generated and inserted in the *(.got.plt) section.
|
|
|
|
But, neither of *(.plt*) or *(rela*) section are generated to help
|
|
me out for the "relocation" of each address stored in the GOT. The
|
|
result is that the content of the GOT is always absolute addresses,
|
|
which makes the machine crash.
|
|
|
|
So, the idea to bypass this limitation (probably due to the custom
|
|
GCC which not provide critical information for the relocation) is to
|
|
isolate the GOT in a standalone section and, after the loading of
|
|
the image, walk thought the relocalised table and manually patch
|
|
each address.
|
|
|
|
Moreover, the __GLOBAL_OFFSET_TABLE__ is used like a table, so, the
|
|
section ".got.plt" SHOULD be before the .got section. */
|
|
.got.plt : { *(.got.plt) *(.igot.plt) *(.igot) }
|
|
.got : { *(.got) }
|
|
|
|
/* readable / writable data */
|
|
.data ALIGN(4) : {
|
|
*(.data);
|
|
*(.data.*);
|
|
*(COMMON);
|
|
}
|
|
|
|
/* bss section included to avoid missaligned segment */
|
|
.bss ALIGN(4) : {
|
|
*(.bss);
|
|
*(.bss.*);
|
|
|
|
/* dynamic BSS information (move me ?) */
|
|
*(.dynbss)
|
|
} > userram
|
|
|
|
/* unwanted section */
|
|
/DISCARD/ : {
|
|
*(.rela.debug*)
|
|
*(.gnu.*)
|
|
*(.debug_info)
|
|
*(.debug_abbrev)
|
|
*(.debug_loc)
|
|
*(.debug_aranges)
|
|
*(.debug_ranges)
|
|
*(.debug_line)
|
|
*(.debug_str)
|
|
*(.debug_*)
|
|
*(.jcr)
|
|
*(.eh_frame_hdr)
|
|
*(.eh_frame)
|
|
*(.comment)
|
|
*(.interp)
|
|
}
|
|
}
|