This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ASM symbols getting confused between main project and library project.

I am developing an application and a library of an LM4F232H5QD using CCS 5.1.  The libary initialized the hardware.  When I call the FLASH versions of the SysCtlPerifheralEnable it works just fine.  I switched to ROM code to save FLASH.  Now that library routine does not work.  I copied the offending ROM_SysCtlPerpheralEnable to my main function and it works fine.  I then stepped through the assembly to see what is happening and I find:

768 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
00000d7e: 484D LDR R0, $C$CON34 R0 <- 01000044
00000d80: 6800 LDR R0, [R0] R0 <- 01000890
00000d82: 6981 LDR R1, [R0, #0x18] R1 <- 01004754 R1 holds jump to address
00000d84: 484C LDR R0, $C$CON35 R0 <- 20000001 (SYSCTL_PERIPH_GPIOA), So R0 holds argument
00000d86: 4788 BLX R1 Jumps to 1004754

75 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
00002528: 487E LDR R0, $C$CON2 R0 <- 21C06800
0000252a: 6800 LDR R0, [R0] R0 <- 6800487E
0000252c: 6981 LDR R1, [R0, #0x18] < debug hangs, suspect we ar trying to read memory location 6800487E, which is out of range
0000252e: 487F LDR R0, $C$CON4
00002530: 4788 BLX R1

The compile command for both is (some newlines for readability):
'Building file: C:/Data/Code/TEC2402/Monitor2402/trunk/Monitor2402.c'
'Invoking: TMS470 Compiler'
"C:/ti/ccsv5/tools/compiler/tms470/bin/cl470" -mv7M4 --code_state=16
--float_support=FPv4SPD16 --abi=eabi -me -g
--include_path="C:/ti/ccsv5/tools/compiler/tms470/include"
--include_path="C:/StellarisWare"
--include_path="C:/Data/Code/LM4FCommon/CommonLib/trunk"
--define=DEBUG --define=css --define=PART_LM4F232H5QD --define=TARGET_IS_BLIZZARD_RA1 --diag_warning=225
--display_error_number
--use_dead_funcs_list=C:\Data\Code\TEC2402\CCS5_WorkSpace\Monitor2402\Debug-Monitor\dead_funcs.xml
--preproc_with_compile --preproc_dependency="Monitor2402.pp"
"C:/Data/Code/TEC2402/Monitor2402/trunk/Monitor2402.c"
'Finished building: C:/Data/Code/TEC2402/Monitor2402/trunk/Monitor2402.c'
 
Any idea on why it appears the linker is not getting the references correct?  Linker command is:

"C:/ti/ccsv5/tools/compiler/tms470/bin/cl470" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --define=DEBUG --define=css --define=PART_LM4F232H5QD --define=TARGET_IS_BLIZZARD_RA1 --diag_warning=225 --display_error_number --use_dead_funcs_list=C:\Data\Code\TEC2402\CCS5_WorkSpace\Monitor2402\Debug-Monitor\dead_funcs.xml -z --stack_size=2048 -m"Monitor2402.map" --heap_size=0 -i"C:/ti/ccsv5/tools/compiler/tms470/lib" -i"C:/ti/ccsv5/tools/compiler/tms470/include" --reread_libs --warn_sections --generate_dead_funcs_list=dead_funcs.xml --rom_model --unused_section_elimination=on -o "Monitor2402.out" "./startup_ccs.obj" "./Monitor2402.obj" -l"libc.a" -l"C:\StellarisWare\driverlib\ccs-cm4f\Debug\driverlib-cm4f.lib" -l"C:\Data\Code\TEC2402\CommonLib2402\trunk\ccs\Debug-Monitor\CommonLib2402.lib" -l"C:\Data\Code\LM4FCommon\CommonLib\trunk\ccs\Debug-Monitor\CommonLib.lib" "../lm4f232h5qd.cmd"

 I produced listing files for these to modules.  If you go an find the definitions of $C$CON2, etc and then interpret the code it should work.  But it looks like during link
the definition of $C$CON2 gets linked to the definition in the main.c module, which is different.  So you get a bad address loaded for the LDR instruction.
  • We need to reproduce this problem ourselves.  There is no other way to tell what is going on.  So, is there any way you could send us the project?

    Thanks and regards,

    -George

  • I have found that the symptom was that registers were being loaded with unexplainable values.  However I think I have discovered it was the preceeding call to set the clock speed that caused the problem.  The ROM version of the code looks like it supports a reduced set of clock divider settings.  I was using one not in the set.  When I just call the library version of the function, I have no problem with the following ROM_ function call.