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

Raymond Toy rtoy at common-lisp.net
Mon Jul 26 17:58:48 CEST 2010


    Date: Monday, July 26, 2010 @ 11:58:48
  Author: rtoy
    Path: /project/cmucl/cvsroot/src

Modified: lisp/lisp.c tools/Linux-cmucl-linker-script

Make executables work again on Linux.  (At least on openSuSE 11.2).

lisp/lisp.c:
o Apparently tzset can call malloc on openSuSE 11.2.  This messes up
  mapping the dynamic space on executables because the heap appears to
  be allocated at the same place as the dynamic space.  Move tzset to
  the very end, after the Lisp spaces have been mapped.

tools/Linux-cmucl-linker-script:
o Update the linker script from the default version on openSuSE 11.2.


---------------------------------+
 lisp/lisp.c                     |   14 ++
 tools/Linux-cmucl-linker-script |  183 +++++++++++++++++---------------------
 2 files changed, 97 insertions(+), 100 deletions(-)


Index: src/lisp/lisp.c
diff -u src/lisp/lisp.c:1.70 src/lisp/lisp.c:1.71
--- src/lisp/lisp.c:1.70	Mon Feb  1 10:16:09 2010
+++ src/lisp/lisp.c	Mon Jul 26 11:58:47 2010
@@ -1,7 +1,7 @@
 /*
  * main() entry point for a stand alone lisp image.
  *
- * $Header: /project/cmucl/cvsroot/src/lisp/lisp.c,v 1.70 2010-02-01 15:16:09 rtoy Exp $
+ * $Header: /project/cmucl/cvsroot/src/lisp/lisp.c,v 1.71 2010-07-26 15:58:47 rtoy Exp $
  *
  */
 
@@ -439,7 +439,7 @@
     if (builtin_image_flag != 0)
 	initial_function = (lispobj) & initial_function_addr;
 
-#if defined(SVR4) || defined(__linux__)
+#if defined(SVR4)
     tzset();
 #endif
 
@@ -782,6 +782,16 @@
      */
     verify_gc();
 #endif
