beta68 / linux

Odroid N2(+) kernel with CoreElec media modules/drivers and amvideocap
Other
3 stars 1 forks source link

Section mismatch warnings - not only a warning #2

Open FauthD opened 2 years ago

FauthD commented 2 years ago

Hi Beta68, When I build here, I get some "Section mismatch" warnings from the linker. First I thought it was from one of my changes, but they also show up with your code. Without the DEBUG macro below it only shows a short summary that can be easily overlooked.

I analyzed the sources and fixed it in my fork: "Fix linker warning "mismatched sections". Could even cause a crash." fc5a0d860c8e60b7f2a249e02041a2bebfbb9e15. Root cause are some init and initdata attributes. These tell the kernel this code is only used at startup, so it can later free this memory. Can be dangerous and cause a crash.

I currently build with the toolchain from CoreElec (GCC 10.2), but I think older linkers should complain as well. Tomorrow I can check building native on my N2+.

There a more changes than this one. If you want to merge code back, we probably should talk.... Many regards, Dieter

My make line: make CONFIG_DEBUG_SECTION_MISMATCH=y -j6 >k.log

Section Mismatch

WARNING: drivers/amlogic/ddr_tool/built-in.o(.text.unlikely+0x80): Section mismatch in reference from the function dmc_monitor_probe() to the function .init.text:ddr_find_port_desc()
The function dmc_monitor_probe() references
the function __init ddr_find_port_desc().
This is often because dmc_monitor_probe lacks a __init
annotation or the annotation of ddr_find_port_desc is wrong.

WARNING: drivers/amlogic/ddr_tool/built-in.o(.text.unlikely+0x1dc): Section mismatch in reference from the function dmc_monitor_probe() to the variable .init.data:init_start_addr
The function dmc_monitor_probe() references
the variable __initdata init_start_addr.
This is often because dmc_monitor_probe lacks a __initdata
annotation or the annotation of init_start_addr is wrong.

WARNING: drivers/amlogic/ddr_tool/built-in.o(.text.unlikely+0x1e0): Section mismatch in reference from the function dmc_monitor_probe() to the variable .init.data:init_start_addr
The function dmc_monitor_probe() references
the variable __initdata init_start_addr.
This is often because dmc_monitor_probe lacks a __initdata
annotation or the annotation of init_start_addr is wrong.

WARNING: drivers/amlogic/ddr_tool/built-in.o(.text.unlikely+0x1ec): Section mismatch in reference from the function dmc_monitor_probe() to the variable .init.data:init_start_addr
The function dmc_monitor_probe() references
the variable __initdata init_start_addr.
This is often because dmc_monitor_probe lacks a __initdata
annotation or the annotation of init_start_addr is wrong.
FauthD commented 2 years ago

Hi Beta68, with gcc 9.4 native on N2+ it does not complain about the sections. Perhaps this linker does not check for this?

Nevertheless this could cause crashes.

PS: I saw you added some dts files (same names as I added, might cause merge issues when I send a pull request). Many regards, Dieter