Global Data Initialization Problem

cancel
Showing results for 
Search instead for 
Did you mean: 

Global Data Initialization Problem

117 Views
konstantin_yako
Contributor I

Hello,

I am working on quite complicated project consisting on two major parts : a static library and the main application which uses this library along with other libraries.

I have two projects, written in C :

1) "IPG100strip" project : to generate "IPG100strip.a" library.

2) "TryP2_ExtLibs_Custom" project : to generate "TryP2_ExtLibs.elf" main application which includes the above library and some third party libraries."

My compiler is Freescale CodeWarrior Eclipse 11.0.1.

The board I am compiling the codes for is based on MPC5606B MCU.

"mpc5606b_FLASH.lcf" link configuration file is used to configure the memory on the board.

I ran into the following problem : all my global arrays ( I mean arrays defined outside the functions ), both initialized and uninitialized contain a garbage when "main()" function is called and I can initialize them only using assignment statements later in the code what is not acceptable for me. This happens both with arrays allocated in the library and in the main application.

This tells me that something is definitely wrong with initialization of global objects.

To make complex thing simple, I stripped everything both from the library and the main application creating them "hollow" and containing only the initialization part, link configuration file, and the only one array of 10 elements "int TestArray[10]={1,2,3,4,5,6,7,8,9,10};" defined in the main application just above "main" function.

If you stop in debugger in the beginning of "main" function, you will see that the array contains a garbage but assignment "TestArray[3]=333;" works.

"main()" function calls "main0()" function which, in turn, calls "Test0919()" from the library from "Stubs.c" file.

The same story is within this function : array looks like a garbage but assignment "TestArray[4]=444;" works.

I believe that problem is in something very basic and I would really appreciate if you tale a look at these extremely simplifies project, review the settings, the linker configuration file and tell me what you think could cause this problem.

I attached the archived projects for your review.

Thank you very much !

Please help.

Labels (1)
0 Kudos
1 Reply

42 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

this question is currently solved by direct support case 00190528.

Regards,

Martin

0 Kudos