2005-04-08 17:01:17 +02:00
|
|
|
/* -*- sh -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Linker script for i386 images
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
|
|
|
|
OUTPUT_ARCH ( i386 )
|
|
|
|
ENTRY ( _entry )
|
|
|
|
|
|
|
|
SECTIONS {
|
|
|
|
|
|
|
|
/* All sections in the resulting file have consecutive load
|
|
|
|
* addresses, but may have individual link addresses depending on
|
|
|
|
* the memory model being used.
|
|
|
|
*
|
2006-08-24 15:18:05 +02:00
|
|
|
* The linker symbols _{prefix,textdata}_link_addr, load_addr, and
|
2006-05-02 17:41:21 +02:00
|
|
|
* _max_align may be specified explicitly. If not specified, they
|
|
|
|
* will default to:
|
2005-04-08 17:01:17 +02:00
|
|
|
*
|
|
|
|
* _prefix_link_addr = 0
|
2006-05-02 22:51:07 +02:00
|
|
|
* _textdata_link_addr = 0
|
2005-04-08 17:01:17 +02:00
|
|
|
* _load_addr = 0
|
|
|
|
* _max_align = 16
|
|
|
|
*
|
|
|
|
* We guarantee alignment of virtual addresses to any alignment
|
|
|
|
* specified by the constituent object files (e.g. via
|
|
|
|
* __attribute__((aligned(x)))). Load addresses are guaranteed
|
|
|
|
* only up to _max_align. Provided that all loader and relocation
|
|
|
|
* code honours _max_align, this means that physical addresses are
|
|
|
|
* also guaranteed up to _max_align.
|
|
|
|
*
|
|
|
|
* Note that when using -DKEEP_IT_REAL, the UNDI segments are only
|
|
|
|
* guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
|
|
|
|
* alignment). Using _max_align>16 will therefore not guarantee
|
|
|
|
* >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
|
|
|
|
* used (though virtual addresses will still be fully aligned).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The prefix
|
|
|
|
*/
|
|
|
|
|
|
|
|
_prefix_link_addr = DEFINED ( _prefix_link_addr ) ? _prefix_link_addr : 0;
|
|
|
|
. = _prefix_link_addr;
|
|
|
|
_prefix = .;
|
|
|
|
|
|
|
|
.prefix : AT ( _prefix_load_offset + __prefix ) {
|
|
|
|
__prefix = .;
|
|
|
|
_entry = .;
|
|
|
|
*(.prefix)
|
|
|
|
*(.prefix.*)
|
2006-05-02 17:41:21 +02:00
|
|
|
_eprefix_progbits = .;
|
2005-04-08 17:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_eprefix = .;
|
|
|
|
|
|
|
|
/*
|
2006-05-02 17:41:21 +02:00
|
|
|
* The 16-bit sections, if present
|
2005-04-08 17:01:17 +02:00
|
|
|
*/
|
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
_text16_link_addr = 0;
|
|
|
|
. = _text16_link_addr;
|
|
|
|
_text16 = .;
|
|
|
|
|
2006-12-20 21:28:20 +01:00
|
|
|
. += 1; /* Prevent NULL being valid */
|
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
.text16 : AT ( _text16_load_offset + __text16 ) {
|
|
|
|
__text16 = .;
|
|
|
|
*(.text16)
|
|
|
|
*(.text16.*)
|
|
|
|
_etext16_progbits = .;
|
|
|
|
} = 0x9090
|
|
|
|
|
|
|
|
_etext16 = .;
|
|
|
|
|
|
|
|
_data16_link_addr = 0;
|
|
|
|
. = _data16_link_addr;
|
|
|
|
_data16 = .;
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2006-12-20 21:28:20 +01:00
|
|
|
. += 1; /* Prevent NULL being valid */
|
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
.rodata16 : AT ( _data16_load_offset + __rodata16 ) {
|
|
|
|
__rodata16 = .;
|
|
|
|
*(.rodata16)
|
|
|
|
*(.rodata16.*)
|
|
|
|
}
|
|
|
|
.data16 : AT ( _data16_load_offset + __data16 ) {
|
|
|
|
__data16 = .;
|
|
|
|
*(.data16)
|
|
|
|
*(.data16.*)
|
|
|
|
_edata16_progbits = .;
|
|
|
|
}
|
|
|
|
.bss16 : AT ( _data16_load_offset + __bss16 ) {
|
|
|
|
__bss16 = .;
|
|
|
|
_bss16 = .;
|
|
|
|
*(.bss16)
|
|
|
|
*(.bss16.*)
|
|
|
|
_ebss16 = .;
|
|
|
|
}
|
|
|
|
.stack16 : AT ( _data16_load_offset + __stack16 ) {
|
|
|
|
__stack16 = .;
|
|
|
|
*(.stack16)
|
|
|
|
*(.stack16.*)
|
2005-04-08 17:01:17 +02:00
|
|
|
}
|
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
_edata16 = .;
|
2005-04-08 17:01:17 +02:00
|
|
|
|
|
|
|
/*
|
2006-05-02 17:41:21 +02:00
|
|
|
* The 32-bit sections
|
2005-04-08 17:01:17 +02:00
|
|
|
*/
|
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
_textdata_link_addr = ( DEFINED ( _textdata_link_addr ) ?
|
|
|
|
_textdata_link_addr : 0 );
|
|
|
|
. = _textdata_link_addr;
|
|
|
|
_textdata = .;
|
|
|
|
|
2005-04-08 17:01:17 +02:00
|
|
|
_text = .;
|
|
|
|
|
2006-12-20 21:28:20 +01:00
|
|
|
. += 1; /* Prevent NULL being valid */
|
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
.text : AT ( _textdata_load_offset + __text ) {
|
2005-04-08 17:01:17 +02:00
|
|
|
__text = .;
|
2006-06-11 03:48:29 +02:00
|
|
|
*(.text.null_trap)
|
2005-04-08 17:01:17 +02:00
|
|
|
*(.text)
|
|
|
|
*(.text.*)
|
|
|
|
} = 0x9090
|
|
|
|
|
|
|
|
_etext = .;
|
|
|
|
|
|
|
|
_data = .;
|
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
.rodata : AT ( _textdata_load_offset + __rodata ) {
|
2005-04-08 17:01:17 +02:00
|
|
|
__rodata = .;
|
|
|
|
*(.rodata)
|
|
|
|
*(.rodata.*)
|
|
|
|
}
|
2006-05-02 22:51:07 +02:00
|
|
|
.data : AT ( _textdata_load_offset + __data ) {
|
2005-04-08 17:01:17 +02:00
|
|
|
__data = .;
|
|
|
|
*(.data)
|
|
|
|
*(.data.*)
|
2005-04-27 14:24:38 +02:00
|
|
|
*(SORT(.tbl.*)) /* Various tables. See include/tables.h */
|
2006-05-02 22:51:07 +02:00
|
|
|
_etextdata_progbits = .;
|
2005-04-08 17:01:17 +02:00
|
|
|
}
|
2006-05-02 22:51:07 +02:00
|
|
|
.bss : AT ( _textdata_load_offset + __bss ) {
|
2005-04-08 17:01:17 +02:00
|
|
|
__bss = .;
|
|
|
|
_bss = .;
|
|
|
|
*(.bss)
|
|
|
|
*(.bss.*)
|
|
|
|
*(COMMON)
|
|
|
|
_ebss = .;
|
|
|
|
}
|
2006-05-02 22:51:07 +02:00
|
|
|
.stack : AT ( _textdata_load_offset + __stack ) {
|
2005-04-08 17:01:17 +02:00
|
|
|
__stack = .;
|
|
|
|
*(.stack)
|
|
|
|
*(.stack.*)
|
|
|
|
}
|
|
|
|
|
|
|
|
_edata = .;
|
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
_etextdata = .;
|
|
|
|
|
2005-04-08 17:01:17 +02:00
|
|
|
_end = .;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dispose of the comment and note sections to make the link map
|
|
|
|
* easier to read
|
|
|
|
*/
|
|
|
|
|
|
|
|
/DISCARD/ : {
|
|
|
|
*(.comment)
|
|
|
|
*(.note)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load address calculations. The slightly obscure nature of the
|
|
|
|
* calculations is because ALIGN(x) can only operate on the
|
|
|
|
* location counter.
|
|
|
|
*/
|
|
|
|
|
|
|
|
_max_align = DEFINED ( _max_align ) ? _max_align : 16;
|
|
|
|
_load_addr = DEFINED ( _load_addr ) ? _load_addr : 0;
|
|
|
|
|
|
|
|
. = _load_addr;
|
|
|
|
|
|
|
|
. -= _prefix_link_addr;
|
|
|
|
_prefix_load_offset = ALIGN ( _max_align );
|
|
|
|
_prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
|
|
|
|
_prefix_size = _eprefix - _prefix;
|
2006-05-02 17:41:21 +02:00
|
|
|
_prefix_progbits_size = _eprefix_progbits - _prefix;
|
|
|
|
. = _prefix_load_addr + _prefix_progbits_size;
|
|
|
|
|
|
|
|
. -= _text16_link_addr;
|
|
|
|
_text16_load_offset = ALIGN ( _max_align );
|
|
|
|
_text16_load_addr = _text16_link_addr + _text16_load_offset;
|
|
|
|
_text16_size = _etext16 - _text16;
|
|
|
|
_text16_progbits_size = _etext16_progbits - _text16;
|
|
|
|
. = _text16_load_addr + _text16_progbits_size;
|
|
|
|
|
|
|
|
. -= _data16_link_addr;
|
|
|
|
_data16_load_offset = ALIGN ( _max_align );
|
|
|
|
_data16_load_addr = _data16_link_addr + _data16_load_offset;
|
|
|
|
_data16_size = _edata16 - _data16;
|
|
|
|
_data16_progbits_size = _edata16_progbits - _data16;
|
|
|
|
. = _data16_load_addr + _data16_progbits_size;
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
. -= _textdata_link_addr;
|
|
|
|
_textdata_load_offset = ALIGN ( _max_align );
|
|
|
|
_textdata_load_addr = _textdata_link_addr + _textdata_load_offset;
|
|
|
|
_textdata_size = _etextdata - _textdata;
|
|
|
|
_textdata_progbits_size = _etextdata_progbits - _textdata;
|
|
|
|
. = _textdata_load_addr + _textdata_progbits_size;
|
2006-05-02 17:41:21 +02:00
|
|
|
|
|
|
|
_load_size = . - _load_addr;
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2007-07-15 03:52:02 +02:00
|
|
|
_payload_offset = _text16_load_offset;
|
|
|
|
|
2005-04-08 17:01:17 +02:00
|
|
|
/*
|
|
|
|
* Alignment checks. ALIGN() can only operate on the location
|
|
|
|
* counter, so we set the location counter to each value we want
|
|
|
|
* to check.
|
|
|
|
*/
|
|
|
|
|
|
|
|
. = _prefix_load_addr - _prefix_link_addr;
|
|
|
|
_assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
|
|
|
"_prefix is badly aligned" );
|
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
. = _text16_load_addr - _text16_link_addr;
|
2005-04-08 17:01:17 +02:00
|
|
|
_assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
2006-05-02 17:41:21 +02:00
|
|
|
"_text16 is badly aligned" );
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2006-05-02 17:41:21 +02:00
|
|
|
. = _data16_load_addr - _data16_link_addr;
|
2005-04-08 17:01:17 +02:00
|
|
|
_assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
2006-05-02 17:41:21 +02:00
|
|
|
"_data16 is badly aligned" );
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2006-05-02 22:51:07 +02:00
|
|
|
. = _textdata_load_addr - _textdata_link_addr;
|
2005-04-08 17:01:17 +02:00
|
|
|
_assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
2006-05-02 17:41:21 +02:00
|
|
|
"_text is badly aligned" );
|
2005-04-08 17:01:17 +02:00
|
|
|
|
|
|
|
/*
|
2006-05-02 17:41:21 +02:00
|
|
|
* Values calculated to save code from doing it
|
2005-04-08 17:01:17 +02:00
|
|
|
*/
|
2006-08-24 15:18:05 +02:00
|
|
|
_text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
|
|
|
|
_data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
|
|
|
|
_load_size_pgh = ( ( _load_size + 15 ) / 16 );
|
2006-06-06 17:29:39 +02:00
|
|
|
_rom_size = ( ( _load_size + 511 ) / 512 );
|
2005-04-08 17:01:17 +02:00
|
|
|
}
|