Home | History | Annotate | Download | only in scripts
      1 /* -*- sh -*- */
      2 
      3 /*
      4  * Linker script for i386 images
      5  *
      6  */
      7 
      8 SECTIONS {
      9 
     10     /* Each section starts at a virtual address of zero.
     11      *
     12      * We guarantee alignment of virtual addresses to any alignment
     13      * specified by the constituent object files (e.g. via
     14      * __attribute__((aligned(x)))).  Load addresses are guaranteed
     15      * only up to _max_align.  Provided that all loader and relocation
     16      * code honours _max_align, this means that physical addresses are
     17      * also guaranteed up to _max_align.
     18      *
     19      * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
     20      * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
     21      * alignment).  Using _max_align>16 will therefore not guarantee
     22      * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
     23      * used (though virtual addresses will still be fully aligned).
     24      *
     25      */
     26 
     27     /*
     28      * The prefix
     29      *
     30      */
     31 
     32     .prefix 0x0 : AT ( _prefix_lma ) {
     33 	_prefix = .;
     34 	*(.prefix)
     35 	*(.prefix.*)
     36 	_mprefix = .;
     37     } .bss.prefix (NOLOAD) : AT ( _end_lma ) {
     38 	_eprefix = .;
     39     }
     40     _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
     41     _prefix_memsz	= ABSOLUTE ( _eprefix - _prefix );
     42 
     43     /*
     44      * The 16-bit (real-mode) code section
     45      *
     46      */
     47 
     48     .text16 0x0 : AT ( _text16_lma ) {
     49 	_text16 = .;
     50 	*(.text16.null)
     51 	. += 1;				/* Prevent NULL being valid */
     52 	*(.text16)
     53 	*(.text16.*)
     54 	_mtext16 = .;
     55     } .bss.text16 (NOLOAD) : AT ( _end_lma ) {
     56 	_etext16 = .;
     57     }
     58     _text16_filesz	= ABSOLUTE ( _mtext16 - _text16 );
     59     _text16_memsz	= ABSOLUTE ( _etext16 - _text16 );
     60 
     61     /*
     62      * The 16-bit (real-mode) data section
     63      *
     64      */
     65 
     66     .data16 0x0 : AT ( _data16_lma ) {
     67 	_data16 = .;
     68 	. += 1;				/* Prevent NULL being valid */
     69 	*(.rodata16)
     70 	*(.rodata16.*)
     71 	*(.data16)
     72 	*(.data16.*)
     73 	_mdata16 = .;
     74     } .bss.data16 (NOLOAD) : AT ( _end_lma ) {
     75 	*(.bss16)
     76 	*(.bss16.*)
     77 	*(.stack16)
     78 	*(.stack16.*)
     79 	_edata16 = .;
     80     }
     81     _data16_filesz	= ABSOLUTE ( _mdata16 - _data16 );
     82     _data16_memsz	= ABSOLUTE ( _edata16 - _data16 );
     83 
     84     /*
     85      * The 32-bit sections
     86      *
     87      */
     88 
     89     .textdata 0x0 : AT ( _textdata_lma ) {
     90 	_textdata = .;
     91 	*(.text.null_trap)
     92 	. += 1;				/* Prevent NULL being valid */
     93 	*(.text)
     94 	*(.text.*)
     95 	*(.rodata)
     96 	*(.rodata.*)
     97 	*(.data)
     98 	*(.data.*)
     99 	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
    100 	_mtextdata = .;
    101     } .bss.textdata (NOLOAD) : AT ( _end_lma ) {
    102 	*(.bss)
    103 	*(.bss.*)
    104 	*(COMMON)
    105 	*(.stack)
    106 	*(.stack.*)
    107 	_etextdata = .;
    108     }
    109     _textdata_filesz	= ABSOLUTE ( _mtextdata - _textdata );
    110     _textdata_memsz	= ABSOLUTE ( _etextdata - _textdata );
    111 
    112     /*
    113      * Compressor information block
    114      *
    115      */
    116 
    117     .zinfo 0x0 : AT ( _zinfo_lma ) {
    118 	_zinfo = .;
    119 	*(.zinfo)
    120 	*(.zinfo.*)
    121 	_mzinfo = .;
    122     } .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
    123 	_ezinfo = .;
    124     }
    125     _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );
    126     _zinfo_memsz	= ABSOLUTE ( _ezinfo - _zinfo );
    127 
    128     /*
    129      * Weak symbols that need zero values if not otherwise defined
    130      *
    131      */
    132 
    133     .weak 0x0 : AT ( _end_lma ) {
    134 	_weak = .;
    135 	*(.weak)
    136 	_eweak = .;
    137     }
    138     _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
    139 
    140     /*
    141      * Dispose of the comment and note sections to make the link map
    142      * easier to read
    143      *
    144      */
    145 
    146     /DISCARD/ : {
    147 	*(.comment)
    148 	*(.comment.*)
    149 	*(.note)
    150 	*(.note.*)
    151 	*(.eh_frame)
    152 	*(.eh_frame.*)
    153 	*(.rel)
    154 	*(.rel.*)
    155 	*(.discard)
    156     }
    157 
    158     /*
    159      * Load address calculations.  In older versions of ld, ALIGN()
    160      * can operate only on the location counter, so we use that.
    161      *
    162      */
    163 
    164     PROVIDE ( _max_align = 16 );
    165     .			= 0;
    166 
    167     .			= ALIGN ( _max_align );
    168     _prefix_lma		= .;
    169     .			+= _prefix_filesz;
    170 
    171     .			= ALIGN ( _max_align );
    172     _payload_lma	= .;
    173     _text16_lma		= .;
    174     .			+= _text16_filesz;
    175 
    176     .			= ALIGN ( _max_align );
    177     _data16_lma		= .;
    178     .			+= _data16_filesz;
    179 
    180     .			= ALIGN ( _max_align );
    181     _textdata_lma	= .;
    182     .			+= _textdata_filesz;
    183 
    184     _filesz		= .; /* Do not include zinfo block in file size */
    185 
    186     .			= ALIGN ( _max_align );
    187     _zinfo_lma		= .;
    188     .			+= _zinfo_filesz;
    189 
    190     .			= ALIGN ( _max_align );
    191     _end_lma		= .;
    192 
    193     /*
    194      * Values calculated to save code from doing it
    195      *
    196      */
    197     _prefix_filesz_sect = ( ( _prefix_filesz + 511 ) / 512 );
    198     _prefix_memsz_pgh	= ( ( _prefix_memsz + 15 ) / 16 );
    199     _prefix_memsz_sect	= ( ( _prefix_memsz + 511 ) / 512 );
    200     _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
    201     _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
    202 }
    203