CMUCL commit: RELEASE-20B-BRANCH src (9 files)

Raymond Toy rtoy at common-lisp.net
Thu Sep 9 02:16:20 CEST 2010


    Date: Wednesday, September 8, 2010 @ 20:16:20
  Author: rtoy
    Path: /project/cmucl/cvsroot/src
     Tag: RELEASE-20B-BRANCH

Modified: lisp/FreeBSD-os.c lisp/elf.c lisp/elf.h tools/linker.sh
          tools/make-main-dist.sh
 Removed: tools/FreeBSD-cmucl-linker-script tools/Linux-cmucl-linker-script
          tools/SunOS-cmucl-linker-script tools/linker-x86.sh

Merge changes from HEAD that allow the executable feature to work
again on FreeBSD.


-----------------------------------+
 lisp/FreeBSD-os.c                 |   10 +
 lisp/elf.c                        |    7 -
 lisp/elf.h                        |   10 -
 tools/FreeBSD-cmucl-linker-script |   79 +++++-------
 tools/Linux-cmucl-linker-script   |  217 --------------------------------
 tools/SunOS-cmucl-linker-script   |   23 ---
 tools/linker-x86.sh               |   20 +--
 tools/linker.sh                   |  237 +++++++++++++++++-------------------
 tools/make-main-dist.sh           |    1 
 9 files changed, 172 insertions(+), 432 deletions(-)


Index: src/lisp/FreeBSD-os.c
diff -u src/lisp/FreeBSD-os.c:1.34 src/lisp/FreeBSD-os.c:1.34.4.1
--- src/lisp/FreeBSD-os.c:1.34	Sun Jun 27 09:17:17 2010
+++ src/lisp/FreeBSD-os.c	Wed Sep  8 20:16:19 2010
@@ -12,7 +12,7 @@
  * Much hacked by Paul Werkowski
  * GENCGC support by Douglas Crosher, 1996, 1997.
  *
- * $Header: /project/cmucl/cvsroot/src/lisp/FreeBSD-os.c,v 1.34 2010-06-27 13:17:17 rtoy Exp $
+ * $Header: /project/cmucl/cvsroot/src/lisp/FreeBSD-os.c,v 1.34.4.1 2010-09-09 00:16:19 rtoy Exp $
  *
  */
 
@@ -307,6 +307,11 @@
 void *
 os_dlsym(const char *sym_name, lispobj lib_list)
 {
+    static void *program_handle;
+
+    if (!program_handle)
+	program_handle = dlopen((void *) 0, RTLD_LAZY | RTLD_GLOBAL);
+
     if (lib_list != NIL) {
 	lispobj lib_list_head;
 
@@ -320,8 +325,7 @@
 		return sym_addr;
 	}
     }
-
-    return dlsym(RTLD_DEFAULT, sym_name);
+    return dlsym(program_handle, sym_name);
 }
 
 void
Index: src/lisp/elf.c
diff -u src/lisp/elf.c:1.29 src/lisp/elf.c:1.29.2.1
--- src/lisp/elf.c:1.29	Mon Aug  2 17:59:43 2010
+++ src/lisp/elf.c	Wed Sep  8 20:16:19 2010
@@ -8,7 +8,7 @@
 
  Above changes put into main CVS branch. 05-Jul-2007.
 
- $Id: elf.c,v 1.29 2010-08-02 21:59:43 rtoy Exp $
+ $Id: elf.c,v 1.29.2.1 2010-09-09 00:16:19 rtoy Exp $
 */
 
 #include <stdio.h>
