<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
text-autospace:none;
word-break:break-hangul;
font-size:10.0pt;
font-family:"Malgun Gothic";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Malgun Gothic";
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Malgun Gothic";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:3.0cm 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=KO link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>I found adding __init to gic_smp_init() removed this warning message.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Is it ok to move this function to .init.text ? (doesn’t it cause it to be removed after initialization?)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Chan<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal align=left style='text-align:left;text-autospace:ideograph-numeric ideograph-other;word-break:keep-all'><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Chan Kim <ckim@etri.re.kr> <br><b>Sent:</b> Sunday, January 23, 2022 7:48 PM<br><b>To:</b> kernelnewbies@kernelnewbies.org<br><b>Subject:</b> how to fix section mismatch warning after inserting #pragma GCC optimize ?<o:p></o:p></span></p></div></div><p class=MsoNormal align=left style='text-align:left'><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Hello all,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>In linux 5.4.21 source code, I put<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> #pragma GCC push_options<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> #pragma GCC optimize ("O0")<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>and<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> #pragma GCC pop_options<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>around function static int __init gic_init_bases in file drivers/irqchip/irq-gic-v3.c. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>When I build it, I get this warning message (section mismatch). <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>( I later found it is actually the </span>“<span lang=EN-US>#pragma GCC optimize ("O0")</span>”<span lang=EN-US> line that is causing it.) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> CALL scripts/atomic/check-atomics.sh<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CALL scripts/checksyscalls.sh<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CHK include/generated/compile.h<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> </span><span lang=DE>CC arch/arm64/kernel/irq.o<o:p></o:p></span></p><p class=MsoNormal><span lang=DE> </span><span lang=EN-US>CC arch/arm64/kernel/setup.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CC drivers/irqchip/irq-gic-v3.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AS arch/arm64/kernel/head.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AR arch/arm64/kernel/built-in.a<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AR arch/arm64/built-in.a<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AR drivers/irqchip/built-in.a<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AR drivers/built-in.a<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> GEN .version<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CHK include/generated/compile.h<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> UPD include/generated/compile.h<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CC init/version.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> AR init/built-in.a<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> LD vmlinux.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> MODPOST vmlinux.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> WARNING: vmlinux.o(.text+0x227cc0): Section mismatch in reference from the function gic_smp_init() to the function .init.text:set_smp_cross_call()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> The function gic_smp_init() references<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> the function __init set_smp_cross_call().<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> This is often because gic_smp_init lacks a __init <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> annotation or the annotation of set_smp_cross_call is wrong.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> MODINFO modules.builtin.modinfo<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> LD .tmp_vmlinux1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> KSYM .tmp_kallsyms1.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> LD .tmp_vmlinux2<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> KSYM .tmp_kallsyms2.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> LD vmlinux<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SORTEX vmlinux<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SYSMAP System.map<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> OBJCOPY arch/arm64/boot/Image<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Function call is like this : gic_init_bases -> gic_smp_init() -> set_smp_cross_call. (currently CONFIG_SMP=y). <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>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. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>But without the #pragma debug setting, there was not warning of this kind. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I'm not sure if I can just add add __init to gic_smp_init(). (or remove _init from set_smp_cross_call )<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>What is the correct method to fix it?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Chan Kim<o:p></o:p></span></p></div></div></body></html>