How to Force the linker to keep all of a Library's fucntions (Codewarrior 2.5.7 and MSC8101)

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

How to Force the linker to keep all of a Library's fucntions (Codewarrior 2.5.7 and MSC8101)

2,482 Views
kc6sye
Contributor I

Environment:
Codewarrior scc compiler (2.5.7) run from dos prompt
Compiling for the MSC8101 (Starcore)

Here's the issue in a nut shell:
We have some Hardware Abstraction Layer functions that are common to all application builds.
We'd like to build them as a library and let all builds call that library makefile (creates say HAL.elb)
The problem is that some functions in HAL aren't directly called by anyone else, like the Interrupt Vector table, and thus get tossed out.  I need to know how to make sure that all these functions are being placed in the build every time.

The feature dream is to do runtime binding so that any application can sit on any hardware, but that's a mountain to climb for another day.

Labels (1)
0 Kudos
4 Replies

485 Views
CrasyCat
Specialist III
Hello
 
You can use the linker command .xref to tell the linker you want to link a non-referenced symbol to an application.
 
If you want to link the constant variable MyVersionConst you need to add the following to your linker command file:
    ,xref _MyVersionConst.
 
The compiler internally adds a _ prefix to symbol names.
 
The command(s) .xref must be specified prior to any .segment command.
 
CrasyCat
0 Kudos

485 Views
kc6sye
Contributor I
I tested this with the first item, an assembly file that is the interrupt vector table.  The linker claims the section name from the assembly file is unresolved.  But another C file function name worked, the function is now present in the dsp map file.  I tired the assembly section name: HAL_DSP_Vectors_ then with an _ added to the front, still no good.

The issue with this solution will be that we wanted to break the explicit connection of function names from any of the build files at the app layer.  Listing them in the dsp linker command file will defeat this.  The only thing that would be ok is to reference the elb name.  Is it there way to turn off the dead stripping completely for an elb?
0 Kudos

485 Views
CrasyCat
Specialist III
Hello
 
For assembly labels, there is no _ prefix added to the symbol name.
So if your vector table is called VectorTable you need to refer to VectorTable in the .xdef command.
 
And you need to specify a symbol name there (not a section name).
 
So you need to define a label at the beginning of the section and make sure you export it with GLOBAL directive.
 
CodeWarrior for StarCore V3.0 and higher provide a .xref_module linker directive allowing to disable dead stripping for all symbols defined within an object file (.eln).
 
CrasyCat
0 Kudos

485 Views
ubhims
Contributor I
I'm not sure if I got your question right, but command line option -n inhibits dead-code and dead-data stripping.
0 Kudos