Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This linker script is used to link rmodules (relocatable modules). It |
| 3 | * links at zero so that relocation fixups are easy when placing the binaries |
| 4 | * anywhere in the address space. |
| 5 | * |
| 6 | * NOTE: The program's loadable sections (text, module_params, and data) are |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 7 | * packed into the flat blob. The rmodule loader assumes the entire program |
| 8 | * resides in one contiguous address space. Therefore, alignment for a given |
| 9 | * section (if required) needs to be done at the end of the preceeding section. |
| 10 | * e.g. if the data section should be aligned to an 8 byte address the text |
| 11 | * section should have ALIGN(8) at the end of its section. Otherwise there |
| 12 | * won't be a consistent mapping between the flat blob and the loaded program. |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | BASE_ADDRESS = 0x00000; |
| 16 | |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame^] | 17 | ENTRY(__rmodule_entry); |
| 18 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 19 | SECTIONS |
| 20 | { |
| 21 | . = BASE_ADDRESS; |
| 22 | |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 23 | .payload : { |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 24 | /* C code of the module. */ |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 25 | _ram_seg = .; |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 26 | *(.textfirst); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 27 | *(.text); |
| 28 | *(.text.*); |
| 29 | /* C read-only data. */ |
| 30 | . = ALIGN(16); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 31 | |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 32 | __CTOR_LIST__ = .; |
| 33 | *(.ctors); |
| 34 | LONG(0); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 35 | LONG(0); |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 36 | __CTOR_END__ = .; |
| 37 | |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 38 | /* The driver sections are to allow linking coreboot's |
| 39 | * ramstage with the rmodule linker. Any changes made in |
Furquan Shaikh | 20f25dd | 2014-04-22 10:41:05 -0700 | [diff] [blame] | 40 | * ramstage.ld should be made here as well. */ |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 41 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 42 | pci_drivers = . ; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame^] | 43 | KEEP(*(.rodata.pci_driver)); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 44 | epci_drivers = . ; |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 45 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 46 | cpu_drivers = . ; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame^] | 47 | KEEP(*(.rodata.cpu_driver)); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 48 | ecpu_drivers = . ; |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 49 | . = ALIGN(8); |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 50 | _bs_init_begin = .; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame^] | 51 | KEEP(*(.bs_init)); |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 52 | _bs_init_end = .; |
| 53 | |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 54 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 55 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 56 | *(.rodata); |
| 57 | *(.rodata.*); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 58 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 59 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 60 | /* The parameters section can be used to pass parameters |
| 61 | * to a module, however there has to be an prior agreement |
| 62 | * on how to interpret the parameters. */ |
| 63 | _module_params_begin = .; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame^] | 64 | KEEP(*(.module_parameters)); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 65 | _module_params_end = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 66 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 67 | |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 68 | /* Data section. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 69 | _sdata = .; |
| 70 | *(.data); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 71 | *(.data.*); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 72 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 73 | _edata = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 74 | |
| 75 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 76 | } |
| 77 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 78 | .bss (NOLOAD) : { |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 79 | /* C uninitialized data of the module. */ |
| 80 | _bss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 81 | *(.bss); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 82 | *(.bss.*) |
| 83 | *(.sbss) |
| 84 | *(.sbss.*) |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 85 | *(COMMON); |
| 86 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 87 | _ebss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 88 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 89 | /* |
| 90 | * Place the heap after BSS. The heap size is passed in by |
| 91 | * by way of ld --defsym=__heap_size=<> |
| 92 | */ |
| 93 | _heap = .; |
| 94 | . = . + __heap_size; |
| 95 | _eheap = .; |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 96 | _eram_seg = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 97 | } |
| 98 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 99 | /DISCARD/ : { |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 100 | /* Drop unnecessary sections. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 101 | *(.eh_frame); |
Edward O'Callaghan | 9cb5a3a | 2014-11-12 11:52:56 +1100 | [diff] [blame] | 102 | *(.note); |
| 103 | *(.note.*); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 104 | } |
| 105 | } |