aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2015-10-08 10:08:18 +0100
committerMark Rutland <mark.rutland@arm.com>2016-06-15 10:27:35 +0100
commit5933e49b6f45fa18dd1e32d14372bb60837ff954 (patch)
tree79928d6bffb9fd92731e89c55a8dad9ed8faf6bc
parent259bef910fee48a927e4700e9e82f99e94962098 (diff)
downloadboot-wrapper-aarch64-5933e49b6f45fa18dd1e32d14372bb60837ff954.tar.gz
Protect against overlapping with the 32-bit kernel
This patch adds a guard in the linker script to abort the build when the bootloader code overflows the 12k limit. Indeed, 32-bit Linux with LPAE enabled puts its initial page tables between 0x80003000 and 0x80007fff. Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
-rw-r--r--Makefile.am4
-rw-r--r--model.lds.S3
2 files changed, 6 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 0e2b92a..5cc7d0b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,9 +71,11 @@ endif
if KERNEL_32
MBOX_OFFSET := 0x7ff8
KERNEL_OFFSET := 0x8000
+TEXT_LIMIT := 0x80003000
else
MBOX_OFFSET := 0xfff8
KERNEL_OFFSET := 0x80000
+TEXT_LIMIT := 0x80080000
endif
LD_SCRIPT := model.lds.S
@@ -123,7 +125,7 @@ $(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM)
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
model.lds: $(LD_SCRIPT) Makefile
- $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -P -C -o $@ $<
+ $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $<
fdt.dtb: $(KERNEL_DTB) Makefile gen-cpu-nodes.sh
( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) $(CPUS_NODE) };" ) | $(DTC) -O dtb -o $@ -
diff --git a/model.lds.S b/model.lds.S
index c906d0c..f1902e1 100644
--- a/model.lds.S
+++ b/model.lds.S
@@ -49,10 +49,13 @@ SECTIONS
*(.text* .data* .rodata* .bss* COMMON)
*(.vectors)
*(.stack)
+ PROVIDE(etext = .);
}
.mbox (PHYS_OFFSET + MBOX_OFFSET): {
mbox = .;
QUAD(0x0)
}
+
+ ASSERT(etext <= TEXT_LIMIT, ".text overflow!")
}