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

Contents of /src/tools/linker.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Tue Jul 17 15:25:14 2007 UTC (6 years, 9 months ago) by fgilham
Branch: MAIN
Changes since 1.2: +5 -52 lines
File MIME type: application/x-sh
Simplify finding C runtime object files.  Suggested by Ray Toy.
1 fgilham 1.1 #!/bin/sh -x
2    
3 fgilham 1.3 # $Id: linker.sh,v 1.3 2007/07/17 15:25:14 fgilham 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 fgilham 1.2 # Set OS-specific variables.
33 fgilham 1.1 case "$OPSYS" in
34     Linux )
35 fgilham 1.2 DLINKER='-dynamic-linker /lib/ld-linux.so.2'
36 fgilham 1.1 STARTCRT="$LIBROOT/../../../crt1.o $LIBROOT/../../../crti.o $LIBROOT/crtbegin.o"
37     ENDCRT="$LIBROOT/crtend.o $LIBROOT/../../../crtn.o"
38     LIBS="-L$LIBROOT -ldl -lm -lgcc -lc -lgcc"
39     ;;
40     FreeBSD )
41 fgilham 1.2 DLINKER='-dynamic-linker /usr/libexec/ld-elf.so.1'
42 fgilham 1.1 STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
43     ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
44 fgilham 1.2 LIBS='-lm -lgcc -lc -lgcc'
45 fgilham 1.1 ;;
46     * )
47     echo "$0: unknown operating system $OPSYS."
48     exit 1
49     ;;
50     esac
51    
52     OUTPUT="-o $2"
53     LINKER=/usr/bin/ld
54     CMUCLLIB=`dirname $0`
55     OBJS="--whole-archive $CMUCLLIB/lisp.a --no-whole-archive"
56 fgilham 1.2 FLAGS='-export-dynamic'
57 fgilham 1.1
58     SCRIPT="-T $CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
59    
60 fgilham 1.2 # This is a hack.
61     # BIFLAG flags the executable as having a builtin lisp image. It should be
62     # a valid address because it will be dereferenced. It should also not point
63     # to an integer 0 because that would make the flag false. We use the first
64     # address in the process memory image, which should point to the ELF header.
65 fgilham 1.1
66     # XXXX The process image start address can change depending on the OS
67     # (at least).
68 fgilham 1.2 BIFLAG='--defsym builtin_image_flag=0x08048000'
69 fgilham 1.1
70     # IFADDR is the initial function address, needed to start lisp processing.
71     IFADDR="--defsym initial_function_addr=$1"
72    
73     $LINKER $SCRIPT $DLINKER $OUTPUT $STARTCRT $FLAGS $BIFLAG $IFADDR $OBJS $LIBS $ENDCRT
74 fgilham 1.2
75     exit 0

  ViewVC Help
Powered by ViewVC 1.1.5