@@ -358,18 +358,17 @@
         }
         
 	if (stat(command, &st) == 0) {
-            extern int main();
-            
 	    free(paths);
 	    printf("\t[%s: linking %s... \n", command, file);
 	    fflush(stdout);
-#if defined(__linux__) || defined(sparc)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(sparc)
             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
+            extern int main();
 	    sprintf(command_line, "%s %s 0x%lx 0x%lx %s", command, C_COMPILER,
                     init_func_address, (unsigned long) &main, file);
 #endif
Index: src/lisp/elf.h
diff -u src/lisp/elf.h:1.13 src/lisp/elf.h:1.13.2.1
--- src/lisp/elf.h:1.13	Fri Jul 30 21:07:15 2010
+++ src/lisp/elf.h	Wed Sep  8 20:16:19 2010
@@ -1,4 +1,4 @@
-/* $Id: elf.h,v 1.13 2010-07-31 01:07:15 rtoy Exp $ */
+/* $Id: elf.h,v 1.13.2.1 2010-09-09 00:16:19 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.
@@ -13,16 +13,10 @@
 
 #define _ELF_H_INCLUDED_
 
-#if defined(__linux__) || defined(DARWIN) || defined(sparc)
 /*
- * Yes, it's named badly.  But it works for sparc too, not just x86.
- * If we ever get this fixed on FreeBSD, then we can move
- * linker-x86.sh to linker.sh and be done with it.
+ * Script to use for linking everything to make an executable.
  */
-#define LINKER_SCRIPT "linker-x86.sh"
-#else
 #define LINKER_SCRIPT "linker.sh"
-#endif
 
 #if defined(SOLARIS)
 #include <sys/elf.h>
Index: src/tools/FreeBSD-cmucl-linker-script
diff -u src/tools/FreeBSD-cmucl-linker-script:1.1 src/tools/FreeBSD-cmucl-linker-script:1.2
--- src/tools/FreeBSD-cmucl-linker-script:1.1	Sat Jul  7 12:04:34 2007
+++ src/tools/FreeBSD-cmucl-linker-script	Mon Sep  6 23:56:38 2010
@@ -1,43 +1,33 @@
-/* Script of linker directives for building Lisp executables with CMU
-   Lisp.  Derived from GNU linker script. For FreeBSD 5.
-   $Id: FreeBSD-cmucl-linker-script,v 1.1 2007-07-07 16:04:34 fgilham Rel $
-*/
+/* -*- mode: c; -*-
+ * Linker directives for building Lisp executables with CMUCL on FreeBSD 8.x.
+ * 
+ * Obtain via:
+ *
+ *  * ld --verbose > tools/FreeBSD-cmucl-linker-script
+ *  * Remove the === header and footer
+ *  * Paste "Lisp core sections" (the three COR* lines before "Stabs debugging sections"
+ * $Header: /project/cmucl/cvsroot/src/tools/Attic/FreeBSD-cmucl-linker-script,v 1.2 2010-09-07 03:56:38 agoncharov Exp $
+ *
+ */
 
 /* Script for -z combreloc: combine and sort reloc sections */
-
 OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd",
 	      "elf32-i386-freebsd")
 OUTPUT_ARCH(i386)
 ENTRY(_start)
-
-PHDRS
-{
-	headers PT_PHDR PHDRS ;
-	interp PT_INTERP ;
-	text PT_LOAD FILEHDR PHDRS ;
-
-	data PT_LOAD ;
-	dynamic PT_DYNAMIC ;
-        note PT_NOTE ;
-
-	/* Add core sections for Lisp. */
-	CORRO	PT_NOTE ;
-	CORSTA	PT_NOTE ;
-        CORDYN	PT_NOTE ;
-}
-
-SEARCH_DIR("/usr/lib");
+SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
 /* Do we need any of these for elf?
    __DYNAMIC = 0;    */
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  . = 0x08048000 + SIZEOF_HEADERS;
-  .interp         : { *(.interp) } :interp :text
-  .note.ABI-tag   : { *(.note.ABI-tag) } :text :note
-  .hash           : { *(.hash) } :text
-  .dynsym         : { *(.dynsym) } :text
-  .dynstr         : { *(.dynstr) } :text
+  /* PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS; */
+  PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + 52 + 10*32;
+
+  .interp         : { *(.interp) }
+  .hash           : { *(.hash) }
+  .dynsym         : { *(.dynsym) }
+  .dynstr         : { *(.dynstr) }
   .gnu.version    : { *(.gnu.version) }
   .gnu.version_d  : { *(.gnu.version_d) }
   .gnu.version_r  : { *(.gnu.version_r) }
@@ -54,7 +44,7 @@
       *(.rel.dtors)
       *(.rel.got)
       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
-    } :text
+    }
   .rela.dyn       :
     {
       *(.rela.init)
@@ -69,12 +59,12 @@
       *(.rela.got)
       *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
     }
