GCC Linker not removing unused constant strings..
I am using GCC for Arm version 4.7, not sure if ver 4.9 solves this issue or not.
with following link options:
-nostdlib
-nostartfiles
-nodefaultlibs
--gc-sections
--cref
--allow-
my issue is the linker is not removing unused strings from printf()
functions that are unused in the file. I have tried adding the
compiler options -flto and -fdata-sections with no success.
Example file included in build:
functionInclude
{
printf("THIS SHOULD BE INCLUDED IN EXECUTATBLE ");
}
functionNOTIncl
{
printf("THIS SHOULD BE REMOVED BY LINKER");
}
The issue is that after the file is compiled that includes both
functions, constant data is grouped together. However, because
functionNOTIncl
by the linker, however, the linker is not removing the constant string
data that was previously allocated by the compiler for the function
("THIS SHOULD BE REMOVED BY LINKER" remains in const data section).
Are there any ld options that can be used to fix this issue?
I do not want to have to eliminate all my unused functions from files to
keep the constant data from getting compiled and linked into my
executable.
Question information
- Language:
- English Edit question
- Status:
- Needs information
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask David for more information if necessary.