summaryrefslogtreecommitdiff
path: root/src/lib/rmodule.ld
blob: f5d5f061e5845cbc2b370b697f3340d36ae36650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * This linker script is used to link rmodules (relocatable modules).  It
 * links at zero so that relocation fixups are easy when placing the binaries
 * anywhere in the address space.
 *
 * NOTE:  The program's loadable sections (text, module_params, and data) are
 * packed into the flat blob. The rmodule loader assumes the entire program
 * resides in one contiguous address space. Therefore, alignment for a given
 * section (if required) needs to be done at the end of the preceeding section.
 * e.g. if the data section should be aligned to an 8 byte address the text
 * section should have ALIGN(8) at the end of its section.  Otherwise there
 * won't be a consistent mapping between the flat blob and the loaded program.
 */

BASE_ADDRESS = 0x00000;

ENTRY(__rmodule_entry);

SECTIONS
{
	. = BASE_ADDRESS;

	.payload :  {
		/* C code of the module. */
		_program = .;
		*(.text._start);
		*(.text.stage_entry);
		*(.text);
		*(.text.*);
		/* C read-only data. */
		. = ALIGN(16);

#if IS_ENABLED(CONFIG_COVERAGE)
		__CTOR_LIST__ = .;
		*(.ctors);
		LONG(0);
		LONG(0);
		__CTOR_END__ = .;
#endif

		/* The driver sections are to allow linking coreboot's
		 * ramstage with the rmodule linker. Any changes made in
		 * ramstage.ld should be made here as well. */
		. = ALIGN(8);
		_pci_drivers = . ;
		KEEP(*(.rodata.pci_driver));
		_epci_drivers = . ;
		. = ALIGN(8);
		_cpu_drivers = . ;
		KEEP(*(.rodata.cpu_driver));
		_ecpu_drivers = . ;
		. = ALIGN(8);
		_bs_init_begin = .;
		KEEP(*(.bs_init));
		LONG(0);
		LONG(0);
		_bs_init_end = .;
		_cbmem_init_hooks = .;
		KEEP(*(.rodata.cbmem_init_hooks));
		_ecbmem_init_hooks = .;

		. = ALIGN(8);

		*(.rodata);
		*(.rodata.*);
		. = ALIGN(8);

		/* The parameters section can be used to pass parameters
		 * to a module, however there has to be an prior agreement
		 * on how to interpret the parameters. */
		_module_params_begin = .;
		KEEP(*(.module_parameters));
		_module_params_end = .;
		. = ALIGN(8);

		/* Data section. */
		. = ALIGN(64);	/* Mirror cache line alignment from ramstage. */
		_sdata = .;
		*(.data);
		*(.data.*);
		. = ALIGN(8);
		_edata = .;

		. = ALIGN(8);
	}

	.bss (NOLOAD) : {
		/* C uninitialized data of the module. */
		_bss = .;
		*(.bss);
		*(.bss.*)
		*(.sbss)
		*(.sbss.*)
		*(COMMON);
		. = ALIGN(8);
		_ebss = .;

		/*
		 * Place the heap after BSS. The heap size is passed in by
		 * by way of ld --defsym=__heap_size=<>
		 */
		_heap = .;
		. = . + __heap_size;
		_eheap = .;
		_eprogram = .;
	}

	/DISCARD/ : {
		/* Drop unnecessary sections. */
		*(.eh_frame);
		*(.note);
		*(.note.*);
	}
}