-  .rel.plt        : { *(.rel.plt) } :text
+  .rel.plt        : { *(.rel.plt) }
   .rela.plt       : { *(.rela.plt) }
   .init           :
   {
     KEEP (*(.init))
-  } :text =0x90909090
+  } =0x90909090
   .plt            : { *(.plt) }
   .text           :
   {
@@ -91,10 +81,10 @@
   PROVIDE (etext = .);
   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
   .rodata1        : { *(.rodata1) }
-  .eh_frame_hdr : { *(.eh_frame_hdr) } :data
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
-  . = DATA_SEGMENT_ALIGN(0x1000, 0x1000);
+  . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1)); . = DATA_SEGMENT_ALIGN (0x1000, 0x1000);
   /* Ensure the __preinit_array_start label is properly aligned.  We
      could instead move the label definition inside the section, but
      the linker would then create the section even if it turns out to
@@ -117,9 +107,9 @@
   .data1          : { *(.data1) }
   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
-  .eh_frame       : { KEEP (*(.eh_frame)) } :data
+  .eh_frame       : { KEEP (*(.eh_frame)) }
   .gcc_except_table   : { *(.gcc_except_table) }
-  .dynamic        : { *(.dynamic) } :data :dynamic
+  .dynamic        : { *(.dynamic) }
   .ctors          :
   {
     /* gcc uses crtbegin.o to find the start of
@@ -131,19 +121,19 @@
        wildcard.  The wildcard also means that it
        doesn't matter which directory crtbegin.o
        is in.  */
-    KEEP (*crtbegin.o(.ctors))
+    KEEP (*crtbegin*.o(.ctors))
     /* We don't want to include the .ctor section from
        from the crtend.o file until after the sorted ctors.
        The .ctor section from the crtend file contains the
        end of ctors marker and it must be last */
-    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
     KEEP (*(SORT(.ctors.*)))
     KEEP (*(.ctors))
