Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpuser * load symbols only up to actual s...



details:   https://anonhg.NetBSD.org/src/rev/478031c648c7
branches:  trunk
changeset: 749320:478031c648c7
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Nov 26 15:44:26 2009 +0000

description:
* load symbols only up to actual size of symbol table instead of size
  we allocated for storing the table
* trimm unused end off of table before passing to the kernel

diffstat:

 sys/rump/librump/rumpuser/rumpuser_dl.c |  33 +++++++++++++++++++++++++++++----
 1 files changed, 29 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 2a7946d97dc6 -r 478031c648c7 sys/rump/librump/rumpuser/rumpuser_dl.c
--- a/sys/rump/librump/rumpuser/rumpuser_dl.c   Thu Nov 26 15:17:08 2009 +0000
+++ b/sys/rump/librump/rumpuser/rumpuser_dl.c   Thu Nov 26 15:44:26 2009 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $   */
+/*      $NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $   */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.8 2009/11/26 10:57:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.9 2009/11/26 15:44:26 pooka Exp $");
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -363,8 +363,33 @@
                if (strstr(map->l_name, "librump") != NULL)
                        error = getsymbols(map);
        }
-       if (error == 0)
-               symload(symtab, symtabsize, strtab, strtabsize);
+
+       if (error == 0) {
+               void *trimmedsym, *trimmedstr;
+
+               /*
+                * Allocate optimum-sized memory for storing tables
+                * and feed to kernel.  If memory allocation fails,
+                * just give the ones with extra context (although
+                * I'm pretty sure we'll die moments later due to
+                * memory running out).
+                */
+               if ((trimmedsym = malloc(symtaboff)) != NULL) {
+                       memcpy(trimmedsym, symtab, symtaboff);
+               } else {
+                       trimmedsym = symtab;
+                       symtab = NULL;
+               }
+               if ((trimmedstr = malloc(strtaboff)) != NULL) {
+                       memcpy(trimmedstr, strtab, strtaboff);
+               } else {
+                       trimmedstr = strtab;
+                       strtab = NULL;
+               }
+               symload(trimmedsym, symtaboff, trimmedstr, strtaboff);
+       }
+       free(symtab);
+       free(strtab);
 
        do {
                couldload = 0;



Home | Main Index | Thread Index | Old Index