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

Contents of /src/tools/linker.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Jul 7 16:00:49 2007 UTC (6 years, 9 months ago) by fgilham
Branch: MAIN
File MIME type: application/x-sh
Add linker script for building Lisp executables.
1 #!/bin/sh -x
2
3 # $Id: linker.sh,v 1.1 2007/07/07 16:00:49 fgilham Exp $
4
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 if [ $# -ne 2 ]
9 then
10 echo "Usage: `basename $0` <initial function address> <executable file>"
11 exit 1
12 fi
13
14 OPSYS=`uname`
15 VER=""
16
17 # Set OS-specific variables. Things marked XXXX can possibly change
18 # with different operationg systems, different distributions (Linux)
19 # or different releases (FreeBSD).
20 case "$OPSYS" in
21 Linux )
22 # XXXX This can change depending on any number of things....
23 LIBROOT=/usr/lib/gcc-lib/i386-redhat-linux/2.96
24 DLINKER="-dynamic-linker /lib/ld-linux.so.2"
25 STARTCRT="$LIBROOT/../../../crt1.o $LIBROOT/../../../crti.o $LIBROOT/crtbegin.o"
26 ENDCRT="$LIBROOT/crtend.o $LIBROOT/../../../crtn.o"
27 LIBS="-L$LIBROOT -ldl -lm -lgcc -lc -lgcc"
28 ;;
29 FreeBSD )
30 # XXXX I guess we have to just keep adding to this.
31 # XXXXX Maybe not. Seems like there's more compatibility than I
32 # thought between binary versions.
33 RELEASE=`uname -r`
34 # case $RELEASE in
35 # 4* ) VER=4 ;;
36 # 5* ) VER=5 ;;
37 # * ) echo "$0: unknown FreeBSD version $RELEASE" ; exit 1 ;;
38 # esac
39 LIBROOT=/usr/lib
40 DLINKER="-dynamic-linker /usr/libexec/ld-elf.so.1"
41 STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
42 ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
43 LIBS="-lm -lgcc -lc -lgcc"
44 ;;
45 * )
46 echo "$0: unknown operating system $OPSYS."
47 exit 1
48 ;;
49 esac
50
51 OUTPUT="-o $2"
52 LINKER=/usr/bin/ld
53 CMUCLLIB=`dirname $0`
54 OBJS="--whole-archive $CMUCLLIB/lisp.a --no-whole-archive"
55 FLAGS="-export-dynamic"
56
57 # XXXX The linker script is a nasty portability issue.
58 SCRIPT="-T $CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
59
60 # BIFLAG flags the executable as having a builtin lisp image. It
61 # should be a valid address because it will be dereferenced. It
62 # should also not point to an integer 0. We use the first address in
63 # the process memory image, which should point to the ELF header.
64
65 # XXXX The process image start address can change depending on the OS
66 # (at least).
67 BIFLAG="--defsym builtin_image_flag=0x08048000"
68
69 # IFADDR is the initial function address, needed to start lisp processing.
70 IFADDR="--defsym initial_function_addr=$1"
71
72 $LINKER $SCRIPT $DLINKER $OUTPUT $STARTCRT $FLAGS $BIFLAG $IFADDR $OBJS $LIBS $ENDCRT

  ViewVC Help
Powered by ViewVC 1.1.5