Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France


Cosmic Software Frequently Asked Questions


I have an application that requires the Cosmic libraries to be linked in two locations. How do I link more than one copy of the same library without name conflicts?


The linker has the ability to link multiple copies of functions without causing a symbol naming conflict. This is useful if your application has a piece of code that must run out of RAM and needs to use some of the same libraries as the main application. It is also useful if you need to use some of the libraries only in one page of a paged application and don't want to waste the common space. This is done using linker regions configured with the +new and +pri (private) segment options. The +new option creates a new region and the +pri creates a private partition within a region. The private partition hides all of the symbols from all other regions so that conflicts which result in multiply defined errors will be allowed. In the following example, all of the symbols in main.o and mod1.o are public so they can call each other however all of the symbols in the library in region 1 are only usable by functions in main.o and all of the libraries in region 2 are only usable by mod1.o. This means that if they both use the same library there will be two copies linked into the application and each region will use the local version. This allows the libraries to be used in banked memory or in a boot loader. e.g. HC12 example
# Region 1 - 
+seg .text -b0x100
main.o
+pri
\lib\libi.h12
\lib\libm.h12
Note: a +new is implied at the beginning of a link command file
# Region 2
+new 
+seg .text -b0x18000 -o0x8000
mod1 .o
+pri
\lib\libi.h12
\lib\libm.h12
An example of a linker command file with multiply defined libraries can be found here and full example is provided in the moveable code example.

Multiple Library Example Link File
Moveable code example