blob: c1669becb69e2de8e92a5adda514708cc93c4747 [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. */
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050025 _ram_seg = .;
Aaron Durbind23e292e2013-03-22 19:55:35 -050026 *(.textfirst);
Aaron Durbinad935522012-12-24 14:28:37 -060027 *(.text);
28 *(.text.*);
29 /* C read-only data. */
30 . = ALIGN(16);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060031
Aaron Durbind23e292e2013-03-22 19:55:35 -050032 __CTOR_LIST__ = .;
33 *(.ctors);
34 LONG(0);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070035 LONG(0);
Aaron Durbind23e292e2013-03-22 19:55:35 -050036 __CTOR_END__ = .;
37
Aaron Durbinf7c6d482013-02-06 15:47:31 -060038 /* The driver sections are to allow linking coreboot's
39 * ramstage with the rmodule linker. Any changes made in
Furquan Shaikh20f25dd2014-04-22 10:41:05 -070040 * ramstage.ld should be made here as well. */
Furquan Shaikh9ceca502014-08-26 15:01:41 -070041 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060042 pci_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050043 KEEP(*(.rodata.pci_driver));
Aaron Durbinf7c6d482013-02-06 15:47:31 -060044 epci_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070045 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060046 cpu_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050047 KEEP(*(.rodata.cpu_driver));
Aaron Durbinf7c6d482013-02-06 15:47:31 -060048 ecpu_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070049 . = ALIGN(8);
Aaron Durbina4feddf2013-04-24 16:12:52 -050050 _bs_init_begin = .;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050051 KEEP(*(.bs_init));
Aaron Durbina4feddf2013-04-24 16:12:52 -050052 _bs_init_end = .;
53
Furquan Shaikh9ceca502014-08-26 15:01:41 -070054 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060055
Aaron Durbinad935522012-12-24 14:28:37 -060056 *(.rodata);
57 *(.rodata.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070058 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060059
Aaron Durbinad935522012-12-24 14:28:37 -060060 /* 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 Durbinf69a99d2015-03-10 11:45:25 -050064 KEEP(*(.module_parameters));
Aaron Durbinad935522012-12-24 14:28:37 -060065 _module_params_end = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050066 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060067
Aaron Durbine1be5ae2013-04-29 13:53:41 -050068 /* Data section. */
Aaron Durbinad935522012-12-24 14:28:37 -060069 _sdata = .;
70 *(.data);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050071 *(.data.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070072 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060073 _edata = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050074
75 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060076 }
77
Aaron Durbinad935522012-12-24 14:28:37 -060078 .bss (NOLOAD) : {
Aaron Durbinf7c6d482013-02-06 15:47:31 -060079 /* C uninitialized data of the module. */
80 _bss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060081 *(.bss);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050082 *(.bss.*)
83 *(.sbss)
84 *(.sbss.*)
Aaron Durbinad935522012-12-24 14:28:37 -060085 *(COMMON);
86 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060087 _ebss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060088
Aaron Durbinad935522012-12-24 14:28:37 -060089 /*
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 Durbin3eb8eb72014-03-10 16:13:58 -050096 _eram_seg = .;
Aaron Durbinad935522012-12-24 14:28:37 -060097 }
98
Aaron Durbinad935522012-12-24 14:28:37 -060099 /DISCARD/ : {
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500100 /* Drop unnecessary sections. */
Aaron Durbinad935522012-12-24 14:28:37 -0600101 *(.eh_frame);
Edward O'Callaghan9cb5a3a2014-11-12 11:52:56 +1100102 *(.note);
103 *(.note.*);
Aaron Durbinad935522012-12-24 14:28:37 -0600104 }
105}