Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl-copy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard M Kreuter
cmucl-copy
Commits
b722d46e
Commit
b722d46e
authored
17 years ago
by
fgilham
Browse files
Options
Downloads
Patches
Plain Diff
Fix script so it will work with different versions of Linux (with any luck).
parent
946a3f59
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/linker.sh
+76
-26
76 additions, 26 deletions
tools/linker.sh
with
76 additions
and
26 deletions
tools/linker.sh
+
76
−
26
View file @
b722d46e
#!/bin/sh -x
# $Id: linker.sh,v 1.
1
2007/07/
07 16:00:49
fgilham Exp $
# $Id: linker.sh,v 1.
2
2007/07/
12 04:50:22
fgilham Exp $
# This file was written by Fred Gilham and is placed in the public domain.
# It comes without warranty of any kind.
PATH
=
/bin:/usr/bin:/usr/local/bin
GCC
=
`
which gcc
`
if
[
-z
"
$GCC
"
]
then
echo
'Cannot find GCC. How did you build lisp?'
exit
1
fi
set_libroot
()
{
LIBROOT
=
`
$GCC
-v
2>&1 |
\
grep
'Reading'
|
\
sed
-e
's/Reading specs from //'
|
\
sed
-e
's|/specs||'
`
echo
"LIBROOT is
$LIBROOT
"
}
find_libroot
()
{
LIBROOT
=
''
GCC_VERSION
=
`
$GCC
-v
2>&1 |
\
grep
'gcc version'
|
\
sed
-e
's/gcc version //'
|
\
sed
-e
's/ .*//'
`
if
[
-z
"
$GCC_VERSION
"
]
;
then
echo
"Can't get the version from GCC. Something is very wrong."
exit
1
fi
CRT_DIR
=
`
find /usr/lib
-name
$GCC_VERSION
-print
`
if
[
-f
$CRT_DIR
/crtbegin.o
]
&&
[
-f
$CRT_DIR
/crtend.o
]
;
then
LIBROOT
=
$CRT_DIR
else
if
[
-f
/usr/lib/crtbegin.o
]
&&
[
-f
/usr/lib/crtend.o
]
;
then
# I doubt that this is right. After all, this is Linux. You
# don't expect to find things in reasonable places.
LIBROOT
=
/usr/lib
fi
fi
if
[
-z
$LIBROOT
]
;
then
echo
"Can't find the directory with the C runtime object files. Exiting."
exit
1
fi
echo
"LIBROOT is
$LIBROOT
"
}
if
[
$#
-ne
2
]
then
echo
"Usage:
`
basename
$0
`
<initial function address> <executable file>"
...
...
@@ -12,35 +65,30 @@ if [ $# -ne 2 ]
fi
OPSYS
=
`
uname
`
VER
=
""
VER
=
''
# Set OS-specific variables. Things marked XXXX can possibly change
# with different operationg systems, different distributions (Linux)
# or different releases (FreeBSD).
# Set OS-specific variables.
case
"
$OPSYS
"
in
Linux
)
# XXXX This can change depending on any number of things....
LIBROOT
=
/usr/lib/gcc-lib/i386-redhat-linux/2.96
DLINKER
=
"-dynamic-linker /lib/ld-linux.so.2"
# See if this is a version of Linux where GCC reports
# where it gets the specs from. Extract the location of
# the C runtime object files from that.
set_libroot
if
[
-z
"
$LIBROOT
"
]
;
then
# We have to do it the hard way.
find_libroot
fi
DLINKER
=
'-dynamic-linker /lib/ld-linux.so.2'
STARTCRT
=
"
$LIBROOT
/../../../crt1.o
$LIBROOT
/../../../crti.o
$LIBROOT
/crtbegin.o"
ENDCRT
=
"
$LIBROOT
/crtend.o
$LIBROOT
/../../../crtn.o"
LIBS
=
"-L
$LIBROOT
-ldl -lm -lgcc -lc -lgcc"
;;
FreeBSD
)
# XXXX I guess we have to just keep adding to this.
# XXXXX Maybe not. Seems like there's more compatibility than I
# thought between binary versions.
RELEASE
=
`
uname
-r
`
# case $RELEASE in
# 4* ) VER=4 ;;
# 5* ) VER=5 ;;
# * ) echo "$0: unknown FreeBSD version $RELEASE" ; exit 1 ;;
# esac
LIBROOT
=
/usr/lib
DLINKER
=
"
-dynamic-linker /usr/libexec/ld-elf.so.1
"
DLINKER
=
'
-dynamic-linker /usr/libexec/ld-elf.so.1
'
STARTCRT
=
"
$LIBROOT
/crt1.o
$LIBROOT
/crti.o
$LIBROOT
/crtbegin.o"
ENDCRT
=
"
$LIBROOT
/crtend.o
$LIBROOT
/crtn.o"
LIBS
=
"
-lm -lgcc -lc -lgcc
"
LIBS
=
'
-lm -lgcc -lc -lgcc
'
;;
*
)
echo
"
$0
: unknown operating system
$OPSYS
."
...
...
@@ -52,21 +100,23 @@ OUTPUT="-o $2"
LINKER
=
/usr/bin/ld
CMUCLLIB
=
`
dirname
$0
`
OBJS
=
"--whole-archive
$CMUCLLIB
/lisp.a --no-whole-archive"
FLAGS
=
"
-export-dynamic
"
FLAGS
=
'
-export-dynamic
'
# XXXX The linker script is a nasty portability issue.
SCRIPT
=
"-T
$CMUCLLIB
/
$OPSYS$VER
-cmucl-linker-script"
# BIFLAG flags the executable as having a builtin lisp image. It
# should be a valid address because it will be dereferenced. It
# should also not point to an integer 0. We use the first address in
# the process memory image, which should point to the ELF header.
# This is a hack.
# BIFLAG flags the executable as having a builtin lisp image. It should be
# a valid address because it will be dereferenced. It should also not point
# to an integer 0 because that would make the flag false. We use the first
# address in the process memory image, which should point to the ELF header.
# XXXX The process image start address can change depending on the OS
# (at least).
BIFLAG
=
"
--defsym builtin_image_flag=0x08048000
"
BIFLAG
=
'
--defsym builtin_image_flag=0x08048000
'
# IFADDR is the initial function address, needed to start lisp processing.
IFADDR
=
"--defsym initial_function_addr=
$1
"
$LINKER
$SCRIPT
$DLINKER
$OUTPUT
$STARTCRT
$FLAGS
$BIFLAG
$IFADDR
$OBJS
$LIBS
$ENDCRT
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment