CMUCL commit: src (3 files)

Raymond Toy rtoy at common-lisp.net
Tue Jul 27 04:35:26 CEST 2010


    Date: Monday, July 26, 2010 @ 22:35:26
  Author: rtoy
    Path: /project/cmucl/cvsroot/src

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

lisp/elf.c:
o Print out the size of Elf_Ehdr and Elf32_Phdr, for debugging.
o Pass the address of main to the linker script.  We will use the
  first word of main as the address of builtin_image_flag.  It seems
  highly unlikely that this would have have the value 0.

tools/Linux-cmucl-linker-script:
o Hardwire the value of SIZEOF_HEADERS.  This is needed on Debian to
  get the right number of segments.
o Comment out some items and/or fix them so that Debian's linker
  doesn't complain.  Doesn't appear to do any harm on openSuSE 11.2.

tools/linker.sh:
o Update for the additional argument for the address of main to use as
  the address of builtin_image_flag.


---------------------------------+
 lisp/elf.c                      |   11 ++++++++---
 tools/Linux-cmucl-linker-script |   17 ++++++++++++-----
 tools/linker.sh                 |   12 ++++++------
 3 files changed, 26 insertions(+), 14 deletions(-)


Index: src/lisp/elf.c
diff -u src/lisp/elf.c:1.19 src/lisp/elf.c:1.20
--- src/lisp/elf.c:1.19	Mon Jul 13 15:41:54 2009
+++ src/lisp/elf.c	Mon Jul 26 22:35:25 2010
@@ -8,7 +8,7 @@
 
  Above changes put into main CVS branch. 05-Jul-2007.
 
- $Id: elf.c,v 1.19 2009-07-13 19:41:54 rtoy Rel $
+ $Id: elf.c,v 1.20 2010-07-27 02:35:25 rtoy Exp $
 */
 
 #include <stdio.h>
@@ -286,6 +286,9 @@
     size_t length = end - start + (os_vm_page_size -
 				   ((end - start) % os_vm_page_size));
 
+    fprintf(stderr, "sizeof Elf_Ehdr = %d\n", sizeof(Elf_Ehdr));
+    fprintf(stderr, "sizeof Elf32_Phdr = %d\n", sizeof(Elf32_Phdr));
+    
     if(id < 1 || id > 3) {
 	fprintf(stderr, "Invalid space id in %s: %d\n", __func__, id);
 	fprintf(stderr, "Executable not built.\n");
@@ -371,11 +374,13 @@
         }
         
 	if(stat(command, &st) == 0) {
+            extern int main();
+            
 	    free(paths);
 	    printf("\t[%s: linking %s... \n", command, file);
 	    fflush(stdout);
-	    sprintf(command_line, "%s %s 0x%lx %s", command, C_COMPILER,
-                    init_func_address, file);
+	    sprintf(command_line, "%s %s 0x%lx 0x%lx %s", command, C_COMPILER,
+                    init_func_address, (unsigned long) &main, file);
 	    ret = system(command_line);
 	    if(ret == -1) {
 		perror("Can't run link script");
Index: src/tools/Linux-cmucl-linker-script
diff -u src/tools/Linux-cmucl-linker-script:1.2 src/tools/Linux-cmucl-linker-script:1.3
--- src/tools/Linux-cmucl-linker-script:1.2	Mon Jul 26 11:58:48 2010
+++ src/tools/Linux-cmucl-linker-script	Mon Jul 26 22:35:26 2010
@@ -1,5 +1,5 @@
 /* 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
+ * 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) }
@@ -22,7 +22,11 @@
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + SIZEOF_HEADERS;
+  /* 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) }
@@ -77,10 +81,13 @@
   .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));
+  /*. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));*/
+  . = DATA_SEGMENT_ALIGN(0x1000, 0x1000);
   /* Exception handling  */
-  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
-  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
+  /* 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) }
Index: src/tools/linker.sh
diff -u src/tools/linker.sh:1.9 src/tools/linker.sh:1.10
--- src/tools/linker.sh:1.9	Mon Jul 26 15:07:56 2010
+++ src/tools/linker.sh	Mon Jul 26 22:35:26 2010
@@ -1,13 +1,13 @@
 #!/bin/sh -x
 
-# $Id: linker.sh,v 1.9 2010-07-26 19:07:56 rtoy Exp $
+# $Id: linker.sh,v 1.10 2010-07-27 02:35:26 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 3 ]
+if [ $# -ne 4 ]
     then
-    echo "Usage: `basename $0` <c-compiler> <initial function address> <executable file>"
+    echo "Usage: `basename $0` <c-compiler> <initial function address> <main> <executable file>"
     exit 1
 fi
 
@@ -50,8 +50,8 @@
 VER=''
 
 # Default values
-OUTPUT="-o $2"
-OUTDIR=`dirname $2`
+OUTPUT="-o $3"
+OUTDIR=`dirname $3`
 CURDIR=`pwd`
 
 LINKER=/usr/bin/ld
@@ -71,7 +71,7 @@
 
 # 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=$2"
 
 # IFADDR is the initial function address, needed to start lisp processing.
 IFADDR="--defsym initial_function_addr=$1"



More information about the cmucl-commit mailing list