[ECOS] binutils wizardry

Andrew Dyer adyer@righthandtech.com
Sun Aug 1 22:52:00 GMT 2004



> -----Original Message-----
> From: ecos-discuss-owner@ecos.sourceware.org
> [mailto:ecos-discuss-owner@ecos.sourceware.org]On Behalf Of Doyle,
> Patrick
> Sent: Friday, July 30, 2004 7:42 AM
> To: ecos discuss list
> Subject: [ECOS] binutils wizardry
> 
> 
> I have an existing application that I load onto my device 
> with RedBoot.  I
> have a raw binary data file that I also load onto my device that my
> application expects to find in memory at address 0x80000.  I 
> would like to
> figure out some method, preferably _after_ I've linked my 
> main application,
> to glue these two pieces together into a single ELF file so 
> that I could
> download both pieces in one swell foop.
> 
> I'm reasonably sure I can do this with some subset of the programs in
> binutils, but I'm not too sure where to start.  I vaguely 
> remember looking
> at how Linux gets gzip'ed for booting (10 or more years ago), so I'll
> probably start there, but, in the mean time, I thought I 
> would ask for some
> pointers.
> 
> Any pointers?
> 


For building redboot on our custom platform I include binary data like
this:

In the .cdl file
(packages/hal/mips/rhtvp100/current/cdl/hal_mips_vr5500_rhtvp100.cdl
for me) I add the following build rule.

	# custom build rule to add the fpga configuration data into the
	# libtarget.a library after its built (in the .xildata section)
      # The data will either be included in the final image or not based
	# on section directives in the include/pkgconf/*.ldi files
	# 
	# FIXME - this is mostly just pure evil
	#
	# objcopy is forced to run from the source dir
	# because it creates symbols for the start and end of the data
	# (which we use) with the source filename (including path) 
	# embedded in it.  By running it in the source directory
	# we force the symbols to always be named the same no
	# matter where the source tree is
	#
	# $(shell pwd) gives a non-zero return code under cygwin
	# for some reason, so it's prefixed with a '-'
	#
	# objcopy doesn't like to overwrite it's output file so we
	# remove it by force
	#
	make -priority 201 {
        v2pro_top_flip.o : <PACKAGE>/src/v2pro_top_flip.bin
		-CURDIR = $(shell pwd)
		@rm -f $@
		cd $(<D) ; \
	      $(OBJCOPY) -I binary -O elf32-littlemips \
	          --rename-section
.data=.xildata,alloc,load,readonly,data,contents \
              $(<F) $(CURDIR)/$@
		$(AR) rcs $(PREFIX)/lib/libtarget.a $@
    }




in the linker include  
(packages/hal/mips/rhtvp100/current/include/pkgconf/mlt_mips_vr5500_rhtv
p100_romram.ldi
for me) file I include a section at the end 

SECTIONS
{
	(blah, blah, blah deleted)

	// bring in xilinx pointers and data
	.xil_data_p 0xbfc70000  :
  	{	
		LONG(ABSOLUTE(_binary_v2pro_top_flip_bin_start));
		LONG(ABSOLUTE(_binary_v2pro_top_flip_bin_end));
	    *(.xildata)
  	} > rom

    SECTIONS_END
}


this puts two word pointers to the start and end of the data
at virtual address 0xbfc70000 (necessary for our application,
not required otherwise) and immediately follows it with anything
in any of the files assigned to the .xildata section.

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list