CMUCL commit: src (5 files)
Raymond Toy
rtoy at common-lisp.net
Thu Jul 29 06:34:10 CEST 2010
Date: Thursday, July 29, 2010 @ 00:34:10
Author: rtoy
Path: /project/cmucl/cvsroot/src
Modified: lisp/elf.c lisp/elf.h lisp/save.c tools/linker.sh
tools/make-main-dist.sh
Change how we build executables for Linux. We no longer need the
hairy and fragile linker script. Instead, we can use regular old gcc
to do what we need.
(Should also work for FreeBSD, but not yet implemented.)
lisp/elf.c:
o Include validate.h so we can get the starting addresses of the
read-only, static, and dynamic spaces.
o Add special case for linux to run the linker script correctly.
lisp/elf.h:
o There's a separate linker script for Linux.
lisp/save.c:
o Temporarily don't run elf_cleanup so we can have easier
testing/debugging.
tools/linker.sh:
o Don't need BIFLAG anymore.
tools/make-main-dist.sh:
o Install linker-x86.sh.
-------------------------+
lisp/elf.c | 15 +++++++++++----
lisp/elf.h | 6 +++++-
lisp/save.c | 5 +++--
tools/linker.sh | 4 ++--
tools/make-main-dist.sh | 1 +
5 files changed, 22 insertions(+), 9 deletions(-)
Index: src/lisp/elf.c
diff -u src/lisp/elf.c:1.20 src/lisp/elf.c:1.21
--- src/lisp/elf.c:1.20 Mon Jul 26 22:35:25 2010
+++ src/lisp/elf.c Thu Jul 29 00:34:10 2010
@@ -8,7 +8,7 @@
Above changes put into main CVS branch. 05-Jul-2007.
- $Id: elf.c,v 1.20 2010-07-27 02:35:25 rtoy Exp $
+ $Id: elf.c,v 1.21 2010-07-29 04:34:10 rtoy Exp $
*/
#include <stdio.h>
@@ -24,6 +24,7 @@
#include "internals.h"
#include "globals.h"
#include "elf.h"
+#include "validate.h"
static char elf_magic_string[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3};
@@ -37,7 +38,6 @@
static char *section_names[] = {"CORDYN", "CORSTA", "CORRO"};
#ifdef SOLARIS
-#include "sparc-validate.h"
/*
* Starting address of the three ELF sections/spaces. These must be
* in the same order as section_names above!
@@ -331,7 +331,6 @@
int
elf_run_linker(long init_func_address, char *file)
{
-
lispobj libstring = SymbolValue(CMUCL_LIB); /* Get library: */
struct vector *vec = (struct vector *)PTR(libstring);
char *paths;
@@ -373,14 +372,22 @@
printf(" %s\n", command);
}
- if(stat(command, &st) == 0) {
+ if (stat(command, &st) == 0) {
extern int main();
free(paths);
printf("\t[%s: linking %s... \n", command, file);
fflush(stdout);
+#ifdef __linux__
+ sprintf(command_line, "%s %s 0x%lx '%s' 0x%lx 0x%lx 0x%lx", command,
+ C_COMPILER, init_func_address, file,
+ (unsigned long) READ_ONLY_SPACE_START,
+ (unsigned long) STATIC_SPACE_START,
+ (unsigned long) DYNAMIC_0_SPACE_START);
+#else
sprintf(command_line, "%s %s 0x%lx 0x%lx %s", command, C_COMPILER,
init_func_address, (unsigned long) &main, file);
+#endif
ret = system(command_line);
if(ret == -1) {
perror("Can't run link script");
Index: src/lisp/elf.h
diff -u src/lisp/elf.h:1.10 src/lisp/elf.h:1.11
--- src/lisp/elf.h:1.10 Mon Jan 19 22:58:11 2009
+++ src/lisp/elf.h Thu Jul 29 00:34:10 2010
@@ -1,4 +1,4 @@
-/* $Id: elf.h,v 1.10 2009-01-20 03:58:11 agoncharov Rel $ */
+/* $Id: elf.h,v 1.11 2010-07-29 04:34:10 rtoy Exp $ */
/* This code was written by Fred Gilham and has been placed in the public domain. It is
provided "AS-IS" and without warranty of any kind.
@@ -8,7 +8,11 @@
#define _ELF_H_INCLUDED_
+#if defined(__linux__)
+#define LINKER_SCRIPT "linker-x86.sh"
+#else
#define LINKER_SCRIPT "linker.sh"
+#endif
#if defined(SOLARIS)
#include <sys/elf.h>
Index: src/lisp/save.c
diff -u src/lisp/save.c:1.23 src/lisp/save.c:1.24
--- src/lisp/save.c:1.23 Thu Dec 17 23:03:24 2009
+++ src/lisp/save.c Thu Jul 29 00:34:10 2010
@@ -1,6 +1,6 @@
/*
- $Header: /project/cmucl/cvsroot/src/lisp/save.c,v 1.23 2009-12-18 04:03:24 agoncharov Exp $
+ $Header: /project/cmucl/cvsroot/src/lisp/save.c,v 1.24 2010-07-29 04:34:10 rtoy Exp $
This code was written as part of the CMU Common Lisp project at
Carnegie Mellon University, and has been placed in the public domain.
@@ -362,8 +362,9 @@
printf("Linking executable...\n");
fflush(stdout);
elf_run_linker(init_function, filename);
+#if 0
elf_cleanup(dir_name);
-
+#endif
printf("done.\n");
exit(0);
}
Index: src/tools/linker.sh
diff -u src/tools/linker.sh:1.13 src/tools/linker.sh:1.14
--- src/tools/linker.sh:1.13 Wed Jul 28 21:51:12 2010
+++ src/tools/linker.sh Thu Jul 29 00:34:10 2010
@@ -1,6 +1,6 @@
#!/bin/sh -x
-# $Id: linker.sh,v 1.13 2010-07-29 01:51:12 rtoy Exp $
+# $Id: linker.sh,v 1.14 2010-07-29 04:34:10 rtoy Exp $
# This file was written by Fred Gilham and is placed in the public domain.
# It comes without warranty of any kind.
@@ -72,7 +72,7 @@
# XXXX The process image start address can change depending on the OS
# (at least).
-BIFLAG="--defsym builtin_image_flag=$2"
+#BIFLAG="--defsym builtin_image_flag=$2"
# IFADDR is the initial function address, needed to start lisp processing.
IFADDR="--defsym initial_function_addr=$1"
Index: src/tools/make-main-dist.sh
diff -u src/tools/make-main-dist.sh:1.21 src/tools/make-main-dist.sh:1.22
--- src/tools/make-main-dist.sh:1.21 Mon Jul 5 16:32:33 2010
+++ src/tools/make-main-dist.sh Thu Jul 29 00:34:10 2010
@@ -92,6 +92,7 @@
then
install ${GROUP} ${OWNER} -m 0755 $TARGET/lisp/lisp.a $DESTDIR/lib/cmucl/lib/
install ${GROUP} ${OWNER} -m 0755 src/tools/linker.sh $DESTDIR/lib/cmucl/lib/
+ install ${GROUP} ${OWNER} -m 0755 src/tools/linker-x86.sh $DESTDIR/lib/cmucl/lib/
install ${GROUP} ${OWNER} -m 0755 src/tools/$SCRIPT-cmucl-linker-script $DESTDIR/lib/cmucl/lib/
fi
for corefile in $TARGET/lisp/$CORE
More information about the cmucl-commit
mailing list