-  } :data
+  }
   .dtors          :
   {
-    KEEP (*crtbegin.o(.dtors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
     KEEP (*(SORT(.dtors.*)))
     KEEP (*(.dtors))
   }
@@ -168,9 +158,9 @@
   . = DATA_SEGMENT_END (.);
 
   /* Lisp core sections. */
-  CORRO  0x10000000 : { CORRO.o  (CORRO)  } :CORRO
-  CORSTA 0x28f00000 : { CORSTA.o (CORSTA) } :CORSTA
-  CORDYN 0x48000000 : { CORDYN.o (CORDYN) } :CORDYN
+  CORRO  0x10000000 : { CORRO.o  (CORRO)  }
+  CORSTA 0x28f00000 : { CORSTA.o (CORSTA) }
+  CORDYN 0x48000000 : { CORDYN.o (CORDYN) }
 
   /* Stabs debugging sections.  */
   .stab          0 : { *(.stab) }
@@ -205,4 +195,5 @@
   .debug_funcnames 0 : { *(.debug_funcnames) }
   .debug_typenames 0 : { *(.debug_typenames) }
   .debug_varnames  0 : { *(.debug_varnames) }
+  /DISCARD/ : { *(.note.GNU-stack) }
 }
Index: src/tools/Linux-cmucl-linker-script
diff -u src/tools/Linux-cmucl-linker-script:1.3 src/tools/Linux-cmucl-linker-script:removed
--- src/tools/Linux-cmucl-linker-script:1.3	Mon Jul 26 22:35:26 2010
+++ src/tools/Linux-cmucl-linker-script	Wed Sep  8 20:16:20 2010
@@ -1,217 +0,0 @@
-/* For the record, this is the default linker script from openSUSE
- * 11.2 version 2.19.51.20090527-10.26.4, obtained via ld --verbose.  We merely put
- *
- * CORRO  0x10000000 : { CORRO.o  *(CORRO)  }
- * CORSTA 0x28000000 : { CORSTA.o *(CORSTA) }
- * CORDYN 0x58100000 : { CORDYN.o *(CORDYN) }
- *
- * after the DATA_SEGMENT_END stuff and before the Stabs debugging section.
- *
- * NOTE: that if the location of the spaces ever change, the addresses
- * above will need to change too!
- */
-
-/* Script for -z combreloc: combine and sort reloc sections */
-OUTPUT_FORMAT("elf32-i386", "elf32-i386",
-	      "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-
-SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
-
-SECTIONS
-{
-  /* Read-only sections, merged into text segment: */
-  /* The 52 + 10*32 below was SIZEOF_HEADER, but that isn't always
-     right.  Thus, replace it with 52 = sizeof(Elf32_Phdr) and 32 =
-     sizeof(Elf_Ehdr).  We use 10 Elf_Ehdr's because we have ten
-     different segments. */
-  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + 52 + 10*32;
-  .interp         : { *(.interp) }
-  .note.gnu.build-id : { *(.note.gnu.build-id) }
-  .hash           : { *(.hash) }
-  .gnu.hash       : { *(.gnu.hash) }
-  .dynsym         : { *(.dynsym) }
-  .dynstr         : { *(.dynstr) }
-  .gnu.version    : { *(.gnu.version) }
-  .gnu.version_d  : { *(.gnu.version_d) }
-  .gnu.version_r  : { *(.gnu.version_r) }
-  .rel.dyn        :
-    {
-      *(.rel.init)
-      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
-      *(.rel.fini)
-      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
-      *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
-      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
-      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
-      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
-      *(.rel.ctors)
-      *(.rel.dtors)
-      *(.rel.got)
-      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
-    }
-  .rel.ifunc.dyn        :
-    {
-      *(.rel.ifunc.*)
-    }
-  .rel.plt        : { *(.rel.plt) }
-  .init           :
-  {
-    KEEP (*(.init))
-  } =0x90909090
-  .plt            : { *(.plt) }
-  .text           :
-  {
-    *(.text .stub .text.* .gnu.linkonce.t.*)
-    /* .gnu.warning sections are handled specially by elf32.em.  */
-    *(.gnu.warning)
-  } =0x90909090
-  .fini           :
-  {
-    KEEP (*(.fini))
-  } =0x90909090
-  PROVIDE (__etext = .);
-  PROVIDE (_etext = .);
-  PROVIDE (etext = .);
-  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
-  .rodata1        : { *(.rodata1) }
-  .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
-  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
-  /* Adjust the address for the data segment.  We want to adjust up to
-     the same address within the page on the next page up.  */
-  /*. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));*/
-  . = DATA_SEGMENT_ALIGN(0x1000, 0x1000);
-  /* Exception handling  */
-  /* Hope the eh_frame doesn't matter.  We removed this because Debian didn't like this line. */
-  /*.eh_frame       : ONLY_IF_RW ( KEEP *(.eh_frame)) }*/
-  /* This used to have : ONLY_IF_RW, but Debian didn't like that, so we removed the ONLY_IF_RW */
-  .gcc_except_table   : { *(.gcc_except_table .gcc_except_table.*) }
-  /* Thread Local Storage sections  */
-  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
-  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
-  .preinit_array     :
-  {
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP (*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-  }
-  .init_array     :
-  {
-     PROVIDE_HIDDEN (__init_array_start = .);
-     KEEP (*(SORT(.init_array.*)))
-     KEEP (*(.init_array))
-     PROVIDE_HIDDEN (__init_array_end = .);
-  }
-  .fini_array     :
-  {
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP (*(.fini_array))
-    KEEP (*(SORT(.fini_array.*)))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-  }
-  .ctors          :
-  {
-    /* gcc uses crtbegin.o to find the start of
-       the constructors, so we make sure it is
-       first.  Because this is a wildcard, it
-       doesn't matter if the user does not
-       actually link against crtbegin.o; the
-       linker won't look for a file to match a
-       wildcard.  The wildcard also means that it
-       doesn't matter which directory crtbegin.o
-       is in.  */
-    KEEP (*crtbegin.o(.ctors))
-    KEEP (*crtbegin?.o(.ctors))
-    /* We don't want to include the .ctor section from
-       the crtend.o file until after the sorted ctors.
-       The .ctor section from the crtend file contains the
-       end of ctors marker and it must be last */
-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
-    KEEP (*(SORT(.ctors.*)))
-    KEEP (*(.ctors))
-  }
-  .dtors          :
-  {
-    KEEP (*crtbegin.o(.dtors))
-    KEEP (*crtbegin?.o(.dtors))
-    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
-    KEEP (*(SORT(.dtors.*)))
-    KEEP (*(.dtors))
-  }
-  .jcr            : { KEEP (*(.jcr)) }
-  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
-  .dynamic        : { *(.dynamic) }
-  .got            : { *(.got) }
-  . = DATA_SEGMENT_RELRO_END (12, .);
-  .got.plt        : { *(.got.plt) }
-  .data           :
-  {
-    *(.data .data.* .gnu.linkonce.d.*)
-    SORT(CONSTRUCTORS)
-  }
-  .data1          : { *(.data1) }
-  _edata = .; PROVIDE (edata = .);
-  __bss_start = .;
-  .bss            :
-  {
-   *(.dynbss)
-   *(.bss .bss.* .gnu.linkonce.b.*)
-   *(COMMON)
-   /* Align here to ensure that the .bss section occupies space up to
-      _end.  Align after .bss to ensure correct alignment even if the
-      .bss section disappears because there are no input sections.
-      FIXME: Why do we need it? When there is no .bss section, we don't
-      pad the .data section.  */
-   . = ALIGN(. != 0 ? 32 / 8 : 1);
-  }
-  . = ALIGN(32 / 8);
-  . = ALIGN(32 / 8);
-  _end = .; PROVIDE (end = .);
-  . = DATA_SEGMENT_END (.);
-
-  CORRO  0x10000000 : { CORRO.o  *(CORRO)  }
-  CORSTA 0x28000000 : { CORSTA.o *(CORSTA) }
-  CORDYN 0x58100000 : { CORDYN.o *(CORDYN) }
-
-  /* Stabs debugging sections.  */
-  .stab          0 : { *(.stab) }
-  .stabstr       0 : { *(.stabstr) }
-  .stab.excl     0 : { *(.stab.excl) }
-  .stab.exclstr  0 : { *(.stab.exclstr) }
-  .stab.index    0 : { *(.stab.index) }
-  .stab.indexstr 0 : { *(.stab.indexstr) }
-  .comment       0 : { *(.comment) }
-  /* DWARF debug sections.
-     Symbols in the DWARF debugging sections are relative to the beginning
-     of the section so we begin them at 0.  */
-  /* DWARF 1 */
-  .debug          0 : { *(.debug) }
-  .line           0 : { *(.line) }
-  /* GNU DWARF 1 extensions */
-  .debug_srcinfo  0 : { *(.debug_srcinfo) }
-  .debug_sfnames  0 : { *(.debug_sfnames) }
-  /* DWARF 1.1 and DWARF 2 */
-  .debug_aranges  0 : { *(.debug_aranges) }
-  .debug_pubnames 0 : { *(.debug_pubnames) }
-  /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
-  .debug_abbrev   0 : { *(.debug_abbrev) }
-  .debug_line     0 : { *(.debug_line) }
-  .debug_frame    0 : { *(.debug_frame) }
-  .debug_str      0 : { *(.debug_str) }
-  .debug_loc      0 : { *(.debug_loc) }
-  .debug_macinfo  0 : { *(.debug_macinfo) }
-  /* SGI/MIPS DWARF 2 extensions */
-  .debug_weaknames 0 : { *(.debug_weaknames) }
-  .debug_funcnames 0 : { *(.debug_funcnames) }
-  .debug_typenames 0 : { *(.debug_typenames) }
-  .debug_varnames  0 : { *(.debug_varnames) }
-  /* DWARF 3 */
-  .debug_pubtypes 0 : { *(.debug_pubtypes) }
-  .debug_ranges   0 : { *(.debug_ranges) }
-  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
-  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
-
-}
Index: src/tools/SunOS-cmucl-linker-script
diff -u src/tools/SunOS-cmucl-linker-script:1.2 src/tools/SunOS-cmucl-linker-script:removed
--- src/tools/SunOS-cmucl-linker-script:1.2	Wed Jul 28 21:51:12 2010
+++ src/tools/SunOS-cmucl-linker-script	Wed Sep  8 20:16:20 2010
@@ -1,23 +0,0 @@
-# This is basically the contents of /usr/lib/ld/map.default, but
-# modified for our purposes.
-text = V0x10000;
-
-# Add core sections for Lisp
-#
-# We make these files be NOTE sections so that it doesn't mess up the
-# linker and the resulting executable.  We'd really like to use LOAD,
-# but when we do that the linker puts sections (like the procedure
-# linkage table!) into the dynamic space.
-
-corro  = NOTE;
-corro : CORRO : CORRO.o;
-corsta = NOTE;
-corsta : CORSTA : CORSTA.o;
-cordyn = NOTE;
-cordyn : CORDYN : CORDYN.o;
-
-{
-	global:
-		initial_function_addr = data V at IFADDR@ S4;
-};
-
Index: src/tools/linker-x86.sh
diff -u src/tools/linker-x86.sh:1.9 src/tools/linker-x86.sh:1.10
--- src/tools/linker-x86.sh:1.9	Mon Aug  2 17:45:36 2010
+++ src/tools/linker-x86.sh	Tue Sep  7 23:28:08 2010
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# $Id: linker-x86.sh,v 1.9 2010-08-02 21:45:36 rtoy Exp $
+# $Id: linker-x86.sh,v 1.10 2010-09-08 03:28:08 agoncharov Exp $
 
 # This file written by Raymond Toy as part of CMU Common Lisp and is
 # placed in the public domain.
@@ -44,11 +44,13 @@
 
 # Name of file where we write the actual initial function address.
 OPT_IFADDR="cmu-ifaddr-$$.c"
+OPT_IFADDR="cmu-ifaddr-alex.c"
 # Names of the core sections from Lisp.
 OPT_CORE="CORRO.o CORSTA.o CORDYN.o"
 
-case `uname` in
-  Linux*)
+uname_s=`uname`
+case $uname_s in
+  Linux|FreeBSD)
       # How to specify the starting address for each of the sections
       # These aren't needed for Linux any more.  map_core_sections
       # takes care of getting the addresses.
@@ -57,7 +59,7 @@
       #STATIC_ADDR="-Wl,--section-start=CORSTA=$5"
       #DYN_ADDR="-Wl,--section-start=CORDYN=$6"
 
-      #OPT_IFADDR="-Wl,--defsym -Wl,initial_function_addr=$IFADDR"
+      #OPT_IF ADDR="-Wl,--defsym -Wl,initial_function_addr=$IFADDR"
 
       # Specify how to link the entire lisp.a library
       OPT_ARCHIVE="-Wl,--whole-archive -Wl,$CMUCLLIB/lisp.a -Wl,--no-whole-archive"
@@ -65,8 +67,12 @@
       # Extra stuff.
 
       OPT_EXTRA="-rdynamic"
-      # See Config.x86_linux
-      OS_LIBS=-ldl
+
+      # See Config.x86_${uname_s}
+      case $uname_s in
+	Linux) OS_LIBS=-ldl;;
+	FreeBSD) OS_LIBS=-lutil;;
+      esac
       ;;
   Darwin*)
       # How to specify the starting address for each of the sections.
