This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Objcopy and alignment
- From: "Dave Murphy" <wintermute2k4 at ntlworld dot com>
- To: "Binutils List" <binutils at sources dot redhat dot com>
- Date: Tue, 18 May 2004 15:40:26 +0100
- Subject: Objcopy and alignment
Is it possible to specify the alignment of binary data when using objcopy to
generate object files from raw data? Failing that, can obcopy be told to
pad the length to, say, an even multiple of 4 bytes?
I'm currently using objcopy to link data in the executable for an embedded
target using makefile rules like this, to generate headers along with the
object file :-
define bin2o
cp $(<) $(*).tmp
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--rename-section .data=.rodata,readonly,data,contents \
--redefine-sym _binary_$*_tmp_start=$*\
--redefine-sym _binary_$*_tmp_end=$*_end\
--redefine-sym _binary_$*_tmp_size=$*_size\
$(*).tmp $(@)
echo "extern const u8" $(*)"[];" > $(*).h
echo "extern const u32" $(*)_size[]";" >> $(*).h
rm $(*).tmp
endef
#---------------------------------------------------------------------------
------
%.o : %.pcx
#---------------------------------------------------------------------------
------
@echo $(notdir $<)
@$(bin2o)
occasionally the data is an odd length so any data following becomes
misaligned.
I've looked at the online docs -
http://sources.redhat.com/binutils/docs-2.15/binutils/objcopy.html and I can
see options for adjusting various addresses and a pad-to address option. How
can these options be used without knowing the addresses of the object being
modified? Surely they can't be known until link time?
Dave