linux kernel中的asm-offsets.c

本文详细介绍了在汇编语言中使用结构体时如何自动化处理成员偏移量的问题。通过DEFINE宏结合sed等工具,自动生成宏定义,确保结构体变化时偏移量始终正确。这一机制在Linux kernel的开发中尤为重要。

1 在汇编中使用结构体

首先考虑一下结构体:

struct test
{
	int a;
	int b;
}

这个结构体很简单,只是用来举例子。在c语言中,如果我们要访问结构体中的某个成员,这非常容易:

struct test t;
t.a = 1;

假如我们想知道结构体中某个成员在结构体中的偏移,这也不难,比如linux kernel就提供了offsetof宏来实现这个功能:

offsetof(struct test, b) /* 得到的就是成员b在结构体中的偏移 */

这一切在c语言中都平平无奇,但是考虑这样一个需求:我们需要在汇编语言中使用结构体。这时候怎么办呢?汇编文件里用c的语法定义结构体肯定是不行的,现实的做法是,把结构体的首地址存放在某个寄存器里,然后只要知道各个成员的偏移,就可以通过首地址+偏移的方式寻址到某个具体的成员。

于是,问题的关键来了。我们怎么获取到各个成员的偏移呢?仍旧使用offsetof宏肯定是不行的,汇编器根本不认识c的语法。最容易想到的方法就是手工算好偏移,然后用于汇编,考虑到程序的可读性,这个偏移用宏定义的形式给出:

#define A_OFFSET (0)
#define B_OFFSET (4)

但这样就是硬编码,万一结构体的成员有变动,那维护起来很麻烦。我们期待的是类似offsetof宏那样的解决方法,不管结构体怎么变,都让编译器帮我们计算好偏移,这样偏移总是正确的,但这在汇编里面不可行。对于这一矛盾,kernel的解决办法是,在c文件中使用offsetof算出偏移量,然后想办法自动化 的把算出来的偏移量表示成宏定义,之后再汇编里包含相应头文件。这样,汇编文件直接使用宏定义就可以总是正确的得到结构体中成员的偏移量。如此一来,在汇编中使用结构体,让数据组织的更有结构,就完全可行了。在kernel中实现上述功能的c文件通常被命名为asm-offsets.c,自动生成的表示偏移量的宏被存放在自动生成的头文件中,这个头文件被命名为asm-offsets.h

那么这一切到底是怎么做到的呢?这就不得不提asm-offsets.c使用到的一个宏DEFINE,这个宏是自动生成asm-offsets.h的关键。

2 DEFINE宏

首先给出DEFINE的定义:

#define DEFINE(sym, val) \
	asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))

这真是好奇怪的一个宏,虽然内联汇编并不稀罕,但这样的内联汇编确实少见。这个宏在asm-offsets.c中是这么使用的,假如我需要上文的struct test的成员的偏移,那么需要在asm-offsets.c中写出如下代码:

int main(void)
{
	DEFINE(TEST_A, offsetof(struct test, a));
	DEFINE(TEST_B, offsetof(struct test, b));
}

接下来,将asm-offsets.c编译成asm-offsets.s,注意这里的编译是狭义上的编译,即只编译不汇编。仍旧以本例来说,编译后,asm-offsets.s的内容(只选其中关键内容,不是所有内容)如下:

.ascii "->TEST_A #0 offsetof(struct test, a)"
.ascii "->TEST_B #4 offsetof(struct test, b)"

