-florian66-

linker

Jul 24th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.36 KB | None | 0 0
  1. /*
  2.     This linker script links the object files when generating the ELF
  3.     output. Note how symbols romdata, bbss, ebss, bdata and edata are used
  4.     in the initialization routine (crt0.c) to initialize the application.
  5.  
  6.     Two ram areas are specified. The "real ram" is accessed directly while
  7.     the other area is virtualized. It is not possible to execute code in
  8.     virtualized ram.
  9. */
  10.  
  11. OUTPUT_ARCH(sh3)
  12. ENTRY(_start)
  13.  
  14. MEMORY
  15. {
  16.     /* System-managed mappings map this area into the add-in data */
  17.     rom : o = 0x00300200, l = 512k
  18.     /* 0x0810000 is apparently mapped to 0x8801c0000 */
  19.     ram : o = 0x08100000, l = 8k
  20.     /* RAM section from P1 area, no MMU involved */
  21.     realram : o = 0x8800d000, l = 12k
  22. }
  23.  
  24. SECTIONS
  25. {
  26.     /* ROM sections: binary code and read-only data */
  27.  
  28.     .text : {
  29.         /* Initialization code. */
  30.         *(.pretext.entry)
  31.         *(.pretext)
  32.  
  33.         _bctors = ABSOLUTE(.);
  34.         *(.ctors)
  35.         _ectors = ABSOLUTE(.);
  36.         _bdtors = ABSOLUTE(.);
  37.         *(.dtors)
  38.         _edtors = ABSOLUTE(.);
  39.  
  40.         *(.text)
  41.         *(.text.*)
  42.     } > rom
  43.  
  44.     .rodata : {
  45.         *(.rodata.fxconv);
  46.         *(.rodata.paradox);
  47.         *(.rodata)
  48.         . = ALIGN(4);
  49.         *(.rodata.*)
  50.  
  51.         _romdata = ALIGN(4) ;
  52.     } > rom
  53.  
  54.     /* RAM sections: bss section and read/write data
  55.        The .bss section is to be stripped from the ELF file and wiped at
  56.        startup, hence its location is undefined */
  57.  
  58.     .bss : {
  59.         _bbss = ABSOLUTE(.);
  60.         _sbss = ABSOLUTE(SIZEOF(.bss));
  61.  
  62.         *(.bss)
  63.     } > ram
  64.  
  65.     .data : AT(_romdata) ALIGN(4) {
  66.         _bdata = ABSOLUTE(.);
  67.         _sdata = ABSOLUTE(SIZEOF(.data));
  68.  
  69.         *(.data)
  70.         *(.data.*)
  71.     } > ram
  72.  
  73.     .cc : AT(_romdata + SIZEOF(.data)) ALIGN(4) {
  74.         *(.eh_frame)
  75.         *(.jcr)
  76.  
  77.         . = ALIGN(4);
  78.     } > ram
  79.  
  80.     /* Real RAM sections: interrupt handlers and some *uninitialized* gint
  81.        data */
  82.  
  83.     _gint_data = _romdata + SIZEOF(.data) + SIZEOF(.cc) ;
  84.  
  85.     .gint : AT(_gint_data) ALIGN(4) {
  86.         /* The vbr needs to be 0x100-aligned because of an ld issue */
  87.         . = ALIGN(0x100) ;
  88.  
  89.         _gint_vbr = . ;
  90.         _bgint = ABSOLUTE(.) ;
  91.  
  92.         /* Exception handler */
  93.         . = _gint_vbr + 0x100 ;
  94.         *(.gint.exc)
  95.  
  96.         /* TLB miss handler */
  97.         . = _gint_vbr + 0x400 ;
  98.         *(.gint.tlb)
  99.  
  100.         /* Interrupt handler */
  101.         . = _gint_vbr + 0x600 ;
  102.         *(.gint.int)
  103.  
  104.         . = ALIGN(4);
  105.         _egint = ABSOLUTE(.) ;
  106.     } > realram
  107.  
  108.     .gint_bss : AT(_gint_data + SIZEOF(.gint)) ALIGN(4) {
  109.         _bgbss = ABSOLUTE(.) ;
  110.         *(.gint.bss)
  111.         _egbss = ABSOLUTE(.) ;
  112.     } > realram
  113. }
Advertisement
Add Comment
Please, Sign In to add comment