+
+#if defined(__linux__)
+    /*
+     * On newer (?) versions of Linux, tzset appears to call malloc.
+     * We set up the timezone here so that malloc happens as late as
+     * possible.
+     */
+    tzset();
+#endif
+    
     if (monitor) {
 	while (1) {
 	    ldb_monitor();
Index: src/tools/Linux-cmucl-linker-script
diff -u src/tools/Linux-cmucl-linker-script:1.1 src/tools/Linux-cmucl-linker-script:1.2
--- src/tools/Linux-cmucl-linker-script:1.1	Thu Jul 12 00:44:38 2007
+++ src/tools/Linux-cmucl-linker-script	Mon Jul 26 11:58:48 2010
@@ -1,35 +1,32 @@
-/* Default linker script, for normal executables */
+/* For the record, this is the default linker script from openSUSE
+ * 11.2 version 2.19.51.20090527-10.26.4, obtained via ldd --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)
 
-PHDRS
-{
-	headers PT_PHDR PHDRS ;
-	interp  PT_INTERP ;
-	text    PT_LOAD FILEHDR PHDRS ;
-	data    PT_LOAD ;
-	dynamic PT_DYNAMIC ;
-
-	CORRO   PT_NOTE ;
-	CORSTA  PT_NOTE ;
-        CORDYN  PT_NOTE ;
-
-        note    PT_NOTE ;
-}
-
-
 SEARCH_DIR("/usr/local/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
+  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + SIZEOF_HEADERS;
+  .interp         : { *(.interp) }
+  .note.gnu.build-id : { *(.note.gnu.build-id) }
+  .hash           : { *(.hash) }
+  .gnu.hash       : { *(.gnu.hash) }
   .dynsym         : { *(.dynsym) }
   .dynstr         : { *(.dynstr) }
   .gnu.version    : { *(.gnu.version) }
@@ -41,6 +38,7 @@
       *(.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.*)
@@ -48,45 +46,12 @@
       *(.rel.dtors)
       *(.rel.got)
       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
-    } :text
-  .rela.dyn       :
+    }
+  .rel.ifunc.dyn        :
     {
-      *(.rela.init)
-      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
-      *(.rela.fini)
-      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
-      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
-      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
-      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
-      *(.rela.ctors)
-      *(.rela.dtors)
-      *(.rela.got)
-      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+      *(.rel.ifunc.*)
     }
-  .rel.init       : { *(.rel.init) }
-  .rela.init      : { *(.rela.init) }
-  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
-  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
-  .rel.fini       : { *(.rel.fini) }
-  .rela.fini      : { *(.rela.fini) }
-  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
-  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
-  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
-  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
-  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
-  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
-  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
-  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
-  .rel.ctors      : { *(.rel.ctors) }
-  .rela.ctors     : { *(.rela.ctors) }
-  .rel.dtors      : { *(.rel.dtors) }
-  .rela.dtors     : { *(.rela.dtors) }
-  .rel.got        : { *(.rel.got) }
-  .rela.got       : { *(.rela.got) }
-  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
-  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
   .rel.plt        : { *(.rel.plt) }
-  .rela.plt       : { *(.rela.plt) }
   .init           :
   {
     KEEP (*(.init))
@@ -107,35 +72,38 @@
   PROVIDE (etext = .);
   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
   .rodata1        : { *(.rodata1) }
-  .eh_frame_hdr : { *(.eh_frame_hdr) } :data
+  .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.  */
-  . = 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
-     be empty, which isn't pretty.  */
-  . = ALIGN(32 / 8);
-  PROVIDE (__preinit_array_start = .);
-  .preinit_array     : { *(.preinit_array) }
-  PROVIDE (__preinit_array_end = .);
-  PROVIDE (__init_array_start = .);
-  .init_array     : { *(.init_array) }
-  PROVIDE (__init_array_end = .);
-  PROVIDE (__fini_array_start = .);
-  .fini_array     : { *(.fini_array) }
-  PROVIDE (__fini_array_end = .);
-  .data           :
-  {
-    *(.data .data.* .gnu.linkonce.d.*)
-    SORT(CONSTRUCTORS)
-  }
-  .data1          : { *(.data1) }
+  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+  /* Exception handling  */
+  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
+  /* Thread Local Storage sections  */
   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
-  .eh_frame       : { KEEP (*(.eh_frame)) }
-  .gcc_except_table   : { *(.gcc_except_table) }
-  .dynamic        : { *(.dynamic) } :data :dynamic
+  .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
@@ -148,25 +116,36 @@
        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 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 *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 *crtend?.o ) .dtors))
     KEEP (*(SORT(.dtors.*)))
     KEEP (*(.dtors))
   }
   .jcr            : { KEEP (*(.jcr)) }
-  .got            : { *(.got.plt) *(.got) }
-  _edata = .;
-  PROVIDE (edata = .);
+  .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            :
   {
@@ -175,17 +154,19 @@
    *(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.  */
-   . = ALIGN(32 / 8);
+      .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);
-  _end = .;
-  PROVIDE (end = .);
+  . = ALIGN(32 / 8);
+  _end = .; PROVIDE (end = .);
   . = DATA_SEGMENT_END (.);
 
-  CORRO  0x10000000 : { CORRO.o  *(CORRO)  } :CORRO
-  CORSTA 0x28000000 : { CORSTA.o *(CORSTA) } :CORSTA
-  CORDYN 0x58100000 : { CORDYN.o *(CORDYN) } :CORDYN
+  CORRO  0x10000000 : { CORRO.o  *(CORRO)  }
+  CORSTA 0x28000000 : { CORSTA.o *(CORSTA) }
+  CORDYN 0x58100000 : { CORDYN.o *(CORDYN) }
 
   /* Stabs debugging sections.  */
   .stab          0 : { *(.stab) }
@@ -220,4 +201,10 @@
   .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_*) }
+
 }



More information about the cmucl-commit mailing list