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


Hi Michael,

Well, I do get a warning message with the PPC binutils.  Here is what it
looks like:

/usr/local/bin/powerpc-snmc-linux-gnu-objcopy --input-target=binary
--output-tar
get=elf32-powerpc \
        vmlinux.gz vmlinux.gz.elf
/usr/local/bin/powerpc-snmc-linux-gnu-objcopy: Warning: Output file
cannot repre
sent architecture UNKNOWN! 


Seems that I remember having problems making this work for PPC also.  I
had to go in and specify the output format, and not just rely on the
default output type. You may have some luck if you look at the
parameters and specify everything explicitly.

Now that I think about it a little more, it seems that it was in the
linker that I had to spell things out, at least regarding options.  Here
is what the linker command ends up looking like:

/usr/local/bin/powerpc-snmc-linux-gnu-ld --format elf32-powerpc -m
elf32ppc -g -
o zvmlinux init_qs850.o misc.o cmdline.o zlib.o embed_config.o
watchdog.o vsprin
tf.o string.o ctype.o printk.o ../drivers/char/smccons.o
../drivers/char/scccons
.o ../kernel/brg.o ../kernel/qspin.o ramtest.o hwinit.o stubs.o -T
qs850.lds -M
\
> zvmlinux.map

Notice that I use both the "--format" and the "-m" specifier.  I'm not
sure it totally necessary, but thats what I had to do to get it to work.

Daris


"Michael K. Elwood" wrote:
> 
> 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

-- 
Daris A Nevil
Simple Network Magic Corporation
401 Kentucky Lane
McKinney, TX 75069
214-793-7757
dnevil@snmc.com
www.snmc.com
quickstack.com
qslinux.org

------
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]