Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/arch/zaurus Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/8d1d261e147a
branches:  netbsd-8
changeset: 461125:8d1d261e147a
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Nov 16 16:39:10 2019 +0000

description:
Pull up following revision(s) (requested by tsutsui in ticket #1446):

        sys/arch/zaurus/conf/GENERIC: revision 1.89
        sys/arch/zaurus/stand/zbsdmod/zbsdmod.c: revision 1.12
        sys/arch/zaurus/conf/INSTALL: revision 1.40
        sys/arch/zaurus/zaurus/machdep.c: revision 1.40
        sys/arch/zaurus/zaurus/machdep.c: revision 1.45
        sys/arch/zaurus/conf/GENERIC: revision 1.85

Yes, we need to load symbols, but we don't need the whole DDB infrastructure
for that.

bye ddb and we fit again.

Make zaurus kernels use symbol tables loaded by the bootloader.
Now COPY_SYMTAB is no longer necessary and it saves ~500kbytes of
GENERIC, so re-enable options DDB (i.e. revert GENERIC rev 1.85).

Also fix zbsdmod.o (a kernel loader for Zaurus Linux) to load symbols
at a proper address as the MI sys/lib/libsa/loadfile_elf32.c does.

No particular comment on port-zaurus@:

 https://mail-index.netbsd.org/port-zaurus/2019/11/11/msg000086.html

Note zbsdmod.c (derived from OpenBSD/zaurus) assumed that the loaded
kernels had "esym" variable at the top of its data section and
implicitly overwrote it with the address of loaded symbol tables.
OpenBSD/zaurus kernels used the esym value written by the zbsdmod.o
to initialize ksyms(4) on startup, but we will avoid such implicit
MD interface between the bootloader and kernels (though we don't
bother to add a symbol address value into bootinfo but just assume
symbols are loaded at end[] of a loaded kernel, as per the MI
libsa loadfile() implementation).

Worth to pullup to both netbsd-8 and netbsd-9.

diffstat:

 sys/arch/zaurus/conf/GENERIC            |   3 +-
 sys/arch/zaurus/conf/INSTALL            |   3 +-
 sys/arch/zaurus/stand/zbsdmod/zbsdmod.c |   6 +-
 sys/arch/zaurus/zaurus/machdep.c        |  66 +++++++++++++++++++++++++++++----
 4 files changed, 63 insertions(+), 15 deletions(-)

diffs (179 lines):

diff -r 5b9e725a02ca -r 8d1d261e147a sys/arch/zaurus/conf/GENERIC
--- a/sys/arch/zaurus/conf/GENERIC      Sat Nov 16 16:35:00 2019 +0000
+++ b/sys/arch/zaurus/conf/GENERIC      Sat Nov 16 16:39:10 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GENERIC,v 1.73.6.3 2018/04/18 14:45:09 martin Exp $
+#      $NetBSD: GENERIC,v 1.73.6.4 2019/11/16 16:39:10 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -171,7 +171,6 @@
 options        DDB_HISTORY_SIZE=100    # Enable history editing in DDB
 #options       KGDB
 #makeoptions   DEBUG="-g"              # compile full symbol table
-makeoptions    COPY_SYMTAB=1
 
 
 # Kernel root file system and dump configuration.
diff -r 5b9e725a02ca -r 8d1d261e147a sys/arch/zaurus/conf/INSTALL
--- a/sys/arch/zaurus/conf/INSTALL      Sat Nov 16 16:35:00 2019 +0000
+++ b/sys/arch/zaurus/conf/INSTALL      Sat Nov 16 16:39:10 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.32 2017/02/08 20:11:18 rin Exp $
+# $NetBSD: INSTALL,v 1.32.6.1 2019/11/16 16:39:10 martin Exp $
 #
 # INSTALL config file (GENERIC with memory disk root)
 #
@@ -67,7 +67,6 @@
 no options             DIAGNOSTIC
 no options             DDB
 no options             DDB_HISTORY_SIZE
-no makeoptions COPY_SYMTAB
 
 no options             PXA2X0_DMAC_DMOVER_CONCURRENCY
 
diff -r 5b9e725a02ca -r 8d1d261e147a sys/arch/zaurus/stand/zbsdmod/zbsdmod.c
--- a/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c   Sat Nov 16 16:35:00 2019 +0000
+++ b/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c   Sat Nov 16 16:39:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zbsdmod.c,v 1.9.22.1 2019/11/03 11:38:50 martin Exp $  */
+/*     $NetBSD: zbsdmod.c,v 1.9.22.2 2019/11/16 16:39:10 martin Exp $  */
 /*     $OpenBSD: zbsdmod.c,v 1.7 2005/05/02 02:45:29 uwe Exp $ */
 
 /*
@@ -139,8 +139,8 @@
                        if (maxv < posv)
                                maxv = posv;
                }
-               if (IS_DATA(phdr[i]) && IS_BSS(phdr[i])) {
-                       posv += phdr[i].p_memsz;
+               if (IS_BSS(phdr[i])) {
+                       posv += phdr[i].p_memsz - phdr[i].p_filesz;
                        if (maxv < posv)
                                maxv = posv;
                }
diff -r 5b9e725a02ca -r 8d1d261e147a sys/arch/zaurus/zaurus/machdep.c
--- a/sys/arch/zaurus/zaurus/machdep.c  Sat Nov 16 16:35:00 2019 +0000
+++ b/sys/arch/zaurus/zaurus/machdep.c  Sat Nov 16 16:39:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.38 2016/12/22 14:48:00 cherry Exp $      */
+/*     $NetBSD: machdep.c,v 1.38.8.1 2019/11/16 16:39:11 martin Exp $  */
 /*     $OpenBSD: zaurus_machdep.c,v 1.25 2006/06/20 18:24:04 todd Exp $        */
 
 /*
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38 2016/12/22 14:48:00 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.8.1 2019/11/16 16:39:11 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -247,6 +247,12 @@
 struct bootinfo *bootinfo;
 struct btinfo_howto *bi_howto;
 
+extern char etext[], end[];
+extern void *esym;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+#include <sys/exec_elf.h>
+#endif
+
 #define        KERNEL_BASE_PHYS        ((paddr_t)&KERNEL_BASE_phys)
 #define        BOOTINFO_PAGE           (KERNEL_BASE_PHYS - PAGE_SIZE)
 
@@ -647,6 +653,9 @@
        psize_t memsize;
        struct pxa2x0_gpioconf **zaurus_gpioconf;
        u_int *magicaddr;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+       u_int symbolsize;
+#endif
 
        /* Get ready for zaurus_restart() */
        pxa2x0_memctl_bootstrap(PXA2X0_MEMCTL_BASE);
@@ -917,6 +926,48 @@
        pmap_curmaxkvaddr =
            KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
 
+       /* check symbol table loaded by bootloader (zbsdmod.o) */
+       esym = end;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+       symbolsize = 0;
+       Elf_Ehdr *eh = (Elf_Ehdr *)end;
+#ifdef VERBOSE_INIT_ARM
+       printf("Checking ELF MAGIC at end: %02x %02x %02x %02x\n",
+           end[0], end[1], end[2], end[3]);
+#endif
+       if (memcmp(eh->e_ident, ELFMAG, SELFMAG) == 0) {
+               Elf_Shdr *sh;
+#ifdef VERBOSE_INIT_ARM
+               printf("ELF header found at end\n");
+#endif
+               sh = (Elf_Shdr *)((char *)end + eh->e_shoff);
+               for (loop = 0; loop < eh->e_shnum; loop++, sh++) {
+#ifdef VERBOSE_INIT_ARM
+                       printf("Checking ELF header %d\n", loop);
+#endif
+                       if (sh->sh_type != SHT_SYMTAB &&
+                           sh->sh_type != SHT_STRTAB) {
+                               continue;
+                       }
+#ifdef VERBOSE_INIT_ARM
+                       printf("Section[%2d]: offset = %d, size = %d\n",
+                           loop, sh->sh_offset, sh->sh_size);
+#endif
+                       if (sh->sh_offset > 0 &&
+                           (sh->sh_offset + sh->sh_size) > symbolsize) {
+                               symbolsize = sh->sh_offset + sh->sh_size;
+                       }
+#ifdef VERBOSE_INIT_ARM
+                       printf("Updating symbolsize = %d\n", symbolsize);
+#endif
+               }
+               esym = (char *)esym + symbolsize;
+       }
+#ifdef VERBOSE_INIT_ARM
+       printf("symbolsize = %d\n", symbolsize);
+#endif
+#endif /* NKSYMS || defined(DDB) || defined(MODULAR) */
+
 #ifdef VERBOSE_INIT_ARM
        printf("Mapping kernel\n");
 #endif
@@ -924,9 +975,9 @@
        /* Now we fill in the L2 pagetable for the kernel static code/data
         * and the symbol table. */
        {
-               extern char etext[], _end[];
+
                size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
-               size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
+               size_t totalsize = (uintptr_t) esym - KERNEL_TEXT_BASE;
                u_int logical;
 
                textsize = (textsize + PGOFSET) & ~PGOFSET;
@@ -1012,10 +1063,9 @@
         * variables.
         */
        {
-               extern char _end[];
 
                physical_freestart = physical_start +
-                   ((((uintptr_t) _end + PGOFSET) & ~PGOFSET) - KERNEL_BASE);
+                   ((((uintptr_t) esym + PGOFSET) & ~PGOFSET) - KERNEL_BASE);
                physical_freeend = physical_end;
                free_pages =
                    (physical_freeend - physical_freestart) / PAGE_SIZE;
@@ -1110,8 +1160,8 @@
 #endif
 
 #if NKSYMS || defined(DDB) || defined(MODULAR)
-       /* Firmware doesn't load symbols. */
-       ddb_init(0, NULL, NULL);
+       if (symbolsize > 0)
+               ksyms_addsyms_elf(symbolsize, &end, esym);
 #endif
 
 #ifdef KGDB



Home | Main Index | Thread Index | Old Index