Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM wrongly brings unused local macros to the final closure #18

Open
marcosps opened this issue May 6, 2024 · 0 comments
Open

LLVM wrongly brings unused local macros to the final closure #18

marcosps opened this issue May 6, 2024 · 0 comments
Assignees
Labels
bug Something isn't working kernel Issue found on Linux Kernel LLVM bug Bug residing in LLVM that affects clang-extract

Comments

@marcosps
Copy link
Collaborator

marcosps commented May 6, 2024

When trying to extract function gsmld_open from drivers/tty/n_gsm.c on upstream kernel, the final closure brings not used macros from the original file, like:

#define CR                      0x02                                                                                                 
#define EA                      0x01                                                                                                 
#define PF                      0x10                                                                                                 
#define RR                      0x01                                                                                                 
#define UI                      0x03                                                                                                 
#define RNR                     0x05 

it can be checked by the invocation below:

/usr/local/bin/clang-extract -Wp,-MMD,drivers/tty/.n_gsm.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 -DMODULE -DKBUILD_BASENAME="n_gsm" -DKBUILD_MODNAME="n_gsm" -D__KBUILD_MODNAME=kmod_n_gsm -c -o drivers/tty/n_gsm.o drivers/tty/n_gsm.c -DCE_DEBUGINFO_PATH=/home/mpdesouza/git/linux/drivers/tty/n_gsm.ko -DCE_SYMVERS_PATH=/home/mpdesouza/git/linux/Module.symvers -DCE_OUTPUT_FILE=/home/mpdesouza/kgr/livepatches/gsm_check/ce/linux/work_drivers_tty_n_gsm.c/gsm_check_drivers_tty_n_gsm.c -DCE_OUTPUT_FUNCTION_PROTOTYPE_HEADER=/home/mpdesouza/kgr/livepatches/gsm_check/ce/linux/work_drivers_tty_n_gsm.c/proto.h -DCE_DSC_OUTPUT=/home/mpdesouza/kgr/livepatches/gsm_check/ce/linux/work_drivers_tty_n_gsm.c/lp.dsc -DCE_EXTRACT_FUNCTIONS=gsmld_open -DCE_KEEP_INCLUDES -DCE_RENAME_SYMBOLS

Somehow it remove the unused macros, but it seems that LLVM sees them as used.

@marcosps marcosps added bug Something isn't working LLVM bug Bug residing in LLVM that affects clang-extract kernel Issue found on Linux Kernel labels May 6, 2024
@marcosps marcosps self-assigned this Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kernel Issue found on Linux Kernel LLVM bug Bug residing in LLVM that affects clang-extract
Projects
None yet
Development

No branches or pull requests

1 participant