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 | |
| 17 | SECTIONS |
| 18 | { |
| 19 | . = BASE_ADDRESS; |
| 20 | |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 21 | .payload : { |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 22 | /* C code of the module. */ |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 23 | _ram_seg = .; |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 24 | *(.textfirst); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 25 | *(.text); |
| 26 | *(.text.*); |
| 27 | /* C read-only data. */ |
| 28 | . = ALIGN(16); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 29 | |
Aaron Durbin | d23e292e | 2013-03-22 19:55:35 -0500 | [diff] [blame] | 30 | __CTOR_LIST__ = .; |
| 31 | *(.ctors); |
| 32 | LONG(0); |
| 33 | __CTOR_END__ = .; |
| 34 | |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 35 | /* The driver sections are to allow linking coreboot's |
| 36 | * ramstage with the rmodule linker. Any changes made in |
Furquan Shaikh | 20f25dd | 2014-04-22 10:41:05 -0700 | [diff] [blame^] | 37 | * ramstage.ld should be made here as well. */ |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 38 | pci_drivers = . ; |
| 39 | *(.rodata.pci_driver) |
| 40 | epci_drivers = . ; |
| 41 | cpu_drivers = . ; |
| 42 | *(.rodata.cpu_driver) |
| 43 | ecpu_drivers = . ; |
Aaron Durbin | a4feddf | 2013-04-24 16:12:52 -0500 | [diff] [blame] | 44 | _bs_init_begin = .; |
| 45 | *(.bs_init) |
| 46 | _bs_init_end = .; |
| 47 | |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 48 | . = ALIGN(4); |
| 49 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 50 | *(.rodata); |
| 51 | *(.rodata.*); |
| 52 | . = ALIGN(4); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 53 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 54 | /* The parameters section can be used to pass parameters |
| 55 | * to a module, however there has to be an prior agreement |
| 56 | * on how to interpret the parameters. */ |
| 57 | _module_params_begin = .; |
| 58 | *(.module_parameters); |
| 59 | _module_params_end = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 60 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 61 | |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 62 | /* Data section. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 63 | _sdata = .; |
| 64 | *(.data); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 65 | *(.data.*); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 66 | . = ALIGN(4); |
| 67 | _edata = .; |
Aaron Durbin | e1be5ae | 2013-04-29 13:53:41 -0500 | [diff] [blame] | 68 | |
| 69 | . = ALIGN(8); |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 70 | } |
| 71 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 72 | .bss (NOLOAD) : { |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 73 | /* C uninitialized data of the module. */ |
| 74 | _bss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 75 | *(.bss); |
Aaron Durbin | 3bc6eb5 | 2014-03-25 14:53:28 -0500 | [diff] [blame] | 76 | *(.bss.*) |
| 77 | *(.sbss) |
| 78 | *(.sbss.*) |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 79 | *(COMMON); |
| 80 | . = ALIGN(8); |
Aaron Durbin | f7c6d48 | 2013-02-06 15:47:31 -0600 | [diff] [blame] | 81 | _ebss = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 82 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 83 | /* |
| 84 | * Place the heap after BSS. The heap size is passed in by |
| 85 | * by way of ld --defsym=__heap_size=<> |
| 86 | */ |
| 87 | _heap = .; |
| 88 | . = . + __heap_size; |
| 89 | _eheap = .; |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 90 | _eram_seg = .; |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 91 | } |
| 92 | |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 93 | /DISCARD/ : { |
Aaron Durbin | 3eb8eb7 | 2014-03-10 16:13:58 -0500 | [diff] [blame] | 94 | /* Drop unnecessary sections. */ |
Aaron Durbin | ad93552 | 2012-12-24 14:28:37 -0600 | [diff] [blame] | 95 | *(.eh_frame); |
| 96 | } |
| 97 | } |