blob: 70a2d3df8e25976d0d3c4f7fbe4b239aa2c82cb0 [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
Julius Wernerec5e5e02014-08-20 15:29:56 -070033#ifdef 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 Durbinf7c6d482013-02-06 15:47:31 -060045 pci_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050046 KEEP(*(.rodata.pci_driver));
Aaron Durbinf7c6d482013-02-06 15:47:31 -060047 epci_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070048 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060049 cpu_drivers = . ;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050050 KEEP(*(.rodata.cpu_driver));
Aaron Durbinf7c6d482013-02-06 15:47:31 -060051 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 = .;
58
Furquan Shaikh9ceca502014-08-26 15:01:41 -070059 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060060
Aaron Durbinad935522012-12-24 14:28:37 -060061 *(.rodata);
62 *(.rodata.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070063 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060064
Aaron Durbinad935522012-12-24 14:28:37 -060065 /* The parameters section can be used to pass parameters
66 * to a module, however there has to be an prior agreement
67 * on how to interpret the parameters. */
68 _module_params_begin = .;
Aaron Durbinf69a99d2015-03-10 11:45:25 -050069 KEEP(*(.module_parameters));
Aaron Durbinad935522012-12-24 14:28:37 -060070 _module_params_end = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050071 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060072
Aaron Durbine1be5ae2013-04-29 13:53:41 -050073 /* Data section. */
Julius Wernerec5e5e02014-08-20 15:29:56 -070074 . = ALIGN(64); /* Mirror cache line alignment from ramstage. */
Aaron Durbinad935522012-12-24 14:28:37 -060075 _sdata = .;
76 *(.data);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050077 *(.data.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070078 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060079 _edata = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050080
81 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060082 }
83
Aaron Durbinad935522012-12-24 14:28:37 -060084 .bss (NOLOAD) : {
Aaron Durbinf7c6d482013-02-06 15:47:31 -060085 /* C uninitialized data of the module. */
86 _bss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060087 *(.bss);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050088 *(.bss.*)
89 *(.sbss)
90 *(.sbss.*)
Aaron Durbinad935522012-12-24 14:28:37 -060091 *(COMMON);
92 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060093 _ebss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060094
Aaron Durbinad935522012-12-24 14:28:37 -060095 /*
96 * Place the heap after BSS. The heap size is passed in by
97 * by way of ld --defsym=__heap_size=<>
98 */
99 _heap = .;
100 . = . + __heap_size;
101 _eheap = .;
Julius Wernerec5e5e02014-08-20 15:29:56 -0700102 _eprogram = .;
Aaron Durbinad935522012-12-24 14:28:37 -0600103 }
104
Aaron Durbinad935522012-12-24 14:28:37 -0600105 /DISCARD/ : {
Aaron Durbin3eb8eb72014-03-10 16:13:58 -0500106 /* Drop unnecessary sections. */
Aaron Durbinad935522012-12-24 14:28:37 -0600107 *(.eh_frame);
Edward O'Callaghan9cb5a3a2014-11-12 11:52:56 +1100108 *(.note);
109 *(.note.*);
Aaron Durbinad935522012-12-24 14:28:37 -0600110 }
111}