Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2019 13:24:42 +0000 (UTC)
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344620 - head/usr.sbin/kldxref
Message-ID:  <201902271324.x1RDOgQX082151@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luporl
Date: Wed Feb 27 13:24:42 2019
New Revision: 344620
URL: https://svnweb.freebsd.org/changeset/base/344620

Log:
  Fix kldxref on PowerPC64
  
  When using kldxref on kernel modules built with clang8 + lld8,
  kldxref would be unable to find the modules metadata information,
  because PowerPC64 was using the ef_nop.c implementation of
  ef_reloc().
  
  When GNU LD was used, it was also relocating the metadata section of
  the .ko file. LLD does not do this, but only generate dynamic
  relocations for it. With minor changes, ef_powerpc.c can now work
  for PowerPC64 too.
  
  Reviewed by:	emaste
  Differential Revision:	https://reviews.freebsd.org/D19370

Modified:
  head/usr.sbin/kldxref/Makefile
  head/usr.sbin/kldxref/ef_powerpc.c

Modified: head/usr.sbin/kldxref/Makefile
==============================================================================
--- head/usr.sbin/kldxref/Makefile	Wed Feb 27 13:01:17 2019	(r344619)
+++ head/usr.sbin/kldxref/Makefile	Wed Feb 27 13:24:42 2019	(r344620)
@@ -6,7 +6,7 @@ SRCS=	kldxref.c ef.c ef_obj.c
 
 WARNS?=	2
 
-.if exists(ef_${MACHINE_CPUARCH}.c) && ${MACHINE_ARCH} != "powerpc64"
+.if exists(ef_${MACHINE_CPUARCH}.c)
 SRCS+=	ef_${MACHINE_CPUARCH}.c
 .else
 SRCS+=	ef_nop.c

Modified: head/usr.sbin/kldxref/ef_powerpc.c
==============================================================================
--- head/usr.sbin/kldxref/ef_powerpc.c	Wed Feb 27 13:01:17 2019	(r344619)
+++ head/usr.sbin/kldxref/ef_powerpc.c	Wed Feb 27 13:24:42 2019	(r344620)
@@ -34,10 +34,17 @@
 
 #include <err.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <string.h>
 
 #include "ef.h"
 
+#ifdef __powerpc64__
+#define PRI_ELF_SIZE PRIu64
+#else
+#define PRI_ELF_SIZE PRIu32
+#endif
+
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
  * target relocation address of the section, and `dataoff/len' is the region
@@ -63,11 +70,11 @@ ef_reloc(struct elf_file *ef, const void *reldata, int
 		return (0);
 
 	switch (rtype) {
-	case R_PPC_RELATIVE: /* word32 B + A */
+	case R_PPC_RELATIVE: /* word32|doubleword64 B + A */
 		*where = relbase + addend;
 		break;
 	default:
-		warnx("unhandled relocation type %u", rtype);
+		warnx("unhandled relocation type %" PRI_ELF_SIZE, rtype);
 	}
 	return (0);
 }



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