SUSE / clang-extract

Other
7 stars 3 forks source link

clang-extract is not able to rename symbol on tomoyo module #11

Closed marcosps closed 3 months ago

marcosps commented 3 months ago

When trying to extract function tomoyo_write_control on file security/tomoyo/common.c, clang-extract can't rename symbol tomoyo_kernel_namespace:

security/tomoyo/common.c:442:32: error: use of undeclared identifier 'tomoyo_kernel_namespace'                                                                                                                                               
  442 |         list_for_each_entry_rcu(ptr, &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER], head.list,                                                                                                                             
      |                                       ^                                                                                                                                                                                              
security/tomoyo/common.c:442:32: error: use of undeclared identifier 'tomoyo_kernel_namespace'                                                                                                                                               
security/tomoyo/common.c:442:32: error: use of undeclared identifier 'tomoyo_kernel_namespace'                                                                                                                                               
security/tomoyo/common.c:442:32: error: use of undeclared identifier 'tomoyo_kernel_namespace'                                                                                                                                               
security/tomoyo/common.c:442:32: error: use of undeclared identifier 'tomoyo_kernel_namespace'

The command below is able to reproduce the problem on upstream linux kernel.

Attention!

You need to have CONFIG_SECURITY=y and SECURITY_TOMOYO=y to have the file compiled, so the builtin-policy.h is also generated.

clang-extract -Wp,-MMD,security/tomoyo/.common.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-overflow -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-restrict -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g -fsanitize=kernel-address -fasan-shadow-offset=0xdffffc0000000000 --param asan-globals=1 --param asan-instrumentation-with-call-threshold=10000 --param asan-instrument-allocas=1 --param asan-stack=1 --param asan-kernel-mem-intrinsic-prefix=1 -DKBUILD_MODFILE="security/tomoyo/common" -DKBUILD_BASENAME="common" -DKBUILD_MODNAME="common" -D__KBUILD_MODNAME=kmod_common -c -o security/tomoyo/common.o security/tomoyo/common.c -DCE_DEBUGINFO_PATH=vmlinux -DCE_SYMVERS_PATH=Module.symvers -DCE_OUTPUT_FILE=/tmp/bsc111_security_tomoyo_common.c -DCE_EXTRACT_FUNCTIONS=tomoyo_write_control -DCE_KEEP_INCLUDES -DCE_RENAME_SYMBOLS