Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running hello world.

2007-07-10 Thread Rob Landley
On Monday 02 July 2007 11:02:49 Alexander Graf wrote:
 Hi,

 this is the patch we are currently using to build qemu-0.9.0. Does this
 work for you?

 Alex

Let's see...

 -/* ld script to make i386 Linux kernel
 - * Written by Martin Mares [EMAIL PROTECTED];
 - */
 -OUTPUT_FORMAT(elf32-i386, elf32-i386, elf32-i386)
 +/* Default linker script, for normal executables */
 +OUTPUT_FORMAT(elf32-i386, elf32-i386,
 +         elf32-i386)

That's just a whitespace change and removal of credit.

 +SEARCH_DIR(/usr/i586-suse-linux/lib); SEARCH_DIR(/usr/local/lib);

I haven't got SuSE.

The next hunk is another huge multi-page whitespace change with code changes 
sprinkled in it.

I have no idea what this patch does, but the second hunk is suse-specific and 
the second half of it is for qemu-ppc which builds runs for me.  (Dunno if it 
_works_, but it's not segfaulting immediately when I run it...)

Rob
-- 
One of my most productive days was throwing away 1000 lines of code.
  - Ken Thompson.




Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running hello world.

2007-07-10 Thread Andreas Färber


Am 10.07.2007 um 17:47 schrieb Rob Landley:

I have no idea what this patch does, but the second hunk is suse- 
specific and
the second half of it is for qemu-ppc which builds runs for me.   
(Dunno if it

_works_, but it's not segfaulting immediately when I run it...)


ppc-softmmu does not build on OS X for me, there are two undefined  
symbol references, caused in some way by function aliasing. Would be  
nice if someone could fix that in CVS.


I got a number of error messages and an (emulated) crash when booting  
a Debian CD on both ppc and ppc64 so am unsure whether it's my  
quickfix (attached) or normal behavior. :-)


Andreas


ppc-2007-07-10.diff
Description: Binary data


Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running hello world.

2007-07-02 Thread Alexander Graf
Hi,

this is the patch we are currently using to build qemu-0.9.0. Does this
work for you?

Alex
--- i386.ld
+++ i386.ld
@@ -1,116 +1,164 @@
-/* ld script to make i386 Linux kernel
- * Written by Martin Mares [EMAIL PROTECTED];
- */
-OUTPUT_FORMAT(elf32-i386, elf32-i386, elf32-i386)
+/* Default linker script, for normal executables */
+OUTPUT_FORMAT(elf32-i386, elf32-i386,
+	  elf32-i386)
 OUTPUT_ARCH(i386)
-SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/alpha-unknown-linux-gnu/lib);
 ENTRY(_start)
