OSDN Git Service

powerpc: Check prom_init for disallowed sections
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 15 Oct 2018 02:49:59 +0000 (13:49 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 18 Oct 2018 13:56:17 +0000 (00:56 +1100)
prom_init.c must not modify the kernel image outside
of the .bss.prominit section. Thus make sure that
prom_init.o doesn't have anything in any of these:

.data
.bss
.init.data

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/prom_init_check.sh

index acb6b92..667df97 100644 (file)
@@ -28,6 +28,18 @@ OBJ="$2"
 
 ERROR=0
 
+function check_section()
+{
+    file=$1
+    section=$2
+    size=$(objdump -h -j $section $file 2>/dev/null | awk "\$2 == \"$section\" {print \$3}")
+    size=${size:-0}
+    if [ $size -ne 0 ]; then
+       ERROR=1
+       echo "Error: Section $section not empty in prom_init.c" >&2
+    fi
+}
+
 for UNDEF in $($NM -u $OBJ | awk '{print $2}')
 do
        # On 64-bit nm gives us the function descriptors, which have
@@ -66,4 +78,8 @@ do
        fi
 done
 
+check_section $OBJ .data
+check_section $OBJ .bss
+check_section $OBJ .init.data
+
 exit $ERROR