dead stripping nightmares

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dead stripping nightmares

5,689 Views
jhall
Contributor II
can anyone help me out??? i'm using v3.1 codewarrior and all i want to do is add a version string to rom...the linker, however, keeps deadstripping it...i've tried all i know to try with all the help manuals...any suggestions?

/**************** VERSION STRING ***************************************/


const char VERSION_STRING[20] =
{' ','x','x','x','x','x','x','x','x',' ','x','x',' ',
'v','1','.','0','.','0',' '};




this is the only reference to VERSION_STRING in the entire project...i've tried #pragma CONST_SEG and all kinds of other things to no avail...please help! thanks...
Labels (1)
12 Replies

1,571 Views
MrBean
Contributor I

Sorry, i have to correct the above.

The -Ou/-Onu option does do something enterly different.

Not what the original question was about.

0 Kudos
Reply

1,571 Views
CrasyCat
Specialist III

Hello

 

There is only one way to disable dead striping by the linker and this is by adding the symbol name in the PRM file ENTRIES block.

 

This is the only way around that.

 

CrasyCat

1,571 Views
yb
Contributor IV
Hi,
 
If you don't use this string in your project, perhaps the compiler optimize it... and doesn't add it to your linked projest !!!
 
Try to use it, just for test.
 
Regards,
Yvan
0 Kudos
Reply

1,571 Views
ok2ucx
Contributor IV
Hi,
 
try to look into map file, UNUSED-OBJECTS SECTION and you'll see how the linker optimizes a memory usage by omitting all variables, constants, functions, etc. that are not used in your project.
You can force linker NOT to omit any constant/variable/function by putting its name into linker PRM file in between ENTRIES END commands (see Linker help for details).
 
Maybe just like this together with placing string onto a specific address too:
 
C file:
 
#pragma CONST_SEG BOOTROM
const char appboottable[FLASH_WRITE_PAGE] =  { "ID$: ZSTAR Triaxial Demo" };
#pragma CONST_SEG DEFAULT
 
PRM file:
 
ENTRIES
appboottable
END
...
 
SECTIONS
...
   BOOT_ROM =  READ_ONLY  0x7000 TO 0x71FF;
...
PLACEMENT
...
   BOOTROM                     INTO BOOT_ROM;
...
END
Regards, Pavel ok2ucx
0 Kudos
Reply

1,571 Views
Ricardo_RauppV
Contributor I

Hi guys.

Do you know if is there a generic way to disable such "cw optimization" wich simply "disappear" with not used objects?

Many times they are not accessed directly, but through different ways..there is..they are needed..!

Use  ENTRY in prm file works fine, but you need to remember to write into it for every not used object you add .....

Thanks !!

Ricardo Raupp

0 Kudos
Reply

1,571 Views
MrBean
Contributor I

Project settings -> Target -> Compiler for .. -> Options -> Optimize dead assignments -> never.

 

Or :

 

#pragma OPTION ADD "-Onu"  

 

 

Might do the job.

0 Kudos
Reply

1,571 Views
Ricardo_RauppV
Contributor I

Thanks MrBean

I´ve heard something about disable dead spreading could interfere in the linked lib size, since the unused functions would be compiled as well...

Do you know if it make sense?

Thanks

Ricardo Raupp

 

0 Kudos
Reply

1,571 Views
MrBean
Contributor I

I just tried it, and it doesnt seem to cause a code size increase.

 

You can also temporarily have the option on:

 

#pragma OPTION ADD "-Onu"  

 

 //code here

 

#pragma OPTION DEL "-Onu"  //Back to default

#pragma OPTION ADD "-Ou"  //And switch on if needed.

 

 

 

 

0 Kudos
Reply

1,571 Views
jhall
Contributor II
i tried using the code...apparently the compiler is too smart for it's own good...but even if that did work it wouldn't get me to the point where i want to be...i still wouldn't know how to stop the linker/compiler from deadstripping it...but it was a good thought though...thanks...

as for putting it between ENTRIES END, well, i've tried that as well...still doesn't work though...i have it as a const char VERSION_STRING...should i define it as something else?

my prm looks like this:


NAMES

END

ENTRIES
IRBaseTimer_OnInterrupt
VERSION_STRING
END

SECTIONS
ROM = READ_ONLY 0xC000 TO 0xFFAF;
Z_RAM = READ_WRITE 0x0080 TO 0x009F;
RAM = READ_WRITE 0x00A0 TO 0x047F;
InterruptVectors_ROM = READ_ONLY 0xFFCC TO 0xFFFF;
VERSION_STRINGS = READ_ONLY 0xC000 TO 0xC0FF;
END

PLACEMENT
DEFAULT_RAM INTO RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM,;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
VERSION INTO VERSION_STRINGS;
END

INIT _EntryPoint /* The entry point of the application. This function is generated into the CPU module. */

STACKSIZE 0x0080 /* Size of the system stack. Value can be changed on the "Build options" tab */



my map file looks like this:

NOT USED VARIABLES
RTSHC08.C.o (ansiis.lib):
_PowOfTwo_8 _PowOfTwo_16 _PowOfTwo_32 errno
Command_Table.c.o:
pCommand
Deck.c.o:
ReceiveBuffKeyPress
CommandoNG_ORIGINAL.c.o:
VERSION_STRING CurrentStatus KeyPress Shadow_PTD
Cpu.c.o:
CpuMode CCR_reg


and in my .c file, after main loop is closed:

void main(void)
{
blah blah blah;
}

/**************** VERSION STRING ***************************************/
const char VERSION_STRING[20] =
{' ','x','x','x','x','x','x','x','x',' ','x','x',' ',
'v','1','.','0','.','0',' '};




any other suggestions guys? thanks for the help!!!

Message Edited by jhall on 2006-10-0607:44 AM

0 Kudos
Reply

1,571 Views
jhall
Contributor II
You know what? it works...forgive me for writing code at 7am...i didnt' follow your instructions wholely...now i have placed it into the section that i want it in the prm file... i was reading the part about putting it into SECTION and PLACEMENT, but wasn't listening to it when i was reading it...so it now works! THANKS
0 Kudos
Reply

1,571 Views
ok2ucx
Contributor IV
my .c file:
 
/**************** VERSION STRING ***************************************/
const char VERSION_STRING[20] =
{' ','x','x','x','x','x','x','x','x',' ','x','x',' ',
'v','1','.','0','.','0',' '};
 
nothing in prm - string unused & removed.
 
Once my prm has this:
 
ENTRIES
VERSION_STRING
END

the string is included as following:
 
 .text      
- VARIABLES:
    VERSION_STRING                            EFAC      14      20       0   .rodata 
   
Are you really using the PRM file that you modify (see Linker for HC08 settings)
 
Pavel ok2ucx
 

 
 
0 Kudos
Reply

1,571 Views
jhall
Contributor II
sorry about that last reply, i thought i had hit submit after i finished typing it...but i forgot to and got pulled off on another task...thanks for you help! following your instructions worked...i knew of the first step, but the placement of the code in the SECTIONS and PLACEMENT, i didn't know about those...thanks...that'll be very helpful in the next few weeks of writing code for this project...
0 Kudos
Reply