This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: linking & cdl question
- From: "Andy Dyer" <adyer at righthandtech dot com>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 22 Jul 2003 18:38:46 -0500
- Subject: RE: [ECOS] linking & cdl question
> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Andy Dyer
> Sent: Saturday, July 19, 2003 8:00 PM
> To: ecos-discuss@sources.redhat.com
> Subject: [ECOS] linking & cdl question
>
>
> I have some Xilinx fpga configuration data used in my hal startup
> that I want to link into my ROM redboot images, but not in the RAM
> versions since presumably redboot has already dealt with the
> configuration at startup.
>
> I have managed to get the raw binary data file into an
> elf .o file with a .rodata section and some symbols defining
> the start and end, but I'm not sure how to reference it in
> cdl and get it linked.
>
> a couple of questions:
>
> would it make sense to put it into the main library or should
> it go into extras (will the rodata section get removed if
> there is no reference to the start and end symbols)?
>
> How do i just specify a .o file to link with no build rule?
>
> Would it be easier to have a make rule somewhere to say
> how to make the .o file from a raw binary file?
> How does one go about this?
For the sake of the archives, I managed to get this done by
defining a make rule in the cdl to add the .o file to the
library after it's built with ar. Gentle suggestions on
making it less ugly would be appreciated.
# custom build rule to add the fpga data into the libtarget.a
# library after its built in the .rodata section
#
# 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 {
spartan2_top.o : <PACKAGE>/src/spartan2_top.bin
-CURDIR = $(shell pwd)
@rm -f $@
cd $(<D) ; \
$(OBJCOPY) -I binary -O elf32-littlemips \
--rename-section
.data=.rodata,alloc,load,readonly,data,contents \
$(<F) $(CURDIR)/$@
$(AR) rcs $(PREFIX)/lib/libtarget.a $@
}
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss