Page 1 of 1

Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 9:32 am
by ja
Hi

I am trying to link two different architecture images into single image is it possible ?

For example if i have image0 which is ARM compliant and image1 which is MSA intel architecture compliant.
How i can create an image image2 = image0+image1 ?

I know that linker script takes the object file as part of section (text) input and
I was using objcopy to generate .bin to .obj for placing the images into appropriate location in case of ARM architecture.
Also, linker script takes the architecture specific flag for OUTPUT format but i am not sure if there is a way i can make the two images with different architecture support as piggy back images inside a final image ?


I know the workaround could be to just copy Opcodes for one of the image directly into memory but i am trying to find a better way ?

Thanks,
- Ja

Re: Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 10:12 am
by AJ
Hi,

You could achieve this with a library system (such as ar).

What exactly are you trying to achieve that would not be better dealt with by just having two completely separate binaries?

Cheers,
Adam

Re: Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 12:35 pm
by ja
Hi,

" What exactly are you trying to achieve that would not be better dealt with by just having two completely separate binaries? "

I am trying to flash a single binary/image and it contains multiple images.
These images are dispersed by the main binary into memory after doing some initialization.
So in short i have one main initialization binary which has multiple binaries. There binaries are for specific purposes such as initializing specific cores, HW engines etc..

I am using bare metal code so there is no OS. Do you have any recommendation for such case ? I know simple workaround by just embedding the opcode into an array but it is not efficient.

Thanks,
Ja

Re: Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 1:43 pm
by Nessphoro
Well, I suppose with ld you could make a section for each arch. and dump the file's contents in there (it will work rather nicely with bins) and then since ld can report you the addresses of sections in variables you could make it work.

Re: Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 2:03 pm
by ja
Hi,

Do you have any example which i can refer ?
I tried making linker script but it just truncates the .bin file.

Thanks,
Ja

Re: Question regarding Linking (GCC)

Posted: Mon Jul 01, 2013 2:59 pm
by Nessphoro
You could do this:

Code: Select all

ENTRY(...)
SECTIONS{
    . = SomeAddress;
    //Your sections and stuff...
    // This could be your bootstrap code, idk
    _ArmCodeStart=.;
    INCLUDE "arm.ld"; //Linker script for arm stuff
   _ArmCodeEnd=.;
    
   _IntelCodeStart=.;
    INCLUDE "x86.ld"; //Linker script for x86stuff
   _IntelCodeEnd=.;
}

You could generate the extra ld files for existing binaries using

Code: Select all

cat binary.bin | hexdump -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' > binary.ld

Re: Question regarding Linking (GCC)

Posted: Tue Jul 02, 2013 2:42 am
by dozniak
Just one question, if you're flashing a firmware, you know precisely what system that is, so unless it's a mixed ARM/Intel machine there's probably no point in having these images mixed together.