Calling all LCF Experts...

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

Calling all LCF Experts...

3,150 Views
nanoGeek
Contributor I
I am using CW 6.2 for coldfire and am compiling for the MCF5407.
 
I am trying to link in a custom library (CF_boot_ROM.elf) and I want it to link starting at a specific address while the rest of my application is to link to another address.  I've tried the following to no avail:

MEMORY {
 TEXT_BOOT (RX) : ORIGIN = 0x7E000000, LENGTH = 0x0
 TEXT (RX) : ORIGIN = 0x7E400000, LENGTH = 0x0
 DATA (RW) : ORIGIN = 0x00040000, LENGTH = 0x0
}
SECTIONS {
 .boot_app :
 {
  CF_boot_ROM.elf(.text)
  .= ALIGN(0x8);
  CF_boot_ROM.elf(.rodata)
  .= ALIGN(0x8);
 } > TEXT_BOOT
 .main_application :
 {
  vectors.s(.text)
     .= ALIGN(0x8);
     mcf5407_lo.s(.text)
     .= ALIGN(0x8);
  *(.text)
  .= ALIGN(0x8);
  *(.rodata)
  .= ALIGN(0x8);
  __end_of_text = .;
 } > TEXT
 
All I get is the main application in my .S19 file.
 
Thanks,
Joe
Labels (1)
0 Kudos
3 Replies

719 Views
CrasyCat
Specialist III

Hello

Not sure I get it right here.

Is CF_boot_ROM.elf an object library or an executable file? I am confused here as usually extension .elf is associated with executable files?

Additionally an object library does not have a formal .text section. It is just a collection of object files, each of them having their own .text section.

So CF_boot_ROM.elf(.text) is not returning any code here.

Finally are you using the functions from CF_boot_ROM.elf within your main application?

The linker is performing dead stripping and is not linking any objects, which is not used to the application.

To tell the linker you want to link some non-referenced object you have to use the linker command FORCEACTIVE.

I hope this helps.

CrasyCat

0 Kudos

719 Views
nanoGeek
Contributor I
CrasyCat, thank you for your reply

The *.elf file is compiled library. At least, that is what CW generated when I selected "Library" from one of the target menus. BTW, can you tell what the difference is between a Library and a Shared Library?

The boot_ROM library is intended to handle power up boot, so it gets executed out of reset (supposedly). It then calls the target application. No other portions of the boot_ROM lib are used by the application.

As for FORCEACTIVE, whould I just list the .elf file as a parameter to FORCEACTIVE? What syntax does it use here? How do I locate the code that is linked from the boot_ROM lib? It needs to link to address 0x7E000000 while the rest of the application needs to link to address 0x7E400000. I can provide some of the pertinent files if that would help.

Again, thank you for your assistance

Joe
0 Kudos

719 Views
CrasyCat
Specialist III

Hello

I have performed some additional tests here.

Basically FORCEACTIVE is good to add individual object (functions, variables) to the application.
If you wish to add all objects defined (implemented) in a file you rather use FORCEFILES.
FORCEFILES works with object files not with archives. So you have to specify all the object files inside of your library file to get them all linked.

Syntax is as follows (I took ANSIC library as a test, just replace the library name with your own library name).

FORCEFILES {C_TRK_4i_CF_MSL.a(string.o) C_TRK_4i_CF_MSL.a(s_fabs.o)}

Place that command at the end of the .lcf file (After the SECTIONS block).

In order to place whole code & constant from your library in a separate memory area, just use following notation in your .lcf file:

SECTIONS {
 .boot_app :
  {
   C_TRK_4i_CF_MSL.a(.text)
   .= ALIGN(0x8);
   C_TRK_4i_CF_MSL.a(.rodata)
   .= ALIGN(0x8);
  } > TEXT_BOOT
 .main_application :
 {
  *(.text)
  .= ALIGN(0x8);
.....

Make sure to specify the C_TRK_4i_CF_MSL.a(.text) prior to *(.text) in the.lcf file.

 I hope this helps.

Note I did all the tests with CodeWarrior for Coldfire V6.3.

CrasyCat

0 Kudos