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. */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 25 | _program = .; |
| 26 | *(.text._start); |
| 27 | *(.text.stage_entry); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 28 | *(.text); |
| 29 | *(.text.*); |
| 30 | /* C read-only data. */ |
| 31 | . = ALIGN(16); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 32 | |
Martin Roth | c4e49f6 | 2015-07-11 13:42:54 -0600 | [diff] [blame] | 33 | #if IS_ENABLED(CONFIG_COVERAGE) |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 34 | __CTOR_LIST__ = .; |
| 35 | *(.ctors); |
| 36 | LONG(0); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 37 | LONG(0); |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 38 | __CTOR_END__ = .; |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 39 | #endif |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 40 | |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 41 | /* The driver sections are to allow linking coreboot's |
| 42 | * ramstage with the rmodule linker. Any changes made in |
Furquan Shaikh | 20f25dd | 2014-04-22 10:41:05 -0700 | [diff] [blame] | 43 | * ramstage.ld should be made here as well. */ |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 44 | . = ALIGN(8); |
Aaron Durbin | 0375815 | 2015-09-03 17:23:08 -0500 | [diff] [blame] | 45 | _pci_drivers = . ; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame] | 46 | KEEP(*(.rodata.pci_driver)); |
Aaron Durbin | 0375815 | 2015-09-03 17:23:08 -0500 | [diff] [blame] | 47 | _epci_drivers = . ; |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 48 | . = ALIGN(8); |
Aaron Durbin | 0375815 | 2015-09-03 17:23:08 -0500 | [diff] [blame] | 49 | _cpu_drivers = . ; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame] | 50 | KEEP(*(.rodata.cpu_driver)); |
Aaron Durbin | 0375815 | 2015-09-03 17:23:08 -0500 | [diff] [blame] | 51 | _ecpu_drivers = . ; |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 52 | . = ALIGN(8); |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 53 | _bs_init_begin = .; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame] | 54 | KEEP(*(.bs_init)); |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 55 | LONG(0); |
| 56 | LONG(0); |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 57 | _bs_init_end = .; |
Kyösti Mälkki | 4fbac46 | 2015-01-07 04:48:43 +0200 | [diff] [blame] | 58 | _cbmem_init_hooks = .; |
| 59 | KEEP(*(.rodata.cbmem_init_hooks)); |
| 60 | _ecbmem_init_hooks = .; |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 61 | |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 62 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 63 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 64 | *(.rodata); |
| 65 | *(.rodata.*); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 66 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 67 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 68 | /* The parameters section can be used to pass parameters |
| 69 | * to a module, however there has to be an prior agreement |
| 70 | * on how to interpret the parameters. */ |
| 71 | _module_params_begin = .; |
Aaron Durbin | f69a99d | 2015-03-10 11:45:25 -0500 | [diff] [blame] | 72 | KEEP(*(.module_parameters)); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 73 | _module_params_end = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 74 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 75 | |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 76 | /* Data section. */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 77 | . = ALIGN(64); /* Mirror cache line alignment from ramstage. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 78 | _sdata = .; |
| 79 | *(.data); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 80 | *(.data.*); |
Furquan Shaikh | 9ceca50 | 2014-08-26 15:01:41 -0700 | [diff] [blame] | 81 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 82 | _edata = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 83 | |
| 84 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 85 | } |
| 86 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 87 | .bss (NOLOAD) : { |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 88 | /* C uninitialized data of the module. */ |
| 89 | _bss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 90 | *(.bss); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 91 | *(.bss.*) |
| 92 | *(.sbss) |
| 93 | *(.sbss.*) |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 94 | *(COMMON); |
| 95 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 96 | _ebss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 97 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 98 | /* |
| 99 | * Place the heap after BSS. The heap size is passed in by |
| 100 | * by way of ld --defsym=__heap_size=<> |
| 101 | */ |
| 102 | _heap = .; |
| 103 | . = . + __heap_size; |
| 104 | _eheap = .; |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 105 | _eprogram = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 106 | } |
| 107 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 108 | /DISCARD/ : { |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 109 | /* Drop unnecessary sections. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 110 | *(.eh_frame); |
Edward O'Callaghan | 9cb5a3a | 2014-11-12 11:52:56 +1100 | [diff] [blame] | 111 | *(.note); |
| 112 | *(.note.*); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 113 | } |
| 114 | } |