hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/arch/powerpc/kernel/prom_init_check.sh
....@@ -1,11 +1,8 @@
11 #!/bin/sh
2
+# SPDX-License-Identifier: GPL-2.0-or-later
23 #
34 # Copyright © 2008 IBM Corporation
45 #
5
-# This program is free software; you can redistribute it and/or
6
-# modify it under the terms of the GNU General Public License
7
-# as published by the Free Software Foundation; either version
8
-# 2 of the License, or (at your option) any later version.
96
107 # This script checks prom_init.o to see what external symbols it
118 # is using, if it finds symbols not in the whitelist it returns
....@@ -16,17 +13,38 @@
1613 # If you really need to reference something from prom_init.o add
1714 # it to the list below:
1815
16
+grep "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} >/dev/null
17
+if [ $? -eq 0 ]
18
+then
19
+ MEM_FUNCS="__memcpy __memset"
20
+else
21
+ MEM_FUNCS="memcpy memset"
22
+fi
23
+
1924 WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
20
-_end enter_prom memcpy memset reloc_offset __secondary_hold
25
+_end enter_prom $MEM_FUNCS reloc_offset __secondary_hold
2126 __secondary_hold_acknowledge __secondary_hold_spinloop __start
22
-strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224
27
+logo_linux_clut224 btext_prepare_BAT
2328 reloc_got2 kernstart_addr memstart_addr linux_banner _stext
24
-__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
29
+__prom_init_toc_start __prom_init_toc_end btext_setup_display TOC.
30
+relocate"
2531
2632 NM="$1"
2733 OBJ="$2"
2834
2935 ERROR=0
36
+
37
+check_section()
38
+{
39
+ file=$1
40
+ section=$2
41
+ size=$(objdump -h -j $section $file 2>/dev/null | awk "\$2 == \"$section\" {print \$3}")
42
+ size=${size:-0}
43
+ if [ $size -ne 0 ]; then
44
+ ERROR=1
45
+ echo "Error: Section $section not empty in prom_init.c" >&2
46
+ fi
47
+}
3048
3149 for UNDEF in $($NM -u $OBJ | awk '{print $2}')
3250 do
....@@ -66,4 +84,8 @@
6684 fi
6785 done
6886
87
+check_section $OBJ .data
88
+check_section $OBJ .bss
89
+check_section $OBJ .init.data
90
+
6991 exit $ERROR