AnsweredAssumed Answered

CodeWarrior 8- & 16-bit tools: Adding ansiis.lib adds 12k to HCS08 project

Question asked by Marc Paquette Employee on Jan 27, 2006
To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.
 
Posted: Oct 05, 2005 - 09:41 PM   
 
I used the project wizard to create a project for the M68DEMO908GB60 board.
 
The sample app compiled and linked, but I noticed that it was 12k. Our final processor is only going to have 16k of flash so I tried to trim things down by removing the ansiis.lib. Everything compiled and linked just fine.
 
The problem was when I created a C routine that was called from main(). It was in the same file, nothing really fancy just a simple call. The linker gave me the following error:
 
Link Error : L1822: Symbol _Jump_Table_Header_Offset in file C:\USB_Debug\ObjectCode\main.c.
o is undefined

I then added back the ansiis.lib file and things worked again, but it went back to 12k. Is there anywhere to call C routines without including the entire ansiis.lib?
 
Has anyone got around this problem?
 
thanks,
jon 
 
 
Posted: Oct 06, 2005 - 02:47 PM   
 
Well, it turns out that is was not the calling the C routines that was the problem, but rather my C routine had a switch() in it. The linker was looking for the C library routine that handles switch statements.
 
So now the question is whether I can just include the file that I need or do I have to include the whole lib along with all the 12k baggage. 
   
 
mw_ron
Moderator
 
Posted: Oct 07, 2005 - 03:59 PM   
 
SalsaMan wrote:
Well, it turns out that is was not the calling the C routines that was the problem, but rather my C routine had a switch() in it. The linker was looking for the C library routine that handles switch statements.
 
So now the question is whether I can just include the file that I need or do I have to include the whole lib along with all the 12k baggage.

There is no library routine that handles switch statement that is part of the compiler. It looks to me like maybe you put an o (oh) instead of a 0 (zero) in your code. Check your code again.
 
Ron
_________________
Ron Liechty
Ombudsman for Metrowerks 
 
Posted: Oct 07, 2005 - 04:14 PM   
 
Ron,
I'm not sure what you mean by put a zero or 0.
 
Can you verify that having the ansiis.lib adds 12k of code to a project? This lib was added by the wizard.
 
I disassembled my C code:
 
0000 8b PSHH
143: switch(command)
0001 a109 CMP #9
0003 2246 BHI L4B ;abs = 004b
0005 a106 CMP #6
0007 95 TSX
0008 f7 STA ,X
0009 250f BCS L1A ;abs = 001a
000b a109 CMP #9
000d 220b BHI L1A ;abs = 001a
000f a006 SUB #6
0011 97 TAX
0012 4f CLRA
0013 cd0000 JSR _Jump_Table_Offset
0016 2c DC.B L43
0017 2b DC.B L43
0018 2a DC.B L43
0019 29 DC.B L43
001a L1A:
001a 410106 CBEQA #1,L23 ;abs = 0023
001d a102 CMP #2
001f 262a BNE L4B ;abs = 004b

And you will notice the _Jump_Table_Offset routine which can be found in rtshc08.c which is part of ansiis.lib. So it would look to me that the compiler HCS08 is using a library routine to handle the switch statement.
 
I was able to extract the routine and put it in one of my source files so I would not have to include the entire library.
 
What granularity can the linker add routines. I thought some linkers would just add a file if a routine is needed. It looks like it adds the entire library is any one routine is needed.
 
I am assuming that the numbers at the bottom of the project window are accurate for the code size and data size.
 
thanks,
jon

 
Posted: Oct 17, 2005 - 03:06 AM   
 
The numbers at the bottom of the project aren't accurate at all.
They just indicate the total size of all code you have written.
The linker does not link functions to the program which aren't used,
unless explicitly told to do so with ENTRIES in the prm-file.
For details about the actual program size, check the .map file.
You can not remove the ansi-lib because then writing code in C won't work anymore. 
 
 
Posted: Oct 17, 2005 - 10:03 AM   
 
datekdev,
Thanks for the reply! That makes sense now that I looked at the map file. I am used to using CodeWarrior for developing PC and Mac so I am still adjusting to the slight differences for the embedded toolset.
 
jon

 

Outcomes