1
# *****************************************************************************
2
# * Copyright (c) 2004, 2008 IBM Corporation
3
# * All rights reserved.
4
# * This program and the accompanying materials
5
# * are made available under the terms of the BSD License
6
# * which accompanies this distribution, and is available at
7
# * http://www.opensource.org/licenses/bsd-license.php
10
# * IBM Corporation - initial implementation
11
# ****************************************************************************/
15
CROSSTMP=`grep ^CROSS $(dirname $0)/../make.rules | cut -d\ -f2`
17
CROSS=${CROSS-$CROSSTMP}
23
OBJCOPY="${CROSS}objcopy"
28
while [ $# -gt 0 ] ; do
30
--ld) LD=$2 ; shift 2 ;;
31
--ldflags) LDFLAGS=$2 ; shift 2 ;;
32
--lds) LDSFILE=$2 ; shift 2 ;;
33
--objcopy) OBJCOPY=$2 ; shift 2 ;;
34
*.o|*.a|-l*|-L*) OBJFILES="$OBJFILES $1" ; shift ;;
35
*) echo "$0:" ; echo " Unsupported argument: $1"; exit -1 ;;
39
if [ -z $LDSFILE ]; then
40
echo "Please specifiy an lds file with the --lds option"
47
# Now create the two object files:
48
$LD $LDFLAGS -T $LDSFILE -o $TMP1.o $OBJFILES || exit -1
49
$LD $LDFLAGS -T $LDSFILE -o $TMP2.o $OBJFILES --section-start .text=0x4000000000000000 || exit -1
51
$OBJCOPY -O binary $TMP1.o $TMP1.bin || exit -1
52
$OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
54
# Create the relocation table with gen_reloc_table:
55
$DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin
57
$LD -o reloc_table.o -bbinary reloc_table.bin -e0 || exit -1
58
$OBJCOPY --rename-section .data=.reloc reloc_table.o reloc_table.o || exit -1
60
rm -f $TMP1.o $TMP2.o $TMP1.bin $TMP2.bin reloc_table.bin