可以看到,上述内容已经包含了宏名以及偏移量(#0、#4),但还不是一个合法的c语言宏定义的形式。接下来怎么得到asm-offsets.h呢?kernel采取的做法很直接,直接使用sedecho等工具,来匹配文本,处理文本,并生成相应的asm-offsets.h。更细一点说,从上述文本中提取出三部分内容:

作为宏名:TEST_A
作为偏移:0
作为注释:offsetof(struct test, a)

作为宏名:TEST_B
作为偏移:4
作为注释:offsetof(struct test, b)

最终生成的asm-offsets.h大体如下:

#define TEST_A 0 /* offsetof(struct test, a) */
#define TEST_B 4 /* offsetof(struct test, b) */

当然,除了结构体中的成员偏移,我们还可以用DEFINE来定义供汇编文件使用 的表示结构体大小的宏,如:

DEFINE(TEST_SIZE, sizeof(struct test));

DEFINE外加后续的处理只是机制,只要机制有了,就可以玩出花来。要是没有机制呢?kernel开发者就会想办法把机制构建出来。

参考文献

[1] What’s purpose of “arm64/kernel/asm-offsets.c”?
[2] lib/asm-offsets.c的作用

xj@xj-virtual-machine:~/linux/kernel_code/uboot$ make V=1 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- DEVICE_TREE=stm32mp157d-atk all make -f ./Makefile syncconfig make -f ./scripts/Makefile.build obj=scripts/basic rm -f .tmp_quiet_recordmcount make -f ./scripts/Makefile.build obj=scripts/kconfig syncconfig mkdir -p include/config include/generated scripts/kconfig/conf --syncconfig Kconfig make -f ./scripts/Makefile.autoconf || \ { rm -f include/config/auto.conf; false; } if [ -d arch/arm/mach-stm32mp/include/mach ]; then \ dest=../../mach-stm32mp/include/mach; \ else \ dest=arch-stm32mp; \ fi; \ ln -fsn $dest arch/arm/include/asm/arch set -e; : ' CHK include/config.h'; mkdir -p include/; (echo "/* Automatically generated - do not edit */"; for i in $(echo "" | sed 's/,/ /g'); do echo \#define CONFIG_$i | sed '/=/ {s/=/ /;q; } ; { s/$/ 1/; }'; done; echo \#define CONFIG_BOARDDIR board/st/stm32mp1; echo \#include \<config_defaults.h\>; echo \#include \<config_uncmd_spl.h\>; echo \#include \<configs/"stm32mp1".h\>; echo \#include \<asm/config.h\>; echo \#include \<linux/kconfig.h\>; echo \#include \<config_fallbacks.h\>;) < scripts/Makefile.autoconf > include/config.h.tmp; if [ -r include/config.h ] && cmp -s include/config.h include/config.h.tmp; then rm -f include/config.h.tmp; else : ' UPD include/config.h'; mv -f include/config.h.tmp include/config.h; fi arm-none-linux-gnueabihf-gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -O2 -fno-stack-protector -fno-delete-null-pointer-checks -fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -D__KERNEL__ -D__UBOOT__ -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -nostdinc -isystem /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -DDO_DEPS_ONLY -dM ./include/common.h > u-boot.cfg.tmp && { grep 'define CONFIG_' u-boot.cfg.tmp > u-boot.cfg; rm u-boot.cfg.tmp; } || { rm u-boot.cfg.tmp; false; } sed -n -f ./tools/scripts/define2mk.sed u-boot.cfg | while read line; do if [ -n "" ] || ! grep -q "${line%=*}=" include/config/auto.conf; then echo "$line"; fi done > include/autoconf.mk arm-none-linux-gnueabihf-gcc -x c -DDO_DEPS_ONLY -M -MP -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -O2 -fno-stack-protector -fno-delete-null-pointer-checks -fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -D__KERNEL__ -D__UBOOT__ -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -nostdinc -isystem /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -MQ include/config/auto.conf ./include/common.h > include/autoconf.mk.dep || { rm include/autoconf.mk.dep; false; } touch include/config/auto.conf set -e; : ' CHK include/config/uboot.release'; mkdir -p include/config/; echo "2020.01-stm32mp-r1$(/bin/bash ./scripts/setlocalversion .)" < include/config/auto.conf > include/config/uboot.release.tmp; if [ -r include/config/uboot.release ] && cmp -s include/config/uboot.release include/config/uboot.release.tmp; then rm -f include/config/uboot.release.tmp; else : ' UPD include/config/uboot.release'; mv -f include/config/uboot.release.tmp include/config/uboot.release; fi set -e; : ' CHK include/generated/version_autogenerated.h'; mkdir -p include/generated/; (echo \#define PLAIN_VERSION \"2020.01-stm32mp-r1""\"; echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; echo \#define CC_VERSION_STRING \"$(LC_ALL=C arm-none-linux-gnueabihf-gcc --version | head -n 1)\"; echo \#define LD_VERSION_STRING \"$(LC_ALL=C arm-none-linux-gnueabihf-ld.bfd --version | head -n 1)\"; ) < include/config/uboot.release > include/generated/version_autogenerated.h.tmp; if [ -r include/generated/version_autogenerated.h ] && cmp -s include/generated/version_autogenerated.h include/generated/version_autogenerated.h.tmp; then rm -f include/generated/version_autogenerated.h.tmp; else : ' UPD include/generated/version_autogenerated.h'; mv -f include/generated/version_autogenerated.h.tmp include/generated/version_autogenerated.h; fi set -e; : ' CHK include/generated/timestamp_autogenerated.h'; mkdir -p include/generated/; (if test -n "${SOURCE_DATE_EPOCH}"; then SOURCE_DATE="@${SOURCE_DATE_EPOCH}"; DATE=""; for date in gdate date.gnu date; do ${date} -u -d "${SOURCE_DATE}" >/dev/null 2>&1 && DATE="${date}"; done; if test -n "${DATE}"; then LC_ALL=C ${DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"'; LC_ALL=C ${DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"'; LC_ALL=C ${DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"'; LC_ALL=C ${DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; LC_ALL=C ${DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; else return 42; fi; else LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; LC_ALL=C date +'#define U_BOOT_TIME "%T"'; LC_ALL=C date +'#define U_BOOT_TZ "%z"'; LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; LC_ALL=C date +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; fi) < Makefile > include/generated/timestamp_autogenerated.h.tmp; if [ -r include/generated/timestamp_autogenerated.h ] && cmp -s include/generated/timestamp_autogenerated.h include/generated/timestamp_autogenerated.h.tmp; then rm -f include/generated/timestamp_autogenerated.h.tmp; else : ' UPD include/generated/timestamp_autogenerated.h'; mv -f include/generated/timestamp_autogenerated.h.tmp include/generated/timestamp_autogenerated.h; fi make -f ./scripts/Makefile.build obj=scripts/basic rm -f .tmp_quiet_recordmcount make -f ./scripts/Makefile.build obj=. mkdir -p lib/ arm-none-linux-gnueabihf-gcc -Wp,-MD,lib/.asm-offsets.s.d -nostdinc -isystem /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -mtune=generic-armv7-a -I./arch/arm/mach-stm32mp/include -DDO_DEPS_ONLY -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(asm_offsets)" -D"KBUILD_MODNAME=KBUILD_STR(asm_offsets)" -fverbose-asm -S -o lib/asm-offsets.s lib/asm-offsets.c set -e; : ' CHK include/generated/generic-asm-offsets.h'; mkdir -p include/generated/; (set -e; echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; echo "#define __GENERIC_ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " */"; echo ""; sed -ne "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; /^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < lib/asm-offsets.s > include/generated/generic-asm-offsets.h.tmp; if [ -r include/generated/generic-asm-offsets.h ] && cmp -s include/generated/generic-asm-offsets.h include/generated/generic-asm-offsets.h.tmp; then rm -f include/generated/generic-asm-offsets.h.tmp; else : ' UPD include/generated/generic-asm-offsets.h'; mv -f include/generated/generic-asm-offsets.h.tmp include/generated/generic-asm-offsets.h; fi mkdir -p arch/arm/lib/ arm-none-linux-gnueabihf-gcc -Wp,-MD,arch/arm/lib/.asm-offsets.s.d -nostdinc -isystem /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -mtune=generic-armv7-a -I./arch/arm/mach-stm32mp/include -DDO_DEPS_ONLY -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(asm_offsets)" -D"KBUILD_MODNAME=KBUILD_STR(asm_offsets)" -fverbose-asm -S -o arch/arm/lib/asm-offsets.s arch/arm/lib/asm-offsets.c set -e; : ' CHK include/generated/asm-offsets.h'; mkdir -p include/generated/; (set -e; echo "#ifndef __ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " */"; echo ""; sed -ne "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; /^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < arch/arm/lib/asm-offsets.s > include/generated/asm-offsets.h.tmp; if [ -r include/generated/asm-offsets.h ] && cmp -s include/generated/asm-offsets.h include/generated/asm-offsets.h.tmp; then rm -f include/generated/asm-offsets.h.tmp; else : ' UPD include/generated/asm-offsets.h'; mv -f include/generated/asm-offsets.h.tmp include/generated/asm-offsets.h; fi
06-13
tp@ubuntu:~/Project/Iford_IMD00V5.1.1/Iford/SourceCode/kernel$ grep -r 'CONFIG_STACKPROTECTOR' . ./kernel/panic.c:#ifdef CONFIG_STACKPROTECTOR ./kernel/configs/android-recommended.config:CONFIG_STACKPROTECTOR_STRONG=y ./kernel/fork.c:#ifdef CONFIG_STACKPROTECTOR ./.config.old:# CONFIG_STACKPROTECTOR is not set ./.config.old:# CONFIG_STACKPROTECTOR_STRONG is not set ./Makefile:stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector ./Makefile:stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong ./.config:CONFIG_STACKPROTECTOR=y ./.config:CONFIG_STACKPROTECTOR_STRONG=y ./include/generated/autoconf.h:#define CONFIG_STACKPROTECTOR_STRONG 1 ./include/generated/autoconf.h:#define CONFIG_STACKPROTECTOR 1 ./include/linux/sched.h:#ifdef CONFIG_STACKPROTECTOR ./include/linux/stackprotector.h:#if defined(CONFIG_STACKPROTECTOR) || defined(CONFIG_ARM64_PTR_AUTH) ./arch/csky/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR ./arch/arm64/Kconfig: support pointer authentication, then CONFIG_STACKPROTECTOR can be ./arch/arm64/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR ./arch/arm64/kernel/process.c:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK) ./arch/arm64/Makefile:ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y) ./arch/arm64/include/asm/stackprotector.h:#if defined(CONFIG_STACKPROTECTOR) ./arch/arm64/include/asm/stackprotector.h: if (!IS_ENABLED(CONFIG_STACKPROTECTOR_PER_TASK)) ./arch/xtensa/kernel/entry.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/xtensa/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR ./arch/xtensa/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR ./arch/mips/kernel/r2300_switch.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/mips/kernel/octeon_switch.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/mips/kernel/asm-offsets.c:#if defined(CONFIG_STACKPROTECTOR) ./arch/mips/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR ./arch/mips/kernel/r4k_switch.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/mips/configs/rs90_defconfig:# CONFIG_STACKPROTECTOR is not set ./arch/x86/kernel/cpu/common.c:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/kernel/head_32.S:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/kernel/asm-offsets_64.c:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/kernel/asm-offsets_32.c:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/entry/entry_32.S:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/entry/entry_64.S:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/include/asm/stackprotector.h:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/include/asm/segment.h:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/include/asm/processor.h:#ifdef CONFIG_STACKPROTECTOR ./arch/x86/purgatory/Makefile:ifdef CONFIG_STACKPROTECTOR ./arch/x86/purgatory/Makefile:ifdef CONFIG_STACKPROTECTOR_STRONG ./arch/arm/kernel/entry-armv.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/arm/kernel/entry-armv.S:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/arm/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR ./arch/arm/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR_PER_TASK ./arch/arm/kernel/process.c:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK) ./arch/arm/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR_PER_TASK ./arch/arm/configs/iford_ssc029d_s01a_spinand_fastboot_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_lh_nor_demo_dualsnr_rt_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_fpga_lh_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_spinand_fastboot_demo_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029d_s01a_emmc_fastboot_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029c_s01a_vm_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029d_s01a_emmc_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029b_s01a_lh_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_lh_spinand_demo_dualsnr_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_lh_nor_demo_dualsnr_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029a_s01a_vm_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029b_s01a_vm_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029a_s01a_lh_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_fastboot_demo_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssz029c_s01b_lh_nor_demo_dualsnr_usbcam_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029d_s01a_fastboot_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029d_s01a_demo_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029a_s01a_lh_tiny_spinand_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/configs/iford_ssc029b_s01a_lh_nor_defconfig:# CONFIG_STACKPROTECTOR_STRONG is not set ./arch/arm/Makefile:ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y) ./arch/arm/include/asm/thread_info.h:#ifdef CONFIG_STACKPROTECTOR_PER_TASK ./arch/arm/include/asm/stackprotector.h:#ifndef CONFIG_STACKPROTECTOR_PER_TASK ./arch/riscv/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR ./arch/sh/kernel/process_32.c:#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) ./arch/sh/kernel/process.c:#ifdef CONFIG_STACKPROTECTOR ./arch/powerpc/kernel/asm-offsets.c:#ifdef CONFIG_STACKPROTECTOR ./arch/powerpc/kernel/entry_64.S:#if defined(CONFIG_STACKPROTECTOR) ./arch/powerpc/Makefile:cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls ./arch/powerpc/Makefile:cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13 ./arch/powerpc/Makefile:cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2 ./arch/powerpc/Makefile:ifdef CONFIG_STACKPROTECTOR ./arch/powerpc/include/asm/paca.h:#ifdef CONFIG_STACKPROTECTOR ./arch/powerpc/xmon/xmon.c:#ifdef CONFIG_STACKPROTECTOR ./Documentation/security/self-protection.rst:return address (``CONFIG_STACKPROTECTOR``), which is verified just before 这个功能是在哪里启用的
最新发布
10-12
mouse@mouse-virtual-machine:~/workspace/kernel/linux-4.19.3$ make -j8 scripts/kconfig/conf --syncconfig Kconfig SYSTBL arch/x86/include/generated/asm/syscalls_32.h SYSHDR arch/x86/include/generated/asm/unistd_32_ia32.h SYSTBL arch/x86/include/generated/asm/syscalls_64.h SYSHDR arch/x86/include/generated/asm/unistd_64_x32.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_64.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_32.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_x32.h UPD include/config/kernel.release WRAP arch/x86/include/generated/uapi/asm/bpf_perf_event.h WRAP arch/x86/include/generated/uapi/asm/poll.h UPD include/generated/uapi/linux/version.h UPD include/generated/utsrelease.h DESCEND objtool HOSTCC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep.o HOSTLD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep-in.o LINK /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/builtin-check.o GEN /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/lib/inat-tables.c CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/decode.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/exec-cmd.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/builtin-orc.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/help.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/pager.o In file included from help.c:12: In function ‘xrealloc’, inlined from ‘add_cmdname’ at help.c:24:2: subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free] 56 | ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to ‘realloc’ here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free] 58 | ret = realloc(ptr, 1); | ^~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to ‘realloc’ here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/check.o cc1: all warnings being treated as errors mv: 对 '/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/.help.o.tmp' 调用 stat 失败: 没有那个文件或目录 make[4]: *** [/home/mouse/workspace/kernel/linux-4.19.3/tools/build/Makefile.build:96:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/help.o] 错误 1 make[3]: *** [Makefile:52:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libsubcmd-in.o] 错误 2 make[2]: *** [Makefile:54:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libsubcmd.a] 错误 2 make[2]: *** 正在等待未完成的任务.... CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/orc_gen.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/orc_dump.o LD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/objtool-in.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/elf.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/special.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/objtool.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libstring.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/str_error_r.o HOSTCC arch/x86/tools/relocs_32.o HOSTCC arch/x86/tools/relocs_64.o WRAP arch/x86/include/generated/asm/dma-contiguous.h HOSTCC arch/x86/tools/relocs_common.o WRAP arch/x86/include/generated/asm/early_ioremap.h WRAP arch/x86/include/generated/asm/export.h WRAP arch/x86/include/generated/asm/mcs_spinlock.h WRAP arch/x86/include/generated/asm/mm-arch-hooks.h CC scripts/mod/empty.o HOSTCC scripts/mod/mk_elfconfig HOSTLD arch/x86/tools/relocs CC scripts/mod/devicetable-offsets.s LD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/objtool-in.o make[1]: *** [Makefile:63:objtool] 错误 2 make: *** [Makefile:1644:tools/objtool] 错误 2 make: *** 正在等待未完成的任务.... MKELF scripts/mod/elfconfig.h HOSTCC scripts/kallsyms HOSTCC scripts/selinux/genheaders/genheaders In file included from scripts/selinux/genheaders/genheaders.c:19: ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map. 249 | #error New address family defined, please update secclass_map. | ^~~~~ HOSTCC scripts/selinux/mdp/mdp make[3]: *** [scripts/Makefile.host:90:scripts/selinux/genheaders/genheaders] 错误 1 make[2]: *** [scripts/Makefile.build:546:scripts/selinux/genheaders] 错误 2 make[2]: *** 正在等待未完成的任务.... HOSTCC scripts/mod/modpost.o HOSTCC scripts/pnmtologo In file included from scripts/selinux/mdp/mdp.c:49: ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map. 249 | #error New address family defined, please update secclass_map. | ^~~~~ make[3]: *** [scripts/Makefile.host:90:scripts/selinux/mdp/mdp] 错误 1 make[2]: *** [scripts/Makefile.build:546:scripts/selinux/mdp] 错误 2 make[1]: *** [scripts/Makefile.build:546:scripts/selinux] 错误 2 make[1]: *** 正在等待未完成的任务.... UPD scripts/mod/devicetable-offsets.h HOSTCC scripts/mod/sumversion.o HOSTCC scripts/mod/file2alias.o HOSTLD scripts/mod/modpost make: *** [Makefile:1067:scripts] 错误 2
08-06
mouse@mouse-virtual-machine:~/workspace/kernel/linux-4.19.3$ make -j8 scripts/kconfig/conf --syncconfig Kconfig SYSTBL arch/x86/include/generated/asm/syscalls_32.h SYSHDR arch/x86/include/generated/asm/unistd_32_ia32.h SYSTBL arch/x86/include/generated/asm/syscalls_64.h SYSHDR arch/x86/include/generated/asm/unistd_64_x32.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_64.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_32.h SYSHDR arch/x86/include/generated/uapi/asm/unistd_x32.h UPD include/config/kernel.release WRAP arch/x86/include/generated/uapi/asm/bpf_perf_event.h WRAP arch/x86/include/generated/uapi/asm/poll.h UPD include/generated/uapi/linux/version.h UPD include/generated/utsrelease.h DESCEND objtool HOSTCC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep.o HOSTLD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep-in.o LINK /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/fixdep CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/builtin-check.o GEN /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/lib/inat-tables.c CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/decode.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/exec-cmd.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/builtin-orc.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/help.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/pager.o In file included from help.c:12: In function ‘xrealloc’, inlined from ‘add_cmdname’ at help.c:24:2: subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free] 56 | ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to ‘realloc’ here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free] 58 | ret = realloc(ptr, 1); | ^~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to ‘realloc’ here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/check.o cc1: all warnings being treated as errors mv: 对 ‘/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/.help.o.tmp’ 调用 stat 失败: 没有那个文件或目录 make[4]: *** [/home/mouse/workspace/kernel/linux-4.19.3/tools/build/Makefile.build:96:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/help.o] 错误 1 make[3]: *** [Makefile:52:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libsubcmd-in.o] 错误 2 make[2]: *** [Makefile:54:/home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libsubcmd.a] 错误 2 make[2]: *** 正在等待未完成的任务… CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/orc_gen.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/orc_dump.o LD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/arch/x86/objtool-in.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/elf.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/special.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/objtool.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/libstring.o CC /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/str_error_r.o HOSTCC arch/x86/tools/relocs_32.o HOSTCC arch/x86/tools/relocs_64.o WRAP arch/x86/include/generated/asm/dma-contiguous.h HOSTCC arch/x86/tools/relocs_common.o WRAP arch/x86/include/generated/asm/early_ioremap.h WRAP arch/x86/include/generated/asm/export.h WRAP arch/x86/include/generated/asm/mcs_spinlock.h WRAP arch/x86/include/generated/asm/mm-arch-hooks.h CC scripts/mod/empty.o HOSTCC scripts/mod/mk_elfconfig HOSTLD arch/x86/tools/relocs CC scripts/mod/devicetable-offsets.s LD /home/mouse/workspace/kernel/linux-4.19.3/tools/objtool/objtool-in.o make[1]: *** [Makefile:63:objtool] 错误 2 make: *** [Makefile:1644:tools/objtool] 错误 2 make: *** 正在等待未完成的任务… MKELF scripts/mod/elfconfig.h HOSTCC scripts/kallsyms HOSTCC scripts/selinux/genheaders/genheaders In file included from scripts/selinux/genheaders/genheaders.c:19: ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map. 249 | #error New address family defined, please update secclass_map. | ^~~~~ HOSTCC scripts/selinux/mdp/mdp make[3]: *** [scripts/Makefile.host:90:scripts/selinux/genheaders/genheaders] 错误 1 make[2]: *** [scripts/Makefile.build:546:scripts/selinux/genheaders] 错误 2 make[2]: *** 正在等待未完成的任务… HOSTCC scripts/mod/modpost.o HOSTCC scripts/pnmtologo In file included from scripts/selinux/mdp/mdp.c:49: ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map. 249 | #error New address family defined, please update secclass_map. | ^~~~~ make[3]: *** [scripts/Makefile.host:90:scripts/selinux/mdp/mdp] 错误 1 make[2]: *** [scripts/Makefile.build:546:scripts/selinux/mdp] 错误 2 make[1]: *** [scripts/Makefile.build:546:scripts/selinux] 错误 2 make[1]: *** 正在等待未完成的任务… UPD scripts/mod/devicetable-offsets.h HOSTCC scripts/mod/sumversion.o HOSTCC scripts/mod/file2alias.o HOSTLD scripts/mod/modpost make: *** [Makefile:1067:scripts] 错误 2
08-06
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值