/[cmucl]/src/tools/linker.sh
ViewVC logotype

Contents of /src/tools/linker.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations)
Wed Jul 25 16:33:16 2007 UTC (6 years, 9 months ago) by rtoy
Branch: MAIN
CVS Tags: snapshot-2007-08
Changes since 1.5: +3 -1 lines
File MIME type: application/x-sh
Remove the sunos-map-file when linker.sh exits.
1 fgilham 1.1 #!/bin/sh -x
2    
3 rtoy 1.6 # $Id: linker.sh,v 1.6 2007/07/25 16:33:16 rtoy Exp $
4 fgilham 1.1
5     # This file was written by Fred Gilham and is placed in the public domain.
6     # It comes without warranty of any kind.
7    
8 fgilham 1.2 PATH=/bin:/usr/bin:/usr/local/bin
9    
10     GCC=`which gcc`
11    
12     if [ -z "$GCC" ]
13     then
14     echo 'Cannot find GCC. How did you build lisp?'
15     exit 1
16     fi
17    
18 fgilham 1.3 # Uniform method for finding GCC C runtime object files suggested by Ray Toy
19     CRTPATH=`$GCC -print-libgcc-file-name`
20     LIBROOT=`dirname $CRTPATH`
21     echo "LIBROOT is $LIBROOT"
22 fgilham 1.2
23 fgilham 1.1 if [ $# -ne 2 ]
24     then
25     echo "Usage: `basename $0` <initial function address> <executable file>"
26     exit 1
27     fi
28    
29     OPSYS=`uname`
30 fgilham 1.2 VER=''
31 fgilham 1.1
32 rtoy 1.5 # Default values
33     OUTPUT="-o $2"
34     LINKER=/usr/bin/ld
35     CMUCLLIB=`dirname $0`
36     OBJS="--whole-archive $CMUCLLIB/lisp.a --no-whole-archive"
37     FLAGS='-export-dynamic'
38    
39     SCRIPT="-T $CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
40    
41     # This is a hack.
42     # These are the default values.
43     #
44     # BIFLAG flags the executable as having a builtin lisp image. It should be
45     # a valid address because it will be dereferenced. It should also not point
46     # to an integer 0 because that would make the flag false. We use the first
47     # address in the process memory image, which should point to the ELF header.
48    
49     # XXXX The process image start address can change depending on the OS
50     # (at least).
51     BIFLAG='--defsym builtin_image_flag=0x08048000'
52    
53     # IFADDR is the initial function address, needed to start lisp processing.
54     IFADDR="--defsym initial_function_addr=$1"
55    
56 fgilham 1.2 # Set OS-specific variables.
57 fgilham 1.1 case "$OPSYS" in
58     Linux )
59 fgilham 1.4 # Handle x86_64 version system. This should be revisited when there's a 64-bit version
60     # of CMUCL on Linux. Note that -m32 won't work in older versions of GCC which we may
61     # still want to support.
62     ARCH=`uname -m`
63     if [ "$ARCH" = "x86_64" ]
64     then
65     CRTPATH=`$GCC -m32 -print-libgcc-file-name`
66     LIBROOT=`dirname $CRTPATH`
67     fi
68     STARTCRT="/usr/lib/crt1.o /usr/lib/crti.o $LIBROOT/crtbegin.o"
69     ENDCRT="$LIBROOT/crtend.o /usr/lib/crtn.o"
70 fgilham 1.2 DLINKER='-dynamic-linker /lib/ld-linux.so.2'
71 fgilham 1.1 LIBS="-L$LIBROOT -ldl -lm -lgcc -lc -lgcc"
72     ;;
73     FreeBSD )
74 fgilham 1.2 DLINKER='-dynamic-linker /usr/libexec/ld-elf.so.1'
75 fgilham 1.1 STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
76     ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
77 fgilham 1.2 LIBS='-lm -lgcc -lc -lgcc'
78 fgilham 1.1 ;;
79 rtoy 1.5 SunOS )
80     STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
81     ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
82     LIBS="-L$LIBROOT -lm -lgcc -lc -lgcc -lsocket -lnsl -ldl"
83     LINKER="/usr/ccs/bin/ld"
84     OBJS="-z allextract $CMUCLLIB/lisp.a CORRO.o CORSTA.o CORDYN.o -z defaultextract"
85     SCRIPT="$CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
86     # Is this right? I just made this point to &main, and the
87     # first word of main isn't all zeros.
88     BIFLAG=0x14120
89     IFADDR=
90     sed -e "s;@BIFLAG@;$BIFLAG;" -e "s;@IFADDR@;$1;" $SCRIPT > sunos-map-file
91     SCRIPT="-M sunos-map-file"
92 rtoy 1.6 # Remove the sunos-map-file when the script exits.
93     trap 'rm -f sunos-map-file' 0
94 rtoy 1.5 FLAGS=
95     BIFLAG=
96     ;;
97 fgilham 1.1 * )
98     echo "$0: unknown operating system $OPSYS."
99     exit 1
100     ;;
101     esac
102    
103     $LINKER $SCRIPT $DLINKER $OUTPUT $STARTCRT $FLAGS $BIFLAG $IFADDR $OBJS $LIBS $ENDCRT
104 fgilham 1.2
105     exit 0

  ViewVC Help
Powered by ViewVC 1.1.5