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

Contents of /src/tools/linker.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Mon Sep 28 12:32:42 2009 UTC (4 years, 6 months ago) by rtoy
Branch: MAIN
CVS Tags: sparc-tramp-assem-base, post-merge-intl-branch, intl-branch-working-2010-02-19-1000, sparc-tramp-assem-2010-07-19, amd64-dd-start, intl-2-branch-base, intl-branch-working-2010-02-11-1000, pre-merge-intl-branch, snapshot-2010-05, snapshot-2010-04, snapshot-2010-07, snapshot-2010-06, snapshot-2010-01, snapshot-2010-03, snapshot-2010-02, intl-branch-2010-03-18-1300, snapshot-2009-11, snapshot-2009-12, intl-branch-base
Branch point for: sparc-tramp-assem-branch, amd64-dd-branch, intl-branch, intl-2-branch
Changes since 1.7: +6 -1 lines
File MIME type: application/x-sh
From A.M.Raportirenko, on cmucl-imp, Sep 25, 2009: dirname
destructively modifies its argument.

lisp/save.c:
o Call dirname once, saving the result, and use it everywhere.
1 #!/bin/sh -x
2
3 # $Id: linker.sh,v 1.8 2009/09/28 12:32:42 rtoy Rel $
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 3 ]
9 then
10 echo "Usage: `basename $0` <c-compiler> <initial function address> <executable file>"
11 exit 1
12 fi
13
14 CCOMPILER=$1
15 shift;
16
17 if [ $CCOMPILER = "cc" ]; then
18 # Sun C compiler
19
20 # Can't set PATH because we don't really know where the compiler
21 # is. The user has to have it in his path.
22
23 CC=`which cc`
24 if [ -z "$CC" ]; then
25 echo 'Cannot find Sun C. Is it available and in $PATH?'
26 exit 1
27 fi
28 CRTPATH=`dirname $CC`/../prod
29 LIBROOT=$CRTPATH/lib
30
31 else
32 # Gcc
33 PATH=/bin:/usr/bin:/usr/local/bin
34
35 GCC=`which gcc`
36
37 if [ -z "$GCC" ]; then
38 echo 'Cannot find GCC. How did you build lisp?'
39 exit 1
40 fi
41
42 # Uniform method for finding GCC C runtime object files suggested by Ray Toy
43 CRTPATH=`$GCC -print-libgcc-file-name`
44 LIBROOT=`dirname $CRTPATH`
45 fi
46
47 echo "LIBROOT is $LIBROOT"
48
49 OPSYS=`uname`
50 VER=''
51
52 # Default values
53 OUTPUT="-o $2"
54 OUTDIR=`dirname $2`
55 CURDIR=`pwd`
56
57 LINKER=/usr/bin/ld
58 CMUCLLIB=`dirname $0`
59 OBJS="--whole-archive $CMUCLLIB/lisp.a --no-whole-archive"
60 FLAGS='-export-dynamic'
61
62 SCRIPT="-T $CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
63
64 # This is a hack.
65 # These are the default values.
66 #
67 # BIFLAG flags the executable as having a builtin lisp image. It should be
68 # a valid address because it will be dereferenced. It should also not point
69 # to an integer 0 because that would make the flag false. We use the first
70 # address in the process memory image, which should point to the ELF header.
71
72 # XXXX The process image start address can change depending on the OS
73 # (at least).
74 BIFLAG='--defsym builtin_image_flag=0x08048000'
75
76 # IFADDR is the initial function address, needed to start lisp processing.
77 IFADDR="--defsym initial_function_addr=$1"
78
79 # Set OS-specific variables.
80 case "$OPSYS" in
81 Linux )
82 # Handle x86_64 version system. This should be revisited when there's a 64-bit version
83 # of CMUCL on Linux. Note that -m32 won't work in older versions of GCC which we may
84 # still want to support.
85 ARCH=`uname -m`
86 if [ "$ARCH" = "x86_64" ]
87 then
88 CRTPATH=`$GCC -m32 -print-libgcc-file-name`
89 LIBROOT=`dirname $CRTPATH`
90 fi
91 STARTCRT="/usr/lib/crt1.o /usr/lib/crti.o $LIBROOT/crtbegin.o"
92 ENDCRT="$LIBROOT/crtend.o /usr/lib/crtn.o"
93 DLINKER='-dynamic-linker /lib/ld-linux.so.2'
94 LIBS="-L$LIBROOT -ldl -lm -lgcc -lc -lgcc"
95 ;;
96 FreeBSD )
97 DLINKER='-dynamic-linker /usr/libexec/ld-elf.so.1'
98 STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
99 ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
100 LIBS='-lm -lgcc -lc -lgcc'
101 ;;
102 SunOS )
103 if [ $CCOMPILER = "cc" ]; then
104 # These values were obtained by running cc -# hello.c and
105 # looking at the linker command.
106 STARTCRT="$LIBROOT/crti.o $LIBROOT/crt1.o $LIBROOT/misalign.o $LIBROOT/values-xa.o"
107 ENDCRT="$LIBROOT/crtn.o"
108 LIBS="-Y P,$LIBROOT/v8plus:$LIBROOT:/usr/ccs/lib:/lib:/usr/lib -Qy -lm -lc -lsocket -lnsl -ldl"
109 else
110 STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
111 ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
112 LIBS="-L$LIBROOT -lm -lgcc -lc -lgcc -lsocket -lnsl -ldl"
113 fi
114 LINKER="/usr/ccs/bin/ld"
115 OBJS="-z allextract $CMUCLLIB/lisp.a CORRO.o CORSTA.o CORDYN.o -z defaultextract"
116 SCRIPT="$CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
117 # Is this right? I just made this point to &main, and the
118 # first word of main isn't all zeros.
119 BIFLAG=0x14120
120 IFADDR=
121 sed -e "s;@BIFLAG@;$BIFLAG;" -e "s;@IFADDR@;$1;" $SCRIPT > sunos-map-file
122 SCRIPT="-M sunos-map-file"
123 # Remove the sunos-map-file when the script exits.
124 trap 'rm -f sunos-map-file' 0
125 FLAGS=
126 BIFLAG=
127 ;;
128 * )
129 echo "$0: unknown operating system $OPSYS."
130 exit 1
131 ;;
132 esac
133
134 cd $OUTDIR
135 $LINKER $SCRIPT $DLINKER $OUTPUT $STARTCRT $FLAGS $BIFLAG $IFADDR $OBJS $LIBS $ENDCRT
136 cd $CURDIR
137
138 exit 0

  ViewVC Help
Powered by ViewVC 1.1.5