@@ -114,7 +120,7 @@
 esac
 
 # Remove the C file when we're done.
-trap 'rm -f $OUTDIR/$OPT_IFADDR $OUTDIR/CORRO.o $OUTDIR/CORSTA.o $OUTDIR/CORDYN.o' 0
+# trap 'rm -f $OUTDIR/$OPT_IFADDR $OUTDIR/CORRO.o $OUTDIR/CORSTA.o $OUTDIR/CORDYN.o' 0
 
 (cd $OUTDIR
 echo "long initial_function_addr = $IFADDR;" > $OPT_IFADDR
Index: src/tools/linker.sh
diff -u src/tools/linker.sh:1.14 src/tools/linker.sh:1.14.2.1
--- src/tools/linker.sh:1.14	Thu Jul 29 00:34:10 2010
+++ src/tools/linker.sh	Wed Sep  8 20:16:20 2010
@@ -1,140 +1,127 @@
-#!/bin/sh -x
+#!/bin/sh
 
-# $Id: linker.sh,v 1.14 2010-07-29 04:34:10 rtoy Exp $
+# $Id: linker.sh,v 1.14.2.1 2010-09-09 00:16:20 rtoy Exp $
 
-# This file was written by Fred Gilham and is placed in the public domain.
-# It comes without warranty of any kind.
-
-if [ $# -ne 4 ]
-    then
-    echo "Usage: `basename $0` <c-compiler> <initial function address> <main> <executable file>"
-    exit 1
-fi
-
-CCOMPILER=$1
-shift;
-
-if [ $CCOMPILER = "cc" ]; then
-    # Sun C compiler
+# This file written by Raymond Toy as part of CMU Common Lisp and is
+# placed in the public domain.
+#
+# This script takes parameters specified by the running lisp to create
+# an executable image.
+#
+# Despite the name, it is used for Linux/x86, Darwin/x86, and
+# Solaris/sparc, as specified in src/lisp/elf.h.
 
-    # Can't set PATH because we don't really know where the compiler
-    # is.  The user has to have it in his path.
+OPSYS=`uname`
 
-    CC=`which cc`
-    if [ -z "$CC" ]; then
-	echo 'Cannot find Sun C.  Is it available and in $PATH?'
-	exit 1
-    fi
-    CRTPATH=`dirname $CC`/../prod
-    LIBROOT=$CRTPATH/lib
-
-else
-    # Gcc
-    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
-
-    # Uniform method for finding GCC C runtime object files suggested by Ray Toy
-    CRTPATH=`$GCC -print-libgcc-file-name`
-    LIBROOT=`dirname $CRTPATH`
+if [ "X$CMU_DEBUG_LINKER" != "X" ]; then
+    # Enable debugging if CMU_DEBUG_LINKER is defined and not empty.
+    set -x
 fi
 
-echo "LIBROOT is $LIBROOT"
+# There must be exactly 6 parameters:
+# - the name of the C compiler (sparc supports both Sun cc and GNU gcc).
+# - the address of the initial function (in C hex format)
+# - the path of the executable to be created
+# - the address of the start of the read-only space
+# - the address of the start of the static space
+# - the address of the start of the dynamic space
+if [ $# -ne 6 ]; then
+    echo "Usage: `basename $0` <c-compiler> <initial-func-addr> <executable> <ro-addr> <static-addr> <dyn-addr>"
+    exit 1
+fi
 
-OPSYS=`uname`
-VER=''
+CCOMPILER=$1
+IFADDR=$2
+EXEC=$3
 
-# Default values
-OUTDIR=`dirname $3`
-OUTNAME=`basename $3`
-OUTPUT="-o $OUTNAME"
-CURDIR=`pwd`
+# Figure out the directory and file name of the executable.
+OUTDIR=`dirname $EXEC`
+OUTNAME=`basename $EXEC`
 
-LINKER=/usr/bin/ld
+# This tells us where the cmu lisp executable is and also the
+# locations of lisp.a.
 CMUCLLIB=`dirname $0`
-OBJS="--whole-archive $CMUCLLIB/lisp.a --no-whole-archive"
-FLAGS='-export-dynamic'
 
-SCRIPT="-T $CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
+# Name of file where we write the actual initial function address.
+OPT_IFADDR="cmu-ifaddr-$$.c"
+# Names of the core sections from Lisp.
+OPT_CORE="CORRO.o CORSTA.o CORDYN.o"
+
+uname_s=`uname`
+case $uname_s in
+  Linux|FreeBSD)
+      # How to specify the starting address for each of the sections
+      # These aren't needed for Linux any more.  map_core_sections
+      # takes care of getting the addresses.
+
+      #RO_ADDR="-Wl,--section-start=CORRO=$4"
+      #STATIC_ADDR="-Wl,--section-start=CORSTA=$5"
+      #DYN_ADDR="-Wl,--section-start=CORDYN=$6"
+
+      #OPT_IF ADDR="-Wl,--defsym -Wl,initial_function_addr=$IFADDR"
+
+      # Specify how to link the entire lisp.a library
+      OPT_ARCHIVE="-Wl,--whole-archive -Wl,$CMUCLLIB/lisp.a -Wl,--no-whole-archive"
+
+      # Extra stuff.
+
+      OPT_EXTRA="-rdynamic"
+
+      # See Config.x86_${uname_s}
+      case $uname_s in
+	Linux) OS_LIBS=-ldl;;
+	FreeBSD) OS_LIBS=-lutil;;
+      esac
+      ;;
+  Darwin)
+      # How to specify the starting address for each of the sections.
+      # We don't actually need these because map_core_sections sets
+      # the addresses itself instead of from the segment address, but
+      # if we don't set them up correctly, vmmap complains when run on
+      # the resulting executable.  There's no harm in specifying them
+      # here, though; the addresses are ignored by map_core_sections.
+      RO_ADDR="-segaddr CORRO $4"
+      STATIC_ADDR="-segaddr CORSTA $5"
+      DYN_ADDR="-segaddr CORDYN $6"
+
+      # Specify how to link the entire lisp.a library
+      OPT_ARCHIVE="-all_load $CMUCLLIB/lisp.a"
+
+      # Extra stuff.  For some reason one __LINKEDIT segment is mapped
+      # just past the dynamic space.  This messes things up, so we move it
+      # to another address.  This seems to be free, at least on 10.5.
+
+      OPT_EXTRA="-segaddr __LINKEDIT 0x99000000 -rdynamic"
+      # See Config.x86_darwin
+      OS_LIBS=
+      ;;
+  SunOS)
+      # A quick test indicates that gcc will accept the following
+      # options too, so this will work whether we have Sun C or gcc.
+      # Note, that this probably only works if gcc uses Sun ld and not
+      # GNU ld.  Most (all?) prebuilt versions of gcc for Solaris use
+      # Sun ld.
+
+      # We don't need anything special to set the starting address.
+      # map_core_sections does that for us on sparc.
+
+      # Specify how to link the entire lisp.a library
+      OPT_ARCHIVE="-Xlinker -z -Xlinker allextract -Xlinker $CMUCLLIB/lisp.a -Xlinker -z -Xlinker defaultextract"
+
+      # Extra stuff.
+
+      OPT_EXTRA="-Bdynamic"
+
+      # See Config.sparc_sunc
+      OS_LIBS="-lsocket -lnsl -ldl"
+      ;;
 
