Problem with ‘--gc-sections’ at link time

Asked by Marco Piovesan

I am building with 4.7 2013q1 a project for STM32F4.
I have this array in flash defined in stm32f4_discovery.c
const uint32_t BUTTON_CLK[BUTTONn] = {USER_BUTTON_GPIO_CLK }; // BUTTONn = 1, USER_BUTTON_GPIO_CLK=1

If I enable removal of unused sections BUTTON_CLK[0] result = 0xFFFFFFFF
If I disable removal of unused sections BUTTON_CLK[0] result = 1

I tried to print removed section using --print-gc-sections
but none section belongs to stm32f4_discovery

Dulcis in fundo
This error disappears if the call to function SystemInit() is commented out and
sections of system_stm32f4xx.c (where is defined SystemInit() ) are not removed.

IMHO this could be a linker bug but naturally I am not sure of this so
if someone can give me some good advice on what to check I will grate.

I can upload my project if someone is interested in to deeper check.

Ciao

Marco

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Marco Piovesan
Solved:
Last query:
Last reply:
Revision history for this message
Terry Guo (terry.guo) said :
#1

Yes. Please upload your project for us to reproduce.

Revision history for this message
Marco Piovesan (marco-piovesan) said :
#2

Please download from
http://download.paser.it/files/get/ps3Sx5jZNS/usbhost3.zip

The project is for CooCox CoIDE Version: 1.7.2

the upload is the status that cause the problem
please try to comment line 44 in main.c or alternatively disable remove unusede section from configuration->link
to clear the problem

Thank you

Ciao

Marco

Revision history for this message
Marco Piovesan (marco-piovesan) said :
#3

I found my problem.
The flash was cleared by application.

Sorry for waste you time.

Ciao

Revision history for this message
Terry Guo (terry.guo) said :
#4

Good, since I am also unable to reproduce it. I want to point out one thing about --gc-sections in CoIDE. It seems only -ffunction-sections is used to compile project files, the -fdata-sections is missing. We will end up with removal of unused functions, not the unused variables. You may want to add -fdata-sections manually.