Replacing ansif.lib by ansii.lib does not make code smaller--why not?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Replacing ansif.lib by ansii.lib does not make code smaller--why not?

跳至解决方案
1,607 次查看
cab
Contributor III

Using HC908JL12 with CW 6.3 and XP.  I see that ansif.lib is very much larger than ansii.lib, so I eliminated a few floating calculations and replaced ansif.lib by ansii.lib.  Yet it appears that my code is the same size regardless which library I use.  I do not know the structure of these libraries.  I imagine it is possible for the linker to only link in the required routines but that kind of precision would be surprising.  I am new to CW and may not be looking at the right numbers in the .map file.  It lists many NOT USED PROCEDURES (and they are different) which I expect is (different) wasted space in Flash.  In both .map files I have these identical sections:

 

TARGET SECTION
---------------------------------------------------------------------------------------------
Processor   : Freescale HC08
Memory Model: SMALL
File Format : ELF\DWARF 2.0
Linker      : SmartLinker V-5.0.37 Build 9279, Oct  7 2009

[...]
Summary of section sizes per section type:
READ_ONLY (R):         16FE (dec:     5886)
READ_WRITE (R/W):    AB (dec:      171)
NO_INIT (N/I):                  63 (dec:       99)

 

Isn't 5886 the majority of Flash?  I know there are a few other contributions, but nothing that would change when the library is changed.

 

Are your libraries and linker that brilliant, or what am I missing?

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,199 次查看
rocco
Senior Contributor II

cab wrote:

 I imagine it is possible for the linker to only link in the required routines but that kind of precision would be surprising.



Hi Cab,

 

The point of a library is that it is just a lirary of routines. You do not have to "check-out" the entire library, only the routines you need. Those NOT USED PROCEDURES are also not included in your flash image.

 

It looks like you are using under 6k of flash, so you should still have half of your flash empty.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,199 次查看
theo
NXP Employee
NXP Employee

The linker performs smart linking - in that it strips the symbols that are not actually used. This means that only the library routines that are used will be allocated to section .text. In order to see which exactly these routines are, check the object allocation section in the .map.file, looking for object files pertaining to the library, e.g.:

*********************************************************************************************
OBJECT-ALLOCATION SECTION
     Name               Module                 Addr   hSize   dSize     Ref    Section   RLIB
---------------------------------------------------------------------------------------------
...

MODULE:                 -- RTSHC08.C.o (ansifs.lib) --
- PROCEDURES:
     _PUSH_ARGS_L                              2146      20      32       1   .text       
     _ENTER_BINARY_L                           2166      16      22       2   .text       
...

     _FMUL                                     244D       7       7       1   .text       
     _FDIV                                     2454       7       7       1   .text       

You will not see any of the not used procedures listed under the object allocation section.

 

If you sum up all the sizes (decimal: dSize) associated with section .text in the object allocation section, you obtain the size of .text as listed in the section allocation section of the map file.

0 项奖励
回复
1,200 次查看
rocco
Senior Contributor II

cab wrote:

 I imagine it is possible for the linker to only link in the required routines but that kind of precision would be surprising.



Hi Cab,

 

The point of a library is that it is just a lirary of routines. You do not have to "check-out" the entire library, only the routines you need. Those NOT USED PROCEDURES are also not included in your flash image.

 

It looks like you are using under 6k of flash, so you should still have half of your flash empty.

0 项奖励
回复