Skip to content

Commit

Permalink
powerpc/build: move got, toc, plt, branch_lt sections to read-only
Browse files Browse the repository at this point in the history
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 <npiggin@gmail.com>
  • Loading branch information
npiggin authored and intel-lab-lkp committed Sep 16, 2022
1 parent 0b705b5 commit 6c034c0
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions arch/powerpc/kernel/vmlinux.lds.S
Expand Up @@ -131,6 +131,10 @@ SECTIONS
/* Read-only data */
RO_DATA(PAGE_SIZE)

.branch_lt : AT(ADDR(.branch_lt) - LOAD_OFFSET) {
*(.branch_lt)
}

#ifdef CONFIG_PPC32
.got1 : AT(ADDR(.got1) - LOAD_OFFSET) {
*(.got1)
Expand All @@ -140,7 +144,30 @@ SECTIONS
*(.got2)
__got2_end = .;
}
.got : AT(ADDR(.got) - LOAD_OFFSET) SPECIAL {
*(.got)
*(.got.plt)
}
.plt : AT(ADDR(.plt) - LOAD_OFFSET) SPECIAL {
/* XXX: is .plt (and .got.plt) required? */
*(.plt)
}

#else /* CONFIG_PPC32 */
.toc1 : AT(ADDR(.toc1) - LOAD_OFFSET) {
*(.toc1)
}

.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
*(.got)
#ifndef CONFIG_RELOCATABLE
__prom_init_toc_start = .;
arch/powerpc/kernel/prom_init.o*(.toc)
__prom_init_toc_end = .;
#endif
*(.toc)
}

SOFT_MASK_TABLE(8)
RESTART_TABLE(8)

Expand Down Expand Up @@ -327,26 +354,11 @@ SECTIONS
*(.data.rel*)
*(SDATA_MAIN)
*(.sdata2)
*(.got.plt) *(.got)
*(.plt)
*(.branch_lt)
}
#else
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
*(.data.rel*)
*(.toc1)
*(.branch_lt)
}

.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
*(.got)
#ifndef CONFIG_RELOCATABLE
__prom_init_toc_start = .;
arch/powerpc/kernel/prom_init.o*(.toc)
__prom_init_toc_end = .;
#endif
*(.toc)
}
#endif

Expand Down

0 comments on commit 6c034c0

Please sign in to comment.