Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Feb 2018 15:01:07 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329315 - head/stand/common
Message-ID:  <201802151501.w1FF17bB070942@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Feb 15 15:01:07 2018
New Revision: 329315
URL: https://svnweb.freebsd.org/changeset/base/329315

Log:
  stand: Fix ubldr after r329190
  
  metadata load files were consolidated in r329190, and these relocation fixup
  bits were inadvertently dropped in the process. Re-add them to fix boot with
  ubldr.
  
  Glanced over by:	jhibbits
  X-MFC-With:	r329190

Modified:
  head/stand/common/metadata.c

Modified: head/stand/common/metadata.c
==============================================================================
--- head/stand/common/metadata.c	Thu Feb 15 14:46:29 2018	(r329314)
+++ head/stand/common/metadata.c	Thu Feb 15 15:01:07 2018	(r329315)
@@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$");
 #include <fdt_platform.h>
 #endif
 
+#ifdef __arm__
+#include <machine/elf.h>
+#endif
 #include <machine/metadata.h>
 
 #include "bootstrap.h"
@@ -315,7 +318,23 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs
     uint64_t			scratch64;
     char			*rootdevname;
     int				howto;
+#ifdef __arm__
+    vm_offset_t			vaddr;
+    int				i;
 
+	/*
+	 * These metadata addreses must be converted for kernel after
+	 * relocation.
+	 */
+    uint32_t			mdt[] = {
+	    MODINFOMD_SSYM, MODINFOMD_ESYM, MODINFOMD_KERNEND,
+	    MODINFOMD_ENVP,
+#if defined(LOADER_FDT_SUPPORT)
+	    MODINFOMD_DTBP
+#endif
+    };
+#endif
+
     align = kern64 ? 8 : 4;
     howto = md_getboothowto(args);
 
@@ -409,6 +428,23 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs
     } else {
 	bcopy(&kernend, md->md_data, sizeof kernend);
     }
+
+#ifdef __arm__
+    /* Convert addresses to the final VA */
+    *modulep -= __elfN(relocation_offset);
+
+    /* Do relocation fixup on metadata of each module. */
+    for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
+        for (i = 0; i < nitems(mdt); i++) {
+            md = file_findmetadata(xp, mdt[i]);
+                if (md) {
+                    bcopy(md->md_data, &vaddr, sizeof vaddr);
+                    vaddr -= __elfN(relocation_offset);
+                    bcopy(&vaddr, md->md_data, sizeof vaddr);
+                }
+            }
+    }
+#endif
 
     (void)md_copymodules(addr, kern64);
 #if defined(LOADER_FDT_SUPPORT)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802151501.w1FF17bB070942>