summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/barebox.lds.h
blob: c5f9d975472a320d54e6a68ec9acf0f2ec7aacc3 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

/*
 * Align to a 32 byte boundary equal to the
 * alignment gcc 4.5 uses for a struct
 */
#define STRUCT_ALIGNMENT 32
#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)

#if defined CONFIG_X86 || \
	defined CONFIG_ARCH_EP93XX
#include <mach/barebox.lds.h>
#endif

#ifndef PRE_IMAGE
#define PRE_IMAGE
#endif

#define BAREBOX_INITCALLS			\
	STRUCT_ALIGN();				\
	__barebox_initcalls_start = .;		\
	KEEP(*(.initcall.0))			\
	KEEP(*(.initcall.1))			\
	KEEP(*(.initcall.2))			\
	KEEP(*(.initcall.3))			\
	KEEP(*(.initcall.4))			\
	KEEP(*(.initcall.5))			\
	KEEP(*(.initcall.6))			\
	KEEP(*(.initcall.7))			\
	KEEP(*(.initcall.8))			\
	KEEP(*(.initcall.9))			\
	KEEP(*(.initcall.10))			\
	KEEP(*(.initcall.11))			\
	KEEP(*(.initcall.12))			\
	KEEP(*(.initcall.13))			\
	KEEP(*(.initcall.14))			\
	KEEP(*(.initcall.15))			\
	__barebox_initcalls_end = .;

#define BAREBOX_EXITCALLS			\
	STRUCT_ALIGN();				\
	__barebox_exitcalls_start = .;		\
	KEEP(*(.exitcall.0))			\
	KEEP(*(.exitcall.1))			\
	KEEP(*(.exitcall.2))			\
	KEEP(*(.exitcall.3))			\
	KEEP(*(.exitcall.4))			\
	KEEP(*(.exitcall.5))			\
	KEEP(*(.exitcall.6))			\
	__barebox_exitcalls_end = .;

#define BAREBOX_CMDS				\
	STRUCT_ALIGN();				\
	__barebox_cmd_start = .;		\
	KEEP(*(SORT_BY_NAME(.barebox_cmd*)))	\
	__barebox_cmd_end = .;

#define BAREBOX_RATP_CMDS			\
	STRUCT_ALIGN();				\
	__barebox_ratp_cmd_start = .;		\
	KEEP(*(SORT_BY_NAME(.barebox_ratp_cmd*)))	\
	__barebox_ratp_cmd_end = .;

#define BAREBOX_SYMS				\
	STRUCT_ALIGN();				\
	__usymtab_start = .;			\
	KEEP(*(__usymtab))			\
	__usymtab_end = .;

#define BAREBOX_MAGICVARS			\
	STRUCT_ALIGN();				\
	__barebox_magicvar_start = .;		\
	KEEP(*(SORT_BY_NAME(.barebox_magicvar*)))	\
	__barebox_magicvar_end = .;

#define BAREBOX_CLK_TABLE			\
	STRUCT_ALIGN();				\
	__clk_of_table_start = .;		\
	KEEP(*(.__clk_of_table));		\
	KEEP(*(.__clk_of_table_end));		\
	__clk_of_table_end = .;

#define BAREBOX_DTB				\
	STRUCT_ALIGN();				\
	__dtb_start = .;			\
	KEEP(*(.dtb.rodata.*));			\
	__dtb_end = .;

#define BAREBOX_IMD				\
	STRUCT_ALIGN();				\
	KEEP(*(.barebox_imd_start))		\
	KEEP(*(.barebox_imd_1*))		\
	*(.barebox_imd_0*)			\
	KEEP(*(.barebox_imd_end))

#ifdef CONFIG_PCI
#define BAREBOX_PCI_FIXUP			\
	STRUCT_ALIGN();				\
	__start_pci_fixups_early = .;		\
	KEEP(*(.pci_fixup_early))		\
	__end_pci_fixups_early = .;		\
	__start_pci_fixups_header = .;		\
	KEEP(*(.pci_fixup_header))		\
	__end_pci_fixups_header = .;		\
	__start_pci_fixups_enable = .;		\
	KEEP(*(.pci_fixup_enable))		\
	__end_pci_fixups_enable = .;
#else
#define BAREBOX_PCI_FIXUP
#endif

#define BAREBOX_RSA_KEYS			\
	STRUCT_ALIGN();				\
	__rsa_keys_start = .;			\
	KEEP(*(.rsa_keys.rodata.*));		\
	__rsa_keys_end = .;			\

#define BAREBOX_DEEP_PROBE			\
	STRUCT_ALIGN();				\
	__barebox_deep_probe_start = .;		\
	KEEP(*(SORT_BY_NAME(.barebox_deep_probe*)))	\
	__barebox_deep_probe_end = .;


#ifdef CONFIG_CONSTRUCTORS
#define KERNEL_CTORS()  . = ALIGN(8);                      \
			__ctors_start = .;                 \
			KEEP(*(.ctors))                    \
			KEEP(*(SORT(.init_array.*)))       \
			KEEP(*(.init_array))               \
			__ctors_end = .;
#else
#define KERNEL_CTORS()
#endif

#define RO_DATA_SECTION				\
	BAREBOX_INITCALLS			\
	BAREBOX_EXITCALLS			\
	BAREBOX_CMDS				\
	BAREBOX_RATP_CMDS			\
	BAREBOX_SYMS				\
	KERNEL_CTORS()				\
	BAREBOX_MAGICVARS			\
	BAREBOX_CLK_TABLE			\
	BAREBOX_DTB				\
	BAREBOX_RSA_KEYS			\
	BAREBOX_PCI_FIXUP			\
	BAREBOX_DEEP_PROBE

#if defined(CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE) && \
CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
#define MAX_BARE_INIT_SIZE CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE
#else
#define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
#endif

#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
#else
#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
#endif

#include <linux/stringify.h>
/* use 2 ASSERT because ld can not accept '"size" "10"' format */
#define BAREBOX_BARE_INIT_SIZE					\
	_barebox_bare_init_size = __bare_init_end - _text;	\
	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \

#define BAREBOX_PBL_SIZE					\
	_barebox_pbl_size = __bss_start - _text;		\
	ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE)) \