Skip to contentSkip to conversation

Linker error `.exit.text' referenced in section `.alt.smp.init'

DISCUSSION Stefan Agner 3 participants 4 messages May 28, 2019

lore
Share & tools
lore
#0 lore raw

Hi,

Cross compiling Linux v5.2-rc2 with CONFIG_DNS_RESOLVER=y using gcc 8.2 I noticed the following build error:

...

  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
MODINFO modules.builtin.modinfo
.exit.text' referenced in section .alt.smp.init' of net/dns_resolver/dns_key.o: defined in discarded section `.exit.text' of net/dns_resolver/dns_key.o

make: *** [Makefile:1052: vmlinux] Error 1

It seems that Masami noticed this a while back:
https://lore.kernel.org/lkml/[email protected]/T/#u

Anybody else seen this?

When I remove put_cred in exit_dns_resolver the kernel links fine...

--
Stefan

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#1 lore raw
Quoted 19 lines · Stefan Agner

Hi,

Cross compiling Linux v5.2-rc2 with CONFIG_DNS_RESOLVER=y using gcc 8.2 I noticed the following build error:

...

  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
MODINFO modules.builtin.modinfo
.exit.text' referenced in section .alt.smp.init' of net/dns_resolver/dns_key.o: defined in discarded section `.exit.text' of net/dns_resolver/dns_key.o

Quoted 8 lines

make: *** [Makefile:1052: vmlinux] Error 1

It seems that Masami noticed this a while back:
https://lore.kernel.org/lkml/[email protected]/T/#u

Anybody else seen this?

When I remove put_cred in exit_dns_resolver the kernel links fine...

I've seen two or thre of these in total. This only happens on 32-bit ARM when a function that needs SMP patching gets inlined into an __exit function. In this case, it's the atomic_dec_and_test().

The last one I fixed was https://lkml.org/lkml/2019/4/15/625
I think I've seen the one in the dns_resolver before but couldn't reproduce it recently.

I used to have a patch that completely avoided dropping .exit when SMP patching was active, but I think we can fix them up as they happen, as I have built thousands of randconfig kernels without hitting this.

The easiestwork around here would be to drop the __exit annotation and add a comment. We could also move put_cred out-of-line and make it non-__exit, or add an extern wrapper for it.

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · Stefan Agner

Hi,

Cross compiling Linux v5.2-rc2 with CONFIG_DNS_RESOLVER=y using gcc 8.2 I noticed the following build error:

...

  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
MODINFO modules.builtin.modinfo
.exit.text' referenced in section .alt.smp.init' of net/dns_resolver/dns_key.o: defined in discarded section `.exit.text' of net/dns_resolver/dns_key.o

Quoted 8 lines

make: *** [Makefile:1052: vmlinux] Error 1

It seems that Masami noticed this a while back:
https://lore.kernel.org/lkml/[email protected]/T/#u

Anybody else seen this?

When I remove put_cred in exit_dns_resolver the kernel links fine...

I've seen two or thre of these in total. This only happens on 32-bit ARM when a function that needs SMP patching gets inlined into an __exit function. In this case, it's the atomic_dec_and_test().

Quoted 7 lines

The last one I fixed was https://lkml.org/lkml/2019/4/15/625
I think I've seen the one in the dns_resolver before but couldn't reproduce it recently.

I used to have a patch that completely avoided dropping .exit when SMP patching was active, but I think we can fix them up as they happen, as I have built thousands of randconfig kernels without hitting this.

Yeah dropping .exit seems rather harsh.

Quoted 4 lines

The easiestwork around here would be to drop the __exit annotation and add a comment. We could also move put_cred out-of-line and make it non-__exit, or add an extern wrapper for it.

Hm, both seem not very appealing to me. I think I'd rather prefer an extern wrapper.

Is this an actual problem? As far as I understand that fixup happens very early and only once during boot, so by the time the kernel drops those .exit.text fixup has been done long time ago...

Is this maybe a case for __ref (defined in include/linux/init.h)?

Or could we have the section marked init/exit such that this does not trigger the error?

--
Stefan

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 52 lines · Stefan Agner
Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · Stefan Agner

Hi,

Cross compiling Linux v5.2-rc2 with CONFIG_DNS_RESOLVER=y using gcc 8.2 I noticed the following build error:

...

  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
MODINFO modules.builtin.modinfo
.exit.text' referenced in section .alt.smp.init' of net/dns_resolver/dns_key.o: defined in discarded section `.exit.text' of net/dns_resolver/dns_key.o

Quoted 8 lines

make: *** [Makefile:1052: vmlinux] Error 1

It seems that Masami noticed this a while back:
https://lore.kernel.org/lkml/[email protected]/T/#u

Anybody else seen this?

When I remove put_cred in exit_dns_resolver the kernel links fine...

I've seen two or thre of these in total. This only happens on 32-bit ARM when a function that needs SMP patching gets inlined into an __exit function. In this case, it's the atomic_dec_and_test().

Quoted 7 lines

The last one I fixed was https://lkml.org/lkml/2019/4/15/625
I think I've seen the one in the dns_resolver before but couldn't reproduce it recently.

I used to have a patch that completely avoided dropping .exit when SMP patching was active, but I think we can fix them up as they happen, as I have built thousands of randconfig kernels without hitting this.

Yeah dropping .exit seems rather harsh.

Quoted 4 lines

The easiestwork around here would be to drop the __exit annotation and add a comment. We could also move put_cred out-of-line and make it non-__exit, or add an extern wrapper for it.

Hm, both seem not very appealing to me. I think I'd rather prefer an extern wrapper.

Quoted 8 lines

Is this an actual problem? As far as I understand that fixup happens very early and only once during boot, so by the time the kernel drops those .exit.text fixup has been done long time ago...

Is this maybe a case for __ref (defined in include/linux/init.h)?

Or could we have the section marked init/exit such that this does not trigger the error?

Moving the SMP alternatives section doesn't change anything: the problem is that the SMP alternatives are part of the image the linker creates, but an entry in there refers to a section that we've told the linker to discard. The linker has no way to provide a value for that entry, and so errors out.

I wonder if there's a way to tell the linker that it's a weak reference, and modify the SMP fixup code to skip it.

Signature · 8 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel