~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/tools/create_reloc_table.sh

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
8
# *
 
9
# * Contributors:
 
10
# *     IBM Corporation - initial implementation
 
11
# ****************************************************************************/
 
12
#!/bin/sh
 
13
 
 
14
 
 
15
CROSSTMP=`grep ^CROSS $(dirname $0)/../make.rules | cut -d\  -f2`
 
16
 
 
17
CROSS=${CROSS-$CROSSTMP}
 
18
 
 
19
# Set defaults:
 
20
LD="${CROSS}ld"
 
21
LDFLAGS="-nostdlib"
 
22
LDSFILE=""
 
23
OBJCOPY="${CROSS}objcopy"
 
24
 
 
25
DIRNAME=`dirname $0`
 
26
 
 
27
# Parse parameters:
 
28
while [ $# -gt 0 ] ; do
 
29
        case "$1" in
 
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 ;;
 
36
        esac
 
37
done
 
38
 
 
39
if [ -z $LDSFILE ]; then
 
40
        echo "Please specifiy an lds file with the --lds option"
 
41
        exit 42
 
42
fi
 
43
 
 
44
TMP1=`mktemp`
 
45
TMP2=`mktemp`
 
46
 
 
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
 
50
 
 
51
$OBJCOPY -O binary $TMP1.o $TMP1.bin || exit -1
 
52
$OBJCOPY -O binary $TMP2.o $TMP2.bin || exit -1
 
53
 
 
54
# Create the relocation table with gen_reloc_table:
 
55
$DIRNAME/gen_reloc_table $TMP1.bin $TMP2.bin reloc_table.bin
 
56
 
 
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
 
59
 
 
60
rm -f $TMP1.o $TMP2.o $TMP1.bin $TMP2.bin reloc_table.bin