Commit 069fd766 authored by Matt Redfearn's avatar Matt Redfearn Committed by Ralf Baechle

MIPS: Reserve space for relocation table

When CONFIG_RELOCATABLE is enabled, add a new section in the memory map
to be filled with relocation data.

CONFIG_RELOCATION_TABLE_SIZE allows the amount of space reserved to be
adjusted if necessary.

The relocs tool will populate this reserved space with relocation
information. The space is reserved within the elf by filling it with
0's, and an invalid entry is left at the start of the space such that
kernel relocation will be aborted if the table is empty.
Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
Cc: Aaro Koskinen <aaro.koskinen@nokia.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Cc: Jonas Gorski <jogo@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: kernel-hardening@lists.openwall.com
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/12982/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent aadeec4d
...@@ -2473,6 +2473,22 @@ config NUMA ...@@ -2473,6 +2473,22 @@ config NUMA
config SYS_SUPPORTS_NUMA config SYS_SUPPORTS_NUMA
bool bool
config RELOCATION_TABLE_SIZE
hex "Relocation table size"
depends on RELOCATABLE
range 0x0 0x01000000
default "0x00100000"
---help---
A table of relocation data will be appended to the kernel binary
and parsed at boot to fix up the relocated kernel.
This option allows the amount of space reserved for the table to be
adjusted, although the default of 1Mb should be ok in most cases.
The build will fail and a valid size suggested if this is too small.
If unsure, leave at the default value.
config NODES_SHIFT config NODES_SHIFT
int int
default "6" default "6"
......
...@@ -136,6 +136,27 @@ SECTIONS ...@@ -136,6 +136,27 @@ SECTIONS
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT) PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
#endif #endif
#ifdef CONFIG_RELOCATABLE
. = ALIGN(4);
.data.reloc : {
_relocation_start = .;
/*
* Space for relocation table
* This needs to be filled so that the
* relocs tool can overwrite the content.
* An invalid value is left at the start of the
* section to abort relocation if the table
* has not been filled in.
*/
LONG(0xFFFFFFFF);
FILL(0);
. += CONFIG_RELOCATION_TABLE_SIZE - 4;
_relocation_end = .;
}
#endif
#ifdef CONFIG_MIPS_RAW_APPENDED_DTB #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
__appended_dtb = .; __appended_dtb = .;
/* leave space for appended DTB */ /* leave space for appended DTB */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment