]> xenbits.xensource.com Git - people/julieng/boot-wrapper-aarch64.git/commitdiff
Protect against overlapping with the 32-bit kernel
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Thu, 8 Oct 2015 09:08:18 +0000 (10:08 +0100)
committerMark Rutland <mark.rutland@arm.com>
Wed, 15 Jun 2016 09:27:35 +0000 (10:27 +0100)
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>
Makefile.am
model.lds.S

index 0e2b92a0215478f99412a612b27b2b5d7a3873a4..5cc7d0b176394ce94f4f81b9dace2af29f15f78b 100644 (file)
@@ -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 $@ -
index c906d0cf1a9b07e08f136e9824a4812e1c62cbe0..f1902e1d213dc950255546da88f77afed3bc133f 100644 (file)
@@ -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!")
 }