how to fix section mismatch warning after inserting #pragma GCC optimize ?

Chan Kim ckim at
Sun Jan 23 05:48:01 EST 2022

Hello all,


In linux 5.4.21 source code, I put

    #pragma GCC push_options

    #pragma GCC optimize ("O0")


    #pragma GCC pop_options

around function static int __init gic_init_bases in file

When I build it, I get this warning message (section mismatch). 

( I later found it is actually the "#pragma GCC optimize ("O0")" line that
is causing it.)  


      CALL    scripts/atomic/

      CALL    scripts/

      CHK     include/generated/compile.h

      CC      arch/arm64/kernel/irq.o

      CC      arch/arm64/kernel/setup.o

      CC      drivers/irqchip/irq-gic-v3.o

      AS      arch/arm64/kernel/head.o

      AR      arch/arm64/kernel/built-in.a

      AR      arch/arm64/built-in.a

      AR      drivers/irqchip/built-in.a

      AR      drivers/built-in.a

      GEN     .version

      CHK     include/generated/compile.h

      UPD     include/generated/compile.h

      CC      init/version.o

      AR      init/built-in.a

      LD      vmlinux.o

      MODPOST vmlinux.o

    WARNING: vmlinux.o(.text+0x227cc0): Section mismatch in reference from
the function gic_smp_init() to the function .init.text:set_smp_cross_call()

    The function gic_smp_init() references

    the function __init set_smp_cross_call().

    This is often because gic_smp_init lacks a __init 

    annotation or the annotation of set_smp_cross_call is wrong.


      MODINFO modules.builtin.modinfo

      LD      .tmp_vmlinux1

      KSYM    .tmp_kallsyms1.o

      LD      .tmp_vmlinux2

      KSYM    .tmp_kallsyms2.o

      LD      vmlinux

      SORTEX  vmlinux


      OBJCOPY arch/arm64/boot/Image


Function call is like this : gic_init_bases -> gic_smp_init() ->
set_smp_cross_call. (currently CONFIG_SMP=y). 

The message seems to say set_smp_cross_call is annotated with __init
(meaning it is placed in .init.text) but gic_smp_init is not. 

But without the #pragma debug setting, there was not warning of this kind. 

I'm not sure if I can just add add __init to gic_smp_init(). (or remove
_init from set_smp_cross_call )

What is the correct method to fix it?


Chan Kim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kernelnewbies mailing list