blob: 06458def18b9ba2c589d749ee532ded56defe7c0 [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
17SECTIONS
18{
19 . = BASE_ADDRESS;
20
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050021 .payload : {
Aaron Durbinad935522012-12-24 14:28:37 -060022 /* C code of the module. */
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050023 _ram_seg = .;
Aaron Durbind23e292e2013-03-22 19:55:35 -050024 *(.textfirst);
Aaron Durbinad935522012-12-24 14:28:37 -060025 *(.text);
26 *(.text.*);
27 /* C read-only data. */
28 . = ALIGN(16);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060029
Aaron Durbind23e292e2013-03-22 19:55:35 -050030 __CTOR_LIST__ = .;
31 *(.ctors);
32 LONG(0);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070033 LONG(0);
Aaron Durbind23e292e2013-03-22 19:55:35 -050034 __CTOR_END__ = .;
35
Aaron Durbinf7c6d482013-02-06 15:47:31 -060036 /* The driver sections are to allow linking coreboot's
37 * ramstage with the rmodule linker. Any changes made in
Furquan Shaikh20f25dd2014-04-22 10:41:05 -070038 * ramstage.ld should be made here as well. */
Furquan Shaikh9ceca502014-08-26 15:01:41 -070039 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060040 pci_drivers = . ;
41 *(.rodata.pci_driver)
42 epci_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070043 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060044 cpu_drivers = . ;
45 *(.rodata.cpu_driver)
46 ecpu_drivers = . ;
Furquan Shaikh9ceca502014-08-26 15:01:41 -070047 . = ALIGN(8);
Aaron Durbina4feddf2013-04-24 16:12:52 -050048 _bs_init_begin = .;
49 *(.bs_init)
50 _bs_init_end = .;
51
Furquan Shaikh9ceca502014-08-26 15:01:41 -070052 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060053
Aaron Durbinad935522012-12-24 14:28:37 -060054 *(.rodata);
55 *(.rodata.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070056 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060057
Aaron Durbinad935522012-12-24 14:28:37 -060058 /* The parameters section can be used to pass parameters
59 * to a module, however there has to be an prior agreement
60 * on how to interpret the parameters. */
61 _module_params_begin = .;
62 *(.module_parameters);
63 _module_params_end = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050064 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060065
Aaron Durbine1be5ae2013-04-29 13:53:41 -050066 /* Data section. */
Aaron Durbinad935522012-12-24 14:28:37 -060067 _sdata = .;
68 *(.data);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050069 *(.data.*);
Furquan Shaikh9ceca502014-08-26 15:01:41 -070070 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060071 _edata = .;
Aaron Durbine1be5ae2013-04-29 13:53:41 -050072
73 . = ALIGN(8);
Aaron Durbinad935522012-12-24 14:28:37 -060074 }
75
Aaron Durbinad935522012-12-24 14:28:37 -060076 .bss (NOLOAD) : {
Aaron Durbinf7c6d482013-02-06 15:47:31 -060077 /* C uninitialized data of the module. */
78 _bss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060079 *(.bss);
Aaron Durbin3bc6eb52014-03-25 14:53:28 -050080 *(.bss.*)
81 *(.sbss)
82 *(.sbss.*)
Aaron Durbinad935522012-12-24 14:28:37 -060083 *(COMMON);
84 . = ALIGN(8);
Aaron Durbinf7c6d482013-02-06 15:47:31 -060085 _ebss = .;
Aaron Durbinad935522012-12-24 14:28:37 -060086
Aaron Durbinad935522012-12-24 14:28:37 -060087 /*
88 * Place the heap after BSS. The heap size is passed in by
89 * by way of ld --defsym=__heap_size=<>
90 */
91 _heap = .;
92 . = . + __heap_size;
93 _eheap = .;
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050094 _eram_seg = .;
Aaron Durbinad935522012-12-24 14:28:37 -060095 }
96
Aaron Durbinad935522012-12-24 14:28:37 -060097 /DISCARD/ : {
Aaron Durbin3eb8eb72014-03-10 16:13:58 -050098 /* Drop unnecessary sections. */
Aaron Durbinad935522012-12-24 14:28:37 -060099 *(.eh_frame);
100 }
101}