+SEARCH_DIR(/usr/i586-suse-linux/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib);
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  . = 0x6000 + SIZEOF_HEADERS;
-  .interp : { *(.interp) 	}
-  .hash  : { *(.hash)		}
-  .dynsym: { *(.dynsym)		}
-  .dynstr: { *(.dynstr)		}
-  .gnu.version   : { *(.gnu.version)	}
-  .gnu.version_d   : { *(.gnu.version_d)	}
-  .gnu.version_r   : { *(.gnu.version_r)	}
-  .rel.text  :
-{ *(.rel.text) *(.rel.gnu.linkonce.t*) }
-  .rela.text :
-{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
-  .rel.data  :
-{ *(.rel.data) *(.rel.gnu.linkonce.d*) }
-  .rela.data :
-{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
-  .rel.rodata:
-{ *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
-  .rela.rodata   :
-{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
-  .rel.got   : { *(.rel.got)		}
-  .rela.got  : { *(.rela.got)		}
-  .rel.ctors : { *(.rel.ctors)	}
-  .rela.ctors: { *(.rela.ctors)	}
-  .rel.dtors : { *(.rel.dtors)	}
-  .rela.dtors: { *(.rela.dtors)	}
-  .rel.init  : { *(.rel.init)	}
-  .rela.init : { *(.rela.init)	}
-  .rel.fini  : { *(.rel.fini)	}
-  .rela.fini : { *(.rela.fini)	}
-  .rel.bss   : { *(.rel.bss)		}
-  .rela.bss  : { *(.rela.bss)		}
-  .rel.plt   : { *(.rel.plt)		}
-  .rela.plt  : { *(.rela.plt)		}
-  .init  : { *(.init)	} =0x47ff041f
-  .text  :
+  PROVIDE (__executable_start = 0x6000); . = 0x6000 + SIZEOF_HEADERS;
+  .interp : { *(.interp) }
+  .hash   : { *(.hash) }
+  .dynsym : { *(.dynsym) }
+  .dynstr : { *(.dynstr) }
+  .gnu.version: { *(.gnu.version) }
+  .gnu.version_d  : { *(.gnu.version_d) }
+  .gnu.version_r  : { *(.gnu.version_r) }
+  .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.ro   : { *(.rel.data.rel.ro*) }
+  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) }
+  .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   :
   {
-*(.text)
+KEEP (*(.init))
+  } =0x90909090
+  .plt: { *(.plt) }
+  .text   :
+  {
+*(.text .stub .text.* .gnu.linkonce.t.*)
+KEEP (*(.text.*personality*))
 /* .gnu.warning sections are handled specially by elf32.em.  */
 *(.gnu.warning)
-*(.gnu.linkonce.t*)
-  } =0x47ff041f
-  _etext = .;
+  } =0x90909090
+  .fini   :
+  {
+KEEP (*(.fini))
+  } =0x90909090
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
   PROVIDE (etext = .);
-  .fini  : { *(.fini)} =0x47ff041f
-  . = 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 = .);
-  .rodata: { *(.rodata) *(.gnu.linkonce.r*) }
-  .rodata1   : { *(.rodata1) }
-  .reginfo : { *(.reginfo) }
+  .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+  .rodata1: { *(.rodata1) }
+  .eh_frame_hdr : { *(.eh_frame_hdr) }

Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running hello world.

2007-06-23 Thread Stefan Weil
Rob Landley schrieb:
 Ok, it's a more fundamental problem:

 [EMAIL PROTECTED]:/sys$ qemu-i386
 Segmentation fault (core dumped)

 Nothing to do with the program it's trying to run, it segfaults with no
 arguments.

 Is anybody else seeing this?

 Rob
Yes, I see this on Debian Linux since several months (libc update?).

The crash is caused by libc startup code which calls a null pointer.
QEMU provides this null pointer with the __init_array_start
workaround in linux-user/main.c.

This can be fixed with some kind of code hack - see my patch
(which is not really a solution, but one more workaround).

Nevertheless user mode emulations remains unusable even
with this patch because of TLS problems.

Regards,
Stefan

Index: linux-user/main.c
===
RCS file: /sources/qemu/qemu/linux-user/main.c,v
retrieving revision 1.116
diff -u -b -B -r1.116 main.c
--- linux-user/main.c	21 Jun 2007 22:55:02 -	1.116
+++ linux-user/main.c	23 Jun 2007 11:03:42 -
@@ -45,12 +45,16 @@
 /* for recent libc, we add these dummy symbols which are not declared
when generating a linked object (bug in ld ?) */
 #if (__GLIBC__  2 || (__GLIBC__ == 2  __GLIBC_MINOR__ = 3))  !defined(CONFIG_STATIC)
-long __preinit_array_start[0];
-long __preinit_array_end[0];
-long __init_array_start[0];
-long __init_array_end[0];
-long __fini_array_start[0];
-long __fini_array_end[0];
+typedef void (*dummy_function_t)(void);
+static void dummy_function(void)
+{
+}
+dummy_function_t __preinit_array_start = dummy_function;
+dummy_function_t __preinit_array_end = dummy_function;
+dummy_function_t __init_array_start = dummy_function;
+dummy_function_t __init_array_end = dummy_function;
+dummy_function_t __fini_array_start = dummy_function;
+dummy_function_t __fini_array_end = dummy_function;
 #endif
 
 /* XXX: on x86 MAP_GROWSDOWN only works if ESP = address + 32, so