Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/stand/ofwboot Align things pessimistically ...



details:   https://anonhg.NetBSD.org/src/rev/31692bf085ec
branches:  trunk
changeset: 486463:31692bf085ec
user:      eeh <eeh%NetBSD.org@localhost>
date:      Mon May 22 19:15:33 2000 +0000

description:
Align things pessimistically so a 64-bit kernel will accept symbols from a 32-bit loader.

diffstat:

 sys/arch/sparc64/stand/ofwboot/elfXX_exec.c |  22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 7f5f5b0ee14e -r 31692bf085ec sys/arch/sparc64/stand/ofwboot/elfXX_exec.c
--- a/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c       Mon May 22 17:17:44 2000 +0000
+++ b/sys/arch/sparc64/stand/ofwboot/elfXX_exec.c       Mon May 22 19:15:33 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elfXX_exec.c,v 1.5 2000/03/06 01:29:04 eeh Exp $       */
+/*     $NetBSD: elfXX_exec.c,v 1.6 2000/05/22 19:15:33 eeh Exp $       */
 
 /*
  * Copyright (c) 1998-2000 Eduardo Horvath.  All rights reserved.
@@ -50,6 +50,13 @@
 #if 0
 int    CAT3(elf,ELFSIZE,_exec) __P((int, CAT3(Elf,ELFSIZE,_Ehdr) *, u_int64_t *, void **, void **));
 #endif
+#if defined(ELFSIZE) && (ELFSIZE == 32)
+#define ELF_ALIGN(x)   (((x)+3)&(~3))
+#elif defined(ELFSIZE) && (ELFSIZE == 64)
+#define ELF_ALIGN(x)   (((x)+7)&(~7))
+#else
+#error ELFSIZE must be either 32 or 64!
+#endif
 
 int
 CAT3(elf, ELFSIZE, _exec)(fd, elf, entryp, ssymp, esymp)
@@ -168,8 +175,11 @@
         * Now load the symbol sections themselves.
         */
        shp = addr + sizeof(CAT3(Elf,ELFSIZE,_Ehdr));
-       addr += sizeof(CAT3(Elf,ELFSIZE,_Ehdr)) + (elf->e_shnum * sizeof(CAT3(Elf,ELFSIZE,_Shdr)));
-       off = sizeof(CAT3(Elf,ELFSIZE,_Ehdr)) + (elf->e_shnum * sizeof(CAT3(Elf,ELFSIZE,_Shdr)));
+       size = sizeof(CAT3(Elf,ELFSIZE,_Ehdr)) +
+               (elf->e_shnum * sizeof(CAT3(Elf,ELFSIZE,_Shdr)));
+       size = ELF_ALIGN(size);
+       addr += size;
+       off = size;
        for (first = 1, i = 0; i < elf->e_shnum; i++, shp++) {
                if (shp->sh_type == SHT_SYMTAB
                    || shp->sh_type == SHT_STRTAB) {
@@ -181,9 +191,9 @@
                                printf("read symbols: %s\n", strerror(errno));
                                return (1);
                        }
-                       addr += (shp->sh_size+3)&(~3);
+                       addr += ELF_ALIGN(shp->sh_size);
                        shp->sh_offset = off;
-                       off += (shp->sh_size+3)&(~3);
+                       off += ELF_ALIGN(shp->sh_size);
                        first = 0;
                }
        }
@@ -192,3 +202,5 @@
        *entryp = elf->e_entry;
        return (0);
 }
+
+#undef ELF_ALIGN



Home | Main Index | Thread Index | Old Index