WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] mini-os: work around ld bug causing stupi

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] mini-os: work around ld bug causing stupid CTOR count
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sat, 20 Aug 2011 07:11:09 +0100
Delivery-date: Fri, 19 Aug 2011 23:11:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xxxxxxxx>
# Date 1313744262 -3600
# Node ID 9957bef3e7b4511f83ed8883cd5ecd49ea3ee95d
# Parent  e35c5202625ef5534561f84352833ad9467d986c
mini-os: work around ld bug causing stupid CTOR count

I'm seeing pvgrub crashing when running CTORs.  It appears its because
the magic in the linker script is generating junk.  If I get ld to
output a map, I see:

.ctors          0x0000000000097000       0x18
                0x0000000000097000                __CTOR_LIST__ = .
                0x0000000000097000        0x4 LONG 0x25c04
                (((__CTOR_END__ - __CTOR_LIST__) / 0x4) - 0x2)
 *(.ctors)
 .ctors         0x0000000000097004       0x10
                
/home/jeremy/hg/xen/unstable/stubdom/mini-os-x86_32-grub/mini-os.o
                0x0000000000097014        0x4 LONG 0x0
                0x0000000000097018                __CTOR_END__ = .

In other words, somehow ((0x97018-0x97000) / 4) - 2 = 0x25c04

The specific crash is that the ctor loop tries to call the NULL
sentinel.  I'm seeing the same with the DTOR list.

Avoid this by terminating the loop with the NULL sentinel, and get rid
of the CTOR count entirely.

From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r e35c5202625e -r 9957bef3e7b4 extras/mini-os/arch/ia64/minios-ia64.lds
--- a/extras/mini-os/arch/ia64/minios-ia64.lds  Fri Aug 19 09:55:20 2011 +0100
+++ b/extras/mini-os/arch/ia64/minios-ia64.lds  Fri Aug 19 09:57:42 2011 +0100
@@ -55,7 +55,6 @@
   .ctors : AT(ADDR(.ctors) - (((5<<(61))+0x100000000) - (1 << 20)))
        {
         __CTOR_LIST__ = .;
-        QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
         *(.ctors)
        CONSTRUCTORS
         QUAD(0)
@@ -65,7 +64,6 @@
   .dtors : AT(ADDR(.dtors) - (((5<<(61))+0x100000000) - (1 << 20)))
         {
         __DTOR_LIST__ = .;
-        QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
         *(.dtors)
         QUAD(0)
         __DTOR_END__ = .;
diff -r e35c5202625e -r 9957bef3e7b4 extras/mini-os/arch/x86/minios-x86_32.lds
--- a/extras/mini-os/arch/x86/minios-x86_32.lds Fri Aug 19 09:55:20 2011 +0100
+++ b/extras/mini-os/arch/x86/minios-x86_32.lds Fri Aug 19 09:57:42 2011 +0100
@@ -30,7 +30,6 @@
 
   .ctors : {
         __CTOR_LIST__ = .;
-        LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
         *(.ctors)
        CONSTRUCTORS
         LONG(0)
@@ -39,7 +38,6 @@
 
   .dtors : {
         __DTOR_LIST__ = .;
-        LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
         *(.dtors)
         LONG(0)
         __DTOR_END__ = .;
diff -r e35c5202625e -r 9957bef3e7b4 extras/mini-os/arch/x86/minios-x86_64.lds
--- a/extras/mini-os/arch/x86/minios-x86_64.lds Fri Aug 19 09:55:20 2011 +0100
+++ b/extras/mini-os/arch/x86/minios-x86_64.lds Fri Aug 19 09:57:42 2011 +0100
@@ -30,7 +30,6 @@
 
   .ctors : {
         __CTOR_LIST__ = .;
-        QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
         *(.ctors)
        CONSTRUCTORS
         QUAD(0)
@@ -39,7 +38,6 @@
 
   .dtors : {
         __DTOR_LIST__ = .;
-        QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
         *(.dtors)
         QUAD(0)
         __DTOR_END__ = .;
diff -r e35c5202625e -r 9957bef3e7b4 extras/mini-os/main.c
--- a/extras/mini-os/main.c     Fri Aug 19 09:55:20 2011 +0100
+++ b/extras/mini-os/main.c     Fri Aug 19 09:57:42 2011 +0100
@@ -153,7 +153,7 @@
 
     __libc_init_array();
     environ = envp;
-    for (i = 1; i <= __CTOR_LIST__[0]; i++)
+    for (i = 0; __CTOR_LIST__[i] != 0; i++)
         ((void((*)(void)))__CTOR_LIST__[i]) ();
     tzset();
 
@@ -164,7 +164,7 @@
 {
     int i;
 
-    for (i = 1; i <= __DTOR_LIST__[0]; i++)
+    for (i = 0; __DTOR_LIST__[i] != 0; i++)
         ((void((*)(void)))__DTOR_LIST__[i]) ();
     close_all_files();
     __libc_fini_array();

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] mini-os: work around ld bug causing stupid CTOR count, Xen patchbot-unstable <=