Skip to content

Commit f21ba44

Browse files
npigginmpe
authored andcommitted
powerpc/build: move got, toc, plt, branch_lt sections to read-only
This moves linker-related tables from .data to read-only area. Relocations are performed at early boot time before memory is protected, after which there should be no modifications required. Signed-off-by: Nicholas Piggin <[email protected]> [mpe: Don't use SPECIAL as reported by [email protected]] Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1faa123 commit f21ba44

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

arch/powerpc/kernel/vmlinux.lds.S

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ SECTIONS
135135
/* Read-only data */
136136
RO_DATA(PAGE_SIZE)
137137

138+
.branch_lt : AT(ADDR(.branch_lt) - LOAD_OFFSET) {
139+
*(.branch_lt)
140+
}
141+
138142
#ifdef CONFIG_PPC32
139143
.got1 : AT(ADDR(.got1) - LOAD_OFFSET) {
140144
*(.got1)
@@ -144,7 +148,25 @@ SECTIONS
144148
*(.got2)
145149
__got2_end = .;
146150
}
151+
.got : AT(ADDR(.got) - LOAD_OFFSET) {
152+
*(.got)
153+
*(.got.plt)
154+
}
155+
.plt : AT(ADDR(.plt) - LOAD_OFFSET) {
156+
/* XXX: is .plt (and .got.plt) required? */
157+
*(.plt)
158+
}
159+
147160
#else /* CONFIG_PPC32 */
161+
.toc1 : AT(ADDR(.toc1) - LOAD_OFFSET) {
162+
*(.toc1)
163+
}
164+
165+
.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
166+
*(.got)
167+
*(.toc)
168+
}
169+
148170
SOFT_MASK_TABLE(8)
149171
RESTART_TABLE(8)
150172

@@ -333,21 +355,11 @@ SECTIONS
333355
*(.data.rel*)
334356
*(SDATA_MAIN)
335357
*(.sdata2)
336-
*(.got.plt) *(.got)
337-
*(.plt)
338-
*(.branch_lt)
339358
}
340359
#else
341360
.data : AT(ADDR(.data) - LOAD_OFFSET) {
342361
DATA_DATA
343362
*(.data.rel*)
344-
*(.toc1)
345-
*(.branch_lt)
346-
}
347-
348-
.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
349-
*(.got)
350-
*(.toc)
351363
}
352364
#endif
353365

0 commit comments

Comments
 (0)