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
This commit is contained in:
Kyle Evans 2018-02-15 15:01:07 +00:00
parent 113ce413ba
commit 4daa199d7b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329315

View file

@ -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,6 +318,22 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64)
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);
@ -410,6 +429,23 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64)
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)
if (dtb != NULL)