Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumpuser Do not process linkmaps if there is exactly ...



details:   https://anonhg.NetBSD.org/src/rev/835d672601c6
branches:  trunk
changeset: 794401:835d672601c6
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Mar 13 11:21:54 2014 +0000

description:
Do not process linkmaps if there is exactly one link map present
(i.e. there is no ld.so).  Makes statically linked rump kernels work on
glibc (at least for me).

based on some discussion with Justin Cormack

diffstat:

 lib/librumpuser/rumpuser_dl.c |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r 2b34ba16d56d -r 835d672601c6 lib/librumpuser/rumpuser_dl.c
--- a/lib/librumpuser/rumpuser_dl.c     Thu Mar 13 10:22:35 2014 +0000
+++ b/lib/librumpuser/rumpuser_dl.c     Thu Mar 13 11:21:54 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $  */
+/*      $NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $  */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.25 2013/10/30 13:08:14 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.26 2014/03/13 11:21:54 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -390,6 +390,22 @@
        origmap = mainmap;
 
        /*
+        * Use a heuristic to determine if we are static linked.
+        * A dynamically linked binary should always have at least
+        * two objects: itself and ld.so.
+        *
+        * In a statically linked binary with glibc the linkmap
+        * contains some "info" that leads to a segfault.  Since we
+        * can't really do anything useful in here without ld.so, just
+        * simply bail and let the symbol references in librump do the
+        * right things.
+        */
+       if (origmap->l_next == NULL && origmap->l_prev == NULL) {
+               dlclose(mainhandle);
+               return;
+       }
+
+       /*
         * Process last->first because that's the most probable
         * order for dependencies
         */



Home | Main Index | Thread Index | Old Index