Error when using KCFLAGS+="-ffunction-sections -fdata-sections" LDFLAGS+="--gc-section" to reduce kernel size

Yue Yu

New Member
Joined
Jan 10, 2020
Messages
3
Reaction score
0
Credits
0
I was trying to compile in the folder kernel 4.4 using the following commands to reduce kernel size for embedded Linux:
make menuconfig ARCH=arm64
make -j 4 ARCH=arm64 CC=aarch64-linux-gnu-gcc KCFLAGS+="-ffunction-sections -fdata-sections" LDFLAGS+="--gc-section"


It results in an Error as below:
5168


However, if I use commends excluding "--gc -section", it works:
make menuconfig ARCH=arm64
make -j 4 ARCH=arm64 CC=aarch64-linux-gnu-gcc KCFLAGS+="-ffunction-sections -fdata-sections"


I guess the problem is arising when linking subdirectory .o to built-in.o.
Can anyone please help me with this problem? I really appreciate any suggestion you provide!
 


Anyone know how to solve 'gc-sections requires either an entry or an undefined symbol' please help me:(
 
I’m not sure offhand.
I know more or less what the —gc-sections linker flag does, but I’ve never used it.
I’ll take a look when I can and will try to get back to you.

But if you manage to find an answer before then, please feel free to share it here, so the rest of the community can benefit from it!
 
I’m not sure offhand.
I know more or less what the —gc-sections linker flag does, but I’ve never used it.
I’ll take a look when I can and will try to get back to you.

But if you manage to find an answer before then, please feel free to share it here, so the rest of the community can benefit from it!
Thanks a lot! I am still working on it and haven't come up with any good idea. For testing, using --print-gc-section after --gc-section can print all the removed sections. If you have any new discovery about using gc-section to reduce kernel size, please let me know. Thanks
 
Last edited:


Top