CMUCL commit: src (lisp/FreeBSD-os.c tools/FreeBSD-cmucl-linker-script)

Alex Goncharov agoncharov at common-lisp.net
Tue Sep 7 05:56:38 CEST 2010


    Date: Monday, September 6, 2010 @ 23:56:38
  Author: agoncharov
    Path: /project/cmucl/cvsroot/src

Modified: lisp/FreeBSD-os.c tools/FreeBSD-cmucl-linker-script

WIP: a run on EXECUTABLE for FreeBSD


-----------------------------------+
 lisp/FreeBSD-os.c                 |   11 +++--
 tools/FreeBSD-cmucl-linker-script |   79 +++++++++++++++---------------------
 2 files changed, 43 insertions(+), 47 deletions(-)


Index: src/lisp/FreeBSD-os.c
diff -u src/lisp/FreeBSD-os.c:1.34 src/lisp/FreeBSD-os.c:1.35
--- src/lisp/FreeBSD-os.c:1.34	Sun Jun 27 09:17:17 2010
+++ src/lisp/FreeBSD-os.c	Mon Sep  6 23:56:38 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.35 2010-09-07 03:56:38 agoncharov Exp $
  *
  */
 
@@ -307,6 +307,12 @@
 void *
 os_dlsym(const char *sym_name, lispobj lib_list)
 {
+    static void *program_handle;
+    void *sym_addr = 0;
+
+    if (!program_handle)
+	program_handle = dlopen((void *) 0, RTLD_LAZY | RTLD_GLOBAL);
+
     if (lib_list != NIL) {
 	lispobj lib_list_head;
 
@@ -320,8 +326,7 @@
 		return sym_addr;
 	}
     }
-
-    return dlsym(RTLD_DEFAULT, sym_name);
+    return dlsym(program_handle, sym_name);
 }
 
 void
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/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) }
 }



More information about the cmucl-commit mailing list