-# This is a hack.
-# These are the default values.
-#
-# 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=$2"
-
-# IFADDR is the initial function address, needed to start lisp processing.
-IFADDR="--defsym initial_function_addr=$1"
-
-# Set OS-specific variables.
-case "$OPSYS" in
-    Linux )
-	# Handle x86_64 version system.  This should be revisited when there's a 64-bit version
-	# of CMUCL on Linux.  Note that -m32 won't work in older versions of GCC which we may
-	# still want to support.
-	ARCH=`uname -m`
-	if [ "$ARCH" = "x86_64" ]
-	then
-	    CRTPATH=`$GCC -m32 -print-libgcc-file-name`
-	    LIBROOT=`dirname $CRTPATH`
-	fi
-	STARTCRT="/usr/lib/crt1.o /usr/lib/crti.o $LIBROOT/crtbegin.o"
-	ENDCRT="$LIBROOT/crtend.o /usr/lib/crtn.o"
-	DLINKER='-dynamic-linker /lib/ld-linux.so.2'
-	LIBS="-L$LIBROOT -ldl -lm -lgcc -lc -lgcc"
-	;;
-    FreeBSD )
-	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'
-	;;
-    SunOS )
-	if [ $CCOMPILER = "cc" ]; then
-	    # These values were obtained by running cc -# hello.c and
-	    # looking at the linker command.
-	    STARTCRT="$LIBROOT/crti.o $LIBROOT/crt1.o $LIBROOT/misalign.o $LIBROOT/values-xa.o"
-	    ENDCRT="$LIBROOT/crtn.o"
-	    LIBS="-Y P,$LIBROOT/v8plus:$LIBROOT:/usr/ccs/lib:/lib:/usr/lib -Qy -lm -lc -lsocket -lnsl -ldl"
-	else
-	    STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
-	    ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
-	    LIBS="-L$LIBROOT -lm -lgcc -lc -lgcc -lsocket -lnsl -ldl"
-	fi
-	LINKER="/usr/ccs/bin/ld"
-	OBJS="-z allextract $CMUCLLIB/lisp.a CORRO.o CORSTA.o CORDYN.o -z defaultextract"
-	SCRIPT="$CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
-	# Don't need BIFLAG on Solaris.  The lisp.a archive has the
-	# correct value for it.
-	IFADDR=$1
-	sed -e "s;@IFADDR@;$IFADDR;" $SCRIPT > $OUTDIR/sunos-map-file
-	SCRIPT="-M sunos-map-file"
-	# Remove the sunos-map-file when the script exits.
-	trap 'rm -f $OUTDIR/sunos-map-file' 0
-	echo $PWD
-	FLAGS=
-	BIFLAG=
-	IFADDR=
-	;;
-    * )
-	echo "$0: unknown operating system $OPSYS."
-	exit 1
-	;;
 esac
 
