All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] qemu-i386 segfaults running "hello world".
@ 2007-06-22 21:15 Rob Landley
  2007-06-22 22:31 ` Rob Landley
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-06-22 21:15 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

Problem: 
landley@triolith:~/firmware/firmware$ build/temp-i686/hello
Hello world!
landley@triolith:~/firmware/firmware$ qemu-i386 build/temp-i686/hello
Segmentation fault (core dumped)

This is on a cvs snapshot from 15 minutes ago.  The hello world is a 
statically linked executable built against uClibc 0.9.29.  It runs fine from 
the command line, but qemu application emulation goes "boing".

The executable is attached.

Am I doing something wrong?

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

[-- Attachment #2: hello --]
[-- Type: application/x-executable, Size: 13994 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 21:15 [Qemu-devel] qemu-i386 segfaults running "hello world" Rob Landley
@ 2007-06-22 22:31 ` Rob Landley
  2007-06-22 23:13   ` Alexander Graf
                     ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Rob Landley @ 2007-06-22 22:31 UTC (permalink / raw)
  To: qemu-devel

Ok, it's a more fundamental problem:

landley@triolith:/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
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 22:31 ` Rob Landley
@ 2007-06-22 23:13   ` Alexander Graf
  2007-06-22 23:27     ` andrzej zaborowski
  2007-06-23  5:31     ` Rob Landley
  2007-06-23  7:41   ` Rob Landley
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 18+ messages in thread
From: Alexander Graf @ 2007-06-22 23:13 UTC (permalink / raw)
  To: qemu-devel

Rob Landley wrote:
> Ok, it's a more fundamental problem:
>
> landley@triolith:/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
>   
agraf@mac:/vm/qemu-devel/patches/qemu> qemu-i386 ~/hello
Hello world!

Well it works for me. I usually see this segfault when trying to compile
qemu with a gcc4. Try gcc3 and everything should be fine.

Alex

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 23:13   ` Alexander Graf
@ 2007-06-22 23:27     ` andrzej zaborowski
  2007-06-23  6:38       ` Rob Landley
  2007-06-23  5:31     ` Rob Landley
  1 sibling, 1 reply; 18+ messages in thread
From: andrzej zaborowski @ 2007-06-22 23:27 UTC (permalink / raw)
  To: qemu-devel

On 23/06/07, Alexander Graf <agraf@suse.de> wrote:
> Rob Landley wrote:
> > Ok, it's a more fundamental problem:
> >
> > landley@triolith:/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
> >
> agraf@mac:/vm/qemu-devel/patches/qemu> qemu-i386 ~/hello
> Hello world!
>
> Well it works for me. I usually see this segfault when trying to compile
> qemu with a gcc4. Try gcc3 and everything should be fine.

I usually see this when I forget to rebuild all files affected by a
recent change (because the Makefile doesn't make the .depend before
you tell it to).

Regards

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 23:13   ` Alexander Graf
  2007-06-22 23:27     ` andrzej zaborowski
@ 2007-06-23  5:31     ` Rob Landley
  2007-06-23  7:27       ` Alexander Graf
  1 sibling, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-06-23  5:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf

On Friday 22 June 2007 19:13:19 Alexander Graf wrote:
> Rob Landley wrote:
> > Ok, it's a more fundamental problem:
> >
> > landley@triolith:/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
>
> agraf@mac:/vm/qemu-devel/patches/qemu> qemu-i386 ~/hello
> Hello world!
>
> Well it works for me. I usually see this segfault when trying to compile
> qemu with a gcc4. Try gcc3 and everything should be fine.

It's using gcc-3.4.  The one that comes with Ubuntu 7.04.  (Or at 
least ./configure said it had found gcc-3.4 during configuration, anyway.)

I ran the sucker under strace and it seems to be segfaulting right before it 
calls main().  I stuck an exit(1) at the start of main and it doesn't get to 
it, but it's after all the shared libraries are loaded:

