This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linking with binary files


Thanks for the info, Daris.

My binutils are built for the mips-tx39-elf target. Objcopy will indeed
convert a binary to what looks like an elf file, but then BFD fails to
recognize the it as legitimate; I get a "File format not recognized"
when I reference the created elf file. Linking with this file fails, and
I also can't objcopy the file back to binary (or to any other format).
Always get the same "File format not recognized" error.

There is a note in the binary.c source file in BFD which states that
binary is supported for output only, not input. And yet it seems to do
the conversion, and the QSLinux build is obviously working. Strange. I
wonder what is different.

Any ideas?

MKE

Daris Nevil wrote:

>You can link binary files by first converting them to .elf format
>(at least for the PPC architecture, not sure about wintel).
>Here is a snippet of how this is done, using objcopy.  This is
>from the QSLinux makefile.
>zvmlinux: $(OBJECTS) vmlinux.gz qs850.lds
>#
># build the boot loader image and then compute the offset into it
># for the kernel image
># Convert the vmlinux.gz to elf format.  Merge the vmlinux.gz kernel
># into the linked boot program.  Re-adjust the VMA of the .data section
># to match the LMA, where it is loaded into flash.  This allows the
># visionIce 'convert' utility to see it, because 'convert' only seems
># to look at the VMA when loading modules.
># Finally, make a binary image that can be burned into flash by the
># SNMC "ff" program.
>#
>        $(OBJCOPY) --input-target=binary --output-target=elf32-powerpc \
>                vmlinux.gz vmlinux.gz.elf
>        $(LD) $(ZLINKFLAGS) -o $@ $(OBJECTS) -T qs850.lds -M \
>                > zvmlinux.map
>        $(OBJCOPY) --change-section-vma .data=`sh lma $(OBJDUMP) $@
>data` \
>                $@ $@.elf
>        cp $@.elf $(TOPDIR)/$@.elf
>        $(OBJCOPY) --input-target=elf32-powerpc --output-target=binary \
>                $@.elf $@.bin
>        cp $@.bin $(TOPDIR)/$@.bin


-- 
**********************************************************
Michael K. Elwood                     mkelwood@qsicorp.com
QSI Corporation

The fourth(?) Law of Thermodynamics:
     (Work in Theory) <= (Work in Practice)
**********************************************************

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]