blob: f5d5f061e5845cbc2b370b697f3340d36ae36650 [file] [log] [blame]
Aaron Durbinad935522012-12-24 14:28:37 -06001/*
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 Durbin3eb8eb72014-03-10 16:13:58 -05007 * 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 Durbinad935522012-12-24 14:28:37 -060013 */
14
15BASE_ADDRESS = 0x00000;
16
Aaron Durbinf69a99d2015-03-10 11:45:25 -050017ENTRY(__rmodule_entry);
18
Aaron Durbinad935522012-12-24 14:28:37 -060019SECTIONS
20{
21 . = BASE_ADDRESS;
22
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050023 .payload : {
Aaron Durbinad935522012-12-24 14:28:37 -060024 /* C code of the module. */
Julius Wernerec5e5e02014-08-20 15:29:56 -070025 _program = .;
26 *(.text._start);
27 *(.text.stage_entry);
Aaron Durbinad935522012-12-24 14:28:37 -060028 *(.text);
29 *(.text.*);
30 /* C read-only data. */
31 . = ALIGN(16);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060032
Martin Rothc4e49f62015-07-11 13:42:54 -060033#if IS_ENABLED(CONFIG_COVERAGE)
Aaron Durbind23e292e2013-03-22 19:55:35 -050034 __CTOR_LIST__ = .;
35 *(.ctors);
36 LONG(0);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070037 LONG(0);
Aaron Durbind23e292e2013-03-22 19:55:35 -050038 __CTOR_END__ = .;
Julius Wernerec5e5e02014-08-20 15:29:56 -070039#endif
Aaron Durbind23e292e2013-03-22 19:55:35 -050040
Aaron Durbinf7c6d482013-02-06 15:47:31 -060041 /* The driver sections are to allow linking coreboot's
42 * ramstage with the rmodule linker. Any changes made in
Furquan Shaikh20f25dd2014-04-22 10:41:05 -070043 * ramstage.ld should be made here as well. */
Furquan Shaikh9ceca502014-08-26 15:01:41 -070044 . = ALIGN(8);
Aaron Durbin03758152015-09-03 17:23:08 -050045 _pci_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050046 KEEP(*(.rodata.pci_driver));
Aaron Durbin03758152015-09-03 17:23:08 -050047 _epci_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070048 . = ALIGN(8);
Aaron Durbin03758152015-09-03 17:23:08 -050049 _cpu_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050050 KEEP(*(.rodata.cpu_driver));
Aaron Durbin03758152015-09-03 17:23:08 -050051 _ecpu_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070052 . = ALIGN(8);
Aaron Durbina4feddf2013-04-24 16:12:52 -050053 _bs_init_begin = .;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050054 KEEP(*(.bs_init));
Aaron Durbin9ef9d852015-03-16 17:30:09 -050055 LONG(0);
56 LONG(0);
Aaron Durbina4feddf2013-04-24 16:12:52 -050057 _bs_init_end = .;
Kyösti Mälkki4fbac462015-01-07 04:48:43 +020058 _cbmem_init_hooks = .;
59 KEEP(*(.rodata.cbmem_init_hooks));
60 _ecbmem_init_hooks = .;
Aaron Durbina4feddf2013-04-24 16:12:52 -050061
Furquan Shaikh9ceca502014-08-26 15:01:41 -070062 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060063
Aaron Durbinad935522012-12-24 14:28:37 -060064 *(.rodata);
65 *(.rodata.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070066 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060067
Aaron Durbinad935522012-12-24 14:28:37 -060068 /* 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 Durbinf69a99d2015-03-10 11:45:25 -050072 KEEP(*(.module_parameters));
Aaron Durbinad935522012-12-24 14:28:37 -060073 _module_params_end = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050074 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060075
Aaron Durbine1be5ae2013-04-29 13:53:41 -050076 /* Data section. */
Julius Wernerec5e5e02014-08-20 15:29:56 -070077 . = ALIGN(64); /* Mirror cache line alignment from ramstage. */
Aaron Durbinad935522012-12-24 14:28:37 -060078 _sdata = .;
79 *(.data);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050080 *(.data.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070081 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060082 _edata = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050083
84 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060085 }
86
Aaron Durbinad935522012-12-24 14:28:37 -060087 .bss (NOLOAD) : {
Aaron Durbinf7c6d482013-02-06 15:47:31 -060088 /* C uninitialized data of the module. */
89 _bss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060090 *(.bss);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050091 *(.bss.*)
92 *(.sbss)
93 *(.sbss.*)
Aaron Durbinad935522012-12-24 14:28:37 -060094 *(COMMON);
95 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060096 _ebss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060097
Aaron Durbinad935522012-12-24 14:28:37 -060098 /*
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 Wernerec5e5e02014-08-20 15:29:56 -0700105 _eprogram = .;
Aaron Durbinad935522012-12-24 14:28:37 -0600106 }
107
Aaron Durbinad935522012-12-24 14:28:37 -0600108 /DISCARD/ : {
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500109 /* Drop unnecessary sections. */
Aaron Durbinad935522012-12-24 14:28:37 -0600110 *(.eh_frame);
Edward O'Callaghan9cb5a3a2014-11-12 11:52:56 +1100111 *(.note);
112 *(.note.*);
Aaron Durbinad935522012-12-24 14:28:37 -0600113 }
114}