> mprotect(0xb7f3f000, 4096, PROT_READ)   = 0
> mprotect(0x80000000, 548864, PROT_READ|PROT_WRITE) = 0
> mprotect(0x80000000, 548864, PROT_READ|PROT_EXEC) = 0
> munmap(0xb7f76000, 57255)               = 0
> set_tid_address(0xb7deca88)             = 4338
> sendto(-1210135920, umovestr: Input/output error
> 0xc, 3084914676,
> MSG_DONTWAIT|MSG_CONFIRM|MSG_FIN|MSG_NOSIGNAL|MSG_MORE|0xb7de0000,
> {sa_family=AF_DECnet, sa_data="\0\0\320=\0\0\r\0\0\0p\362\0\0"},
> 3217384328) = 0 rt_sigaction(SIGRTMIN, {0xb7df13f0, [], SA_SIGINFO}, NULL,
> 8) = 0
> rt_sigaction(SIGRT_1, {0xb7df1300, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
> rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
> getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
> uname({sys="Linux", node="triolith", ...}) = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV (core dumped) +++
> Process 4338 detached

If I link "int main() {}" against -lm and -lrt I get the same set of calls up 
through the first mprotect.  (The next two mprotects are probably setting up 
other segments like bss that an empty program doesn't have.)  Then everything 
up through the uname() is the same...  And then it would call "main".

Right now I'm commenting out various global variable initializations because 
that's what comes to mind as "stuff that runs right before main()".

By the way, by commenting out this bit:

//const char interp[] __attribute__((section(".interp"))) 
= "/lib/ld-linux.so.2";

I made it go from "segmentation fault" to "illegal instruction" as the reason 
it dies.  Which is weird because there's no non-x86 toolchain the path, this 
is all stock Ubuntu stuff.  But oh well...

> Alex

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 23:27     ` andrzej zaborowski
@ 2007-06-23  6:38       ` Rob Landley
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Landley @ 2007-06-23  6:38 UTC (permalink / raw)
  To: qemu-devel

On Friday 22 June 2007 19:27:18 andrzej zaborowski wrote:
> > Well it works for me. I usually see this segfault when trying to compile
> > qemu with a gcc4. Try gcc3 and everything should be fine.
>
> I usually see this when I forget to rebuild all files affected by a
> recent change (because the Makefile doesn't make the .depend before
> you tell it to).

I did an rm -rf of the directory and re-downloaded it out from CVS when I 
first encountered this.  Didn't fix it.  I just did a "make distclean" and 
rebuilt again: same problem.

> Regards

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-23  5:31     ` Rob Landley
@ 2007-06-23  7:27       ` Alexander Graf
  2007-06-24  5:40         ` Rob Landley
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Graf @ 2007-06-23  7:27 UTC (permalink / raw)
  To: qemu-devel


On Jun 23, 2007, at 7:31 AM, Rob Landley wrote:

> On Friday 22 June 2007 19:13:19 Alexander Graf wrote:
>> Rob Landley wrote:
>>> Ok, it's a more fundamental problem:
>>>
>>> landley@triolith:/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
>>
>> agraf@mac:/vm/qemu-devel/patches/qemu> qemu-i386 ~/hello
>> Hello world!
>>
>> Well it works for me. I usually see this segfault when trying to  
>> compile
>> qemu with a gcc4. Try gcc3 and everything should be fine.
>
> It's using gcc-3.4.  The one that comes with Ubuntu 7.04.  (Or at
> least ./configure said it had found gcc-3.4 during configuration,  
> anyway.)
>
> I ran the sucker under strace and it seems to be segfaulting right  
> before it
> calls main().  I stuck an exit(1) at the start of main and it  
> doesn't get to
> it, but it's after all the shared libraries are loaded:
>
>> mprotect(0xb7f3f000, 4096, PROT_READ)   = 0
>> mprotect(0x80000000, 548864, PROT_READ|PROT_WRITE) = 0
>> mprotect(0x80000000, 548864, PROT_READ|PROT_EXEC) = 0
>> munmap(0xb7f76000, 57255)               = 0
>> set_tid_address(0xb7deca88)             = 4338
>> sendto(-1210135920, umovestr: Input/output error
>> 0xc, 3084914676,
>> MSG_DONTWAIT|MSG_CONFIRM|MSG_FIN|MSG_NOSIGNAL|MSG_MORE|0xb7de0000,
>> {sa_family=AF_DECnet, sa_data="\0\0\320=\0\0\r\0\0\0p\362\0\0"},
>> 3217384328) = 0 rt_sigaction(SIGRTMIN, {0xb7df13f0, [],  
>> SA_SIGINFO}, NULL,
>> 8) = 0
>> rt_sigaction(SIGRT_1, {0xb7df1300, [], SA_RESTART|SA_SIGINFO},  
>> NULL, 8) = 0
>> rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
>> getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024,  
>> rlim_max=RLIM_INFINITY}) = 0
>> uname({sys="Linux", node="triolith", ...}) = 0
>> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
>> +++ killed by SIGSEGV (core dumped) +++
>> Process 4338 detached
>
> If I link "int main() {}" against -lm and -lrt I get the same set  
> of calls up
> through the first mprotect.  (The next two mprotects are probably  
> setting up
> other segments like bss that an empty program doesn't have.)  Then  
> everything
> up through the uname() is the same...  And then it would call "main".
>
> Right now I'm commenting out various global variable  
> initializations because
> that's what comes to mind as "stuff that runs right before main()".
>
> By the way, by commenting out this bit:
>
> //const char interp[] __attribute__((section(".interp")))
> = "/lib/ld-linux.so.2";
>
> I made it go from "segmentation fault" to "illegal instruction" as  
> the reason
> it dies.  Which is weird because there's no non-x86 toolchain the  
> path, this
> is all stock Ubuntu stuff.  But oh well...
>
>> Alex
>
> Rob
> -- 
> "One of my most productive days was throwing away 1000 lines of code."
>   - Ken Thompson.
>
>

I guess you're running on i586 then? I only tried this on ppc.
Last time I checked the code-copy stuff was broken, so maybe it helps  
to disable that?

If that doesn't work either - would you mind to gdb it and run a "bt"  
when it segfaulted so we can see if the segfault is in the generated  
code?

Alex

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 22:31 ` Rob Landley
  2007-06-22 23:13   ` Alexander Graf
@ 2007-06-23  7:41   ` Rob Landley
  2007-06-23 11:00     ` Jens Axboe
  2007-06-23  9:50   ` Nigel Horne
  2007-06-23 11:12   ` [Qemu-devel] [PATCH] " Stefan Weil
  3 siblings, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-06-23  7:41 UTC (permalink / raw)
  To: qemu-devel

On Friday 22 June 2007 18:31:20 Rob Landley wrote:
> Ok, it's a more fundamental problem:
>
> landley@triolith:/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

So I'm vaguely suspecting that some of the dynamic linker magic this thing's 
doing is contributing to the screw up (or at least the complexity of 
debugging it), so I thought I'd statically link.

If I ./configure --static the result doesn't build, it dies during linking.  
Is this expected?  (Do I need to install .a versions of all the alsa and x11 
libraries to make that work?)

I realize releases are a bit out of fashion, but is there any way to go 
through cvs to track down which checkin broke this stuff?  I can do it in 
git, mercurial, or subversion.  But cvs isn't really set up for this sort of 
thing...

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-22 22:31 ` Rob Landley
  2007-06-22 23:13   ` Alexander Graf
  2007-06-23  7:41   ` Rob Landley
@ 2007-06-23  9:50   ` Nigel Horne
  2007-06-23 11:12   ` [Qemu-devel] [PATCH] " Stefan Weil
  3 siblings, 0 replies; 18+ messages in thread
From: Nigel Horne @ 2007-06-23  9:50 UTC (permalink / raw)
  To: qemu-devel

Rob Landley wrote:
> Ok, it's a more fundamental problem:
>
> landley@triolith:/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?
>   
Yes, I get it.
> Rob
>   
-Nigel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-23  7:41   ` Rob Landley
@ 2007-06-23 11:00     ` Jens Axboe
  2007-06-24  7:01       ` Rob Landley
  0 siblings, 1 reply; 18+ messages in thread
From: Jens Axboe @ 2007-06-23 11:00 UTC (permalink / raw)
  To: qemu-devel

On Sat, Jun 23 2007, Rob Landley wrote:
> On Friday 22 June 2007 18:31:20 Rob Landley wrote:
> > Ok, it's a more fundamental problem:
> >
> > landley@triolith:/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
> 
> So I'm vaguely suspecting that some of the dynamic linker magic this thing's 
> doing is contributing to the screw up (or at least the complexity of 
> debugging it), so I thought I'd statically link.
> 
> If I ./configure --static the result doesn't build, it dies during linking.  
> Is this expected?  (Do I need to install .a versions of all the alsa and x11 
> libraries to make that work?)
> 
> I realize releases are a bit out of fashion, but is there any way to go 
> through cvs to track down which checkin broke this stuff?  I can do it in 
> git, mercurial, or subversion.  But cvs isn't really set up for this sort of 
> thing...

git clone git://git.kernel.dk/data/git/qemu.git

and bisect on that then. It's a continued git import of the cvs repo,
gets updated every night.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running "hello world".
  2007-06-22 22:31 ` Rob Landley
                     ` (2 preceding siblings ...)
  2007-06-23  9:50   ` Nigel Horne
@ 2007-06-23 11:12   ` Stefan Weil
  2007-06-24  7:36     ` Rob Landley
  3 siblings, 1 reply; 18+ messages in thread
From: Stefan Weil @ 2007-06-23 11:12 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Rob Landley schrieb:
> Ok, it's a more fundamental problem:
>
> landley@triolith:/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


[-- Attachment #2: main.patch --]
[-- Type: text/x-diff, Size: 1200 bytes --]

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 -0000	1.116
+++ linux-user/main.c	23 Jun 2007 11:03:42 -0000
@@ -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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-23  7:27       ` Alexander Graf
@ 2007-06-24  5:40         ` Rob Landley
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Landley @ 2007-06-24  5:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf

On Saturday 23 June 2007 03:27:03 Alexander Graf wrote:

> I guess you're running on i586 then?

Athlon.  (/proc/cpuinfo says "AMD Sempron(tm)   2200+")

> I only tried this on ppc. 
> Last time I checked the code-copy stuff was broken, so maybe it helps
> to disable that?

What code-copy stuff?  (How do I disable that?)

> If that doesn't work either - would you mind to gdb it and run a "bt"
> when it segfaulted so we can see if the segfault is in the generated
> code?

Sure... except it has no debugging symbols so the backtrace is just numbers 
and an occasional library name. How about...  Huh, ./configure --help doesn't 
show any sort of --enable-debug...  Trying "./configure --extra-cflags=-g"... 
Nope, that stripped it too.  Ok, grep for "strip" and it shows up in multiple 
places.  It's in ./configure but I can't seem to tell configure not to do it. 
Maybe "make STRIP=echo" would work?  Nope...

Grrr:
  make clean
  mkdir sub
  ln /bin/echo sub/strip
  PATH=`pwd`/sub:$PATH make

Ok, that didn't do it either.

Would somebody like to clue me in on how to get this darn thing to build a 
version with debugging symbols, please?

In the meantime:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x800773a9 in ?? ()
#2  0x00000001 in ?? ()
#3  0xbff09304 in ?? ()
#4  0xbff0930c in ?? ()
#5  0xb7f75ff4 in ?? ()
#6  0xb7fc77b0 in ?? () from /lib/ld-linux.so.2
#7  0x80077350 in ?? ()
#8  0xffffffee in ?? ()
#9  0xb7f75ff4 in ?? ()
#10 0xb7fd3ce0 in ?? () from /lib/ld-linux.so.2
#11 0x80077350 in ?? ()
#12 0xbff092d8 in ?? ()
#13 0xb7e4ee61 in ?? ()
#14 0x00000001 in ?? ()
#15 0xbff09304 in ?? ()
#16 0xbff0930c in ?? ()
#17 0xb7fbbdcb in ?? () from /lib/ld-linux.so.2
#18 0x00000000 in ?? ()

Kind of useless...

> Alex

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-23 11:00     ` Jens Axboe
@ 2007-06-24  7:01       ` Rob Landley
  2007-06-26 13:05         ` Jens Axboe
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-06-24  7:01 UTC (permalink / raw)
  To: qemu-devel

On Saturday 23 June 2007 07:00:03 Jens Axboe wrote:
> > I realize releases are a bit out of fashion, but is there any way to go
> > through cvs to track down which checkin broke this stuff?  I can do it in
> > git, mercurial, or subversion.  But cvs isn't really set up for this sort
> > of thing...
>
> git clone git://git.kernel.dk/data/git/qemu.git
>
> and bisect on that then. It's a continued git import of the cvs repo,
> gets updated every night.

Oh _cool_.  Any way to get a mention of that on the qemu web page?

Thanks,

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running "hello world".
  2007-06-23 11:12   ` [Qemu-devel] [PATCH] " Stefan Weil
@ 2007-06-24  7:36     ` Rob Landley
  2007-07-02 15:02       ` Alexander Graf
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-06-24  7:36 UTC (permalink / raw)
  To: qemu-devel

On Saturday 23 June 2007 07:12:39 Stefan Weil wrote:
> Rob Landley schrieb:
> > Ok, it's a more fundamental problem:
> >
> > landley@triolith:/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?).

Ubuntu 7.04 is using glibc-2.5.

> 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.

What exactly is this working around, anyway?  There are comments in the code 
that it's doing something fancy (being both a shared library and an 
executable, I think) but I'm not sure why...

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

I applied your patch and still got the segfault.

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

That I know how to work around.  Set the environment variable 
LD_ASSUME_KERNEL=2.4.1 and glibc won't try to use TLS.

> Regards,
> Stefan

Rob

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
  2007-06-24  7:01       ` Rob Landley
@ 2007-06-26 13:05         ` Jens Axboe
  0 siblings, 0 replies; 18+ messages in thread
From: Jens Axboe @ 2007-06-26 13:05 UTC (permalink / raw)
  To: Rob Landley; +Cc: qemu-devel

On Sun, Jun 24 2007, Rob Landley wrote:
> On Saturday 23 June 2007 07:00:03 Jens Axboe wrote:
> > > I realize releases are a bit out of fashion, but is there any way to go
> > > through cvs to track down which checkin broke this stuff?  I can do it in
> > > git, mercurial, or subversion.  But cvs isn't really set up for this sort
> > > of thing...
> >
> > git clone git://git.kernel.dk/data/git/qemu.git
> >
> > and bisect on that then. It's a continued git import of the cvs repo,
> > gets updated every night.
> 
> Oh _cool_.  Any way to get a mention of that on the qemu web page?

I don't mind, it's already mentioned on some japanese qemu-win page for
quite some time.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running "hello world".
  2007-06-24  7:36     ` Rob Landley
@ 2007-07-02 15:02       ` Alexander Graf
  2007-07-10 15:47         ` Rob Landley
  0 siblings, 1 reply; 18+ messages in thread
From: Alexander Graf @ 2007-07-02 15:02 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

Hi,

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

Alex

[-- Attachment #2: linkerscripts.patch --]
[-- Type: text/x-patch, Size: 21537 bytes --]

--- i386.ld
+++ i386.ld
@@ -1,116 +1,164 @@
-/* ld script to make i386 Linux kernel
- * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
- */
-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: */
-  . = 0x60000000 + 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 = 0x60000000); . = 0x60000000 + 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) }
+  .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(0x100000) + (. & (0x100000 - 1));
-  .data    :
+  . = ALIGN (0x1000) - ((0x1000 - .) & (0x1000 - 1)); . = 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.*) }
+  /* 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 (*(.init_array))
+     PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array     :
+  {
+    PROVIDE_HIDDEN (__fini_array_start = .);
+    KEEP (*(.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))
+    /* 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 (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+  .jcr            : { KEEP (*(.jcr)) }
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
+  .dynamic        : { *(.dynamic) }
+  .got            : { *(.got) }
+  . = DATA_SEGMENT_RELRO_END (12, .);
+  .got.plt        : { *(.got.plt) }
+  .data           :
   {
-    *(.data)
-    *(.gnu.linkonce.d*)
-    CONSTRUCTORS
-  }
-  .data1   : { *(.data1) }
-  .ctors         :
-  {
-    *(.ctors)
-  }
-  .dtors         :
-  {
-    *(.dtors)
-  }
-  .plt      : { *(.plt)	}
-  .got           : { *(.got.plt) *(.got) }
-  .dynamic       : { *(.dynamic) }
-  /* We want the small data sections together, so single-instruction offsets
-     can access them all, and initialized data all before uninitialized, so
-     we can shorten the on-disk segment size.  */
-  .sdata     : { *(.sdata) }
-  _edata  =  .;
-  PROVIDE (edata = .);
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  }
+  .data1          : { *(.data1) }
+  _edata = .; PROVIDE (edata = .);
   __bss_start = .;
-  .sbss      : { *(.sbss) *(.scommon) }
-  .bss       :
+  .bss            :
   {
    *(.dynbss)
-   *(.bss)
+   *(.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);
   }
-  _end = . ;
+  . = ALIGN(32 / 8);
+  . = ALIGN(32 / 8);
+  _end = .;
   PROVIDE (end = .);
+  . = DATA_SEGMENT_END (.);
   /* 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          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) }
+  .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.  */
@@ -124,7 +172,7 @@
   .debug_aranges  0 : { *(.debug_aranges) }
   .debug_pubnames 0 : { *(.debug_pubnames) }
   /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info) }
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
   .debug_abbrev   0 : { *(.debug_abbrev) }
   .debug_line     0 : { *(.debug_line) }
   .debug_frame    0 : { *(.debug_frame) }
@@ -136,5 +184,5 @@
   .debug_funcnames 0 : { *(.debug_funcnames) }
   .debug_typenames 0 : { *(.debug_typenames) }
   .debug_varnames  0 : { *(.debug_varnames) }
-  /* These must appear regardless of  .  */
+  /DISCARD/ : { *(.note.GNU-stack) }
 }
--- ppc.ld
+++ ppc.ld
@@ -1,116 +1,200 @@
-/* ld script to make i386 Linux kernel
- * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
- */
-OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
-OUTPUT_ARCH(powerpc)
-SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/alpha-unknown-linux-gnu/lib);
+/* Default linker script, for normal executables */
+OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
+	      "elf32-powerpc")
+OUTPUT_ARCH(powerpc:common)
 ENTRY(_start)
+SEARCH_DIR("/usr/powerpc-suse-linux/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  . = 0x60000000 + 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 = 0x60000000); . = 0x60000000 + 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) }
+  .rela.got1           : { *(.rela.got1) }
+  .rela.got2           : { *(.rela.got2) }
+  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
+  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
+  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
+  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
+  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
+  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
+  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
+  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
+  .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))
+  } =0
+  .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 = .;
+    *(.glink)
+  } =0
+  .fini           :
+  {
+    KEEP (*(.fini))
+  } =0
+  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) }
+  .sdata2         :
+  {
+    PROVIDE (_SDA2_BASE_ = 32768);
+    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
+  }
+  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
+  .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(0x100000) + (. & (0x100000 - 1));
-  .data    :
+  . = ALIGN (0x10000) - ((0x10000 - .) & (0x10000 - 1)); . = DATA_SEGMENT_ALIGN (0x10000, 0x1000);
+  /* 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) }
+  .preinit_array     :
+  {
+    PROVIDE_HIDDEN (__preinit_array_start = .);
+    KEEP (*(.preinit_array))
+    PROVIDE_HIDDEN (__preinit_array_end = .);
+  }
+  .init_array     :
+  {
+     PROVIDE_HIDDEN (__init_array_start = .);
+     KEEP (*(.init_array))
+     PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array     :
   {
-    *(.data)
-    *(.gnu.linkonce.d*)
-    CONSTRUCTORS
+    PROVIDE_HIDDEN (__fini_array_start = .);
+    KEEP (*(.fini_array))
+    PROVIDE_HIDDEN (__fini_array_end = .);
   }
-  .data1   : { *(.data1) }
-  .ctors         :
+  .ctors          :
   {
-    *(.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))
+    /* 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 (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
   }
-  .dtors         :
+  .dtors          :
   {
-    *(.dtors)
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
   }
-  .plt      : { *(.plt)	}
-  .got           : { *(.got.plt) *(.got) }
-  .dynamic       : { *(.dynamic) }
+  .jcr            : { KEEP (*(.jcr)) }
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
+  .got1           : { *(.got1) }
+  .got2           : { *(.got2) }
+  .dynamic        : { *(.dynamic) }
+  .got            : SPECIAL { *(.got) }
+  . = DATA_SEGMENT_RELRO_END (0, .);
+  .plt            : SPECIAL { *(.plt) }
+  .data           :
+  {
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  }
+  .data1          : { *(.data1) }
+  .got            : SPECIAL { *(.got) }
   /* We want the small data sections together, so single-instruction offsets
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
-  .sdata     : { *(.sdata) }
-  _edata  =  .;
-  PROVIDE (edata = .);
+  .sdata          :
+  {
+    PROVIDE (_SDA_BASE_ = 32768);
+    *(.sdata .sdata.* .gnu.linkonce.s.*)
+  }
+  _edata = .; PROVIDE (edata = .);
   __bss_start = .;
-  .sbss      : { *(.sbss) *(.scommon) }
-  .bss       :
+  .sbss           :
+  {
+    PROVIDE (__sbss_start = .); PROVIDE (___sbss_start = .);
+    *(.dynsbss)
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+    PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .);
+  }
+  .plt            : SPECIAL { *(.plt) }
+  .bss            :
   {
    *(.dynbss)
-   *(.bss)
+   *(.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);
   }
-  _end = . ;
+  . = ALIGN(32 / 8);
+  . = ALIGN(32 / 8);
+  _end = .;
   PROVIDE (end = .);
+  . = DATA_SEGMENT_END (.);
   /* 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          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) }
+  .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.  */
@@ -124,7 +208,7 @@
   .debug_aranges  0 : { *(.debug_aranges) }
   .debug_pubnames 0 : { *(.debug_pubnames) }
   /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info) }
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
   .debug_abbrev   0 : { *(.debug_abbrev) }
   .debug_line     0 : { *(.debug_line) }
   .debug_frame    0 : { *(.debug_frame) }
@@ -136,5 +220,6 @@
   .debug_funcnames 0 : { *(.debug_funcnames) }
   .debug_typenames 0 : { *(.debug_typenames) }
   .debug_varnames  0 : { *(.debug_varnames) }
-  /* These must appear regardless of  .  */
+  /DISCARD/	: { *(.fixup) }
+  /DISCARD/ : { *(.note.GNU-stack) }
 }

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running "hello world".
  2007-07-02 15:02       ` Alexander Graf
@ 2007-07-10 15:47         ` Rob Landley
  2007-07-10 16:10           ` Andreas Färber
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Landley @ 2007-07-10 15:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf

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 <mj@atrey.karlin.mff.cuni.cz>;
> - */
> -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.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-i386 segfaults running "hello world".
  2007-07-10 15:47         ` Rob Landley
@ 2007-07-10 16:10           ` Andreas Färber
  0 siblings, 0 replies; 18+ messages in thread
From: Andreas Färber @ 2007-07-10 16:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]


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

[-- Attachment #2: ppc-2007-07-10.diff --]
[-- Type: application/octet-stream, Size: 515 bytes --]

? .DS_Store
? ia64-softmmu
Index: hw/ppc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ppc.c,v
retrieving revision 1.22
diff -r1.22 ppc.c
599c599,602
< __attribute__ (( alias ("cpu_ppc_store_tbu") ));
---
> //__attribute__ (( alias ("cpu_ppc_store_tbu") ));
> {
> 	cpu_ppc_store_tbu(env, value);
> }
602c605,608
< __attribute__ (( alias ("cpu_ppc_load_tbu") ));
---
> //__attribute__ (( alias ("cpu_ppc_load_tbu") ));
> {
> 	return cpu_ppc_load_tbu(env);
> }

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2007-07-10 16:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-22 21:15 [Qemu-devel] qemu-i386 segfaults running "hello world" Rob Landley
2007-06-22 22:31 ` Rob Landley
2007-06-22 23:13   ` Alexander Graf
2007-06-22 23:27     ` andrzej zaborowski
2007-06-23  6:38       ` Rob Landley
2007-06-23  5:31     ` Rob Landley
2007-06-23  7:27       ` Alexander Graf
2007-06-24  5:40         ` Rob Landley
2007-06-23  7:41   ` Rob Landley
2007-06-23 11:00     ` Jens Axboe
2007-06-24  7:01       ` Rob Landley
2007-06-26 13:05         ` Jens Axboe
2007-06-23  9:50   ` Nigel Horne
2007-06-23 11:12   ` [Qemu-devel] [PATCH] " Stefan Weil
2007-06-24  7:36     ` Rob Landley
2007-07-02 15:02       ` Alexander Graf
2007-07-10 15:47         ` Rob Landley
2007-07-10 16:10           ` Andreas Färber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.