-cd $OUTDIR
-$LINKER $SCRIPT $DLINKER $OUTPUT $STARTCRT $FLAGS $BIFLAG $IFADDR $OBJS $LIBS $ENDCRT
-cd $CURDIR
+# Remove the C file and core section files when we're done.
+trap 'rm -f $OUTDIR/$OPT_IFADDR $OUTDIR/CORRO.o $OUTDIR/CORSTA.o $OUTDIR/CORDYN.o' 0
+
+(cd $OUTDIR
+echo "long initial_function_addr = $IFADDR;" > $OPT_IFADDR
+$CCOMPILER -m32 -o $OUTNAME $OPT_IFADDR $OPT_ARCHIVE $OPT_CORE $RO_ADDR $STATIC_ADDR $DYN_ADDR $OPT_EXTRA $OS_LIBS -lm)
 
-exit 0
Index: src/tools/make-main-dist.sh
diff -u src/tools/make-main-dist.sh:1.25 src/tools/make-main-dist.sh:1.25.2.1
--- src/tools/make-main-dist.sh:1.25	Sun Aug  1 08:32:11 2010
+++ src/tools/make-main-dist.sh	Wed Sep  8 20:16:20 2010
@@ -97,7 +97,6 @@
 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/
     if [ -f src/tools/$SCRIPT-cmucl-linker-script ]; then
 	install ${GROUP} ${OWNER} -m 0755 src/tools/$SCRIPT-cmucl-linker-script $DESTDIR/lib/cmucl/lib/
     fi



More information about the cmucl-commit mailing list