error: impossible constraint in 'asm' when compiling kernel code with -O0 option

jim.cromie at gmail.com jim.cromie at gmail.com
Thu Oct 7 18:29:29 EDT 2021


On Tue, Oct 5, 2021 at 9:00 PM <ckim at etri.re.kr> wrote:
>
> In linux-5.4.21 code,
>
> To prevent some variables from being ‘optimized out’ during kernel code analysis using gdb, I added in drivers/iommu/Makefile,
>
> (replacing -O2 flags to -O0 flags for some files,  I found http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )
>
> CFLAGS_REMOVE_arm-smmu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-impl.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm.o := -O2
>
> CFLAGS_REMOVE_of_iommu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-v3.o := -O2
>
> CFLAGS_arm-smmu.o := -O0
>
> CFLAGS_arm-smmu-impl.o := -O0
>
> CFLAGS_io-pgtable-arm-v7s.o := -O0
>
> CFLAGS_io-pgtable-arm.o := -O0
>
> CFLAGS_of_iommu.o := -O0
>
> CFLAGS_arm-smmu-v3.o := -O0
>
> But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get
>
> CALL    scripts/checksyscalls.sh
>
>   CALL    scripts/atomic/check-atomics.sh
>
>   CHK     include/generated/compile.h
>
>   CC      drivers/iommu/io-pgtable-arm.o
>

try
make   drivers/iommu/io-pgtable-arm.i
it will show you intermediate output.

I did it on kernel/params.i  ( wrong config to run yours)

you will find the asm goto code therein

[jimc at samwise lm-sept]$ less +/jump_label kernel/params.i

# 53 "/home/jimc/projects/lx/wk-next/arch/x86/include/asm/jump_label.h"
static inline __attribute__((__gnu_inline__))
__attribute__((__unused__)) __attribute__((no_instrument_function))
__attribute__((__always_inline__)) boo
l arch_static_branch_jump(struct static_key * const key, const bool branch)
{
 do { asm goto("1:" "jmp %l[l_yes]\n\t" ".pushsection __jump_table,
\"aw\" \n\t" " " ".balign 8" " " "\n\t" ".long 1b - . \n\t" ".long
%l[l_yes] - . \n
\t" " " ".quad" " " "%c0 + %c1 - .\n\t" ".popsection \n\t" : : "i"
(key), "i" (branch) : : l_yes); asm (""); } while (0)


                                         ;

 return false;
l_yes:
 return true;
}

extern int arch_jump_entry_size(struct jump_entry *entry);
# 118 "/home/jimc/projects/lx/wk-next/include/linux/jump_label.h" 2



More information about the Kernelnewbies mailing list