Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C dead code detection while using ARM compiler

I am working on embedded systems. I use C to program and ARM compiler to compile.

The code I am working on has been around for sometime an has been developed by multiple people. It uses function pointers as well.

Are there any tools that may help me to detect dead code? If not, how do you suggest I go about it?

like image 762
tdk Avatar asked Oct 13 '25 08:10

tdk


2 Answers

The ARM linker supports cross-module optimisation which will remove unused functions within object modules (including class member functions). Dead code within a function will be dealt with by the optimizer.

If you want to actually remove the code from the source, then a static analysis tool will be able to detect similar dead code sections to those that the compiler optimiser can detect.

like image 176
Clifford Avatar answered Oct 14 '25 22:10

Clifford


Have you tried the feedback linker option? It creates a file with a list of unused functions.

See ARM Compiler toolchain Linker Reference > --feedback=file

like image 24
jking Avatar answered Oct 15 '25 00:10

jking