All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
@ 2018-03-08  6:11 Mikulas Patocka
  2018-03-08  7:39 ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2018-03-08  6:11 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: David Woodhouse, Thomas Gleixner, Josh Poimboeuf,
	Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
	Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel

The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add 
retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.

This patch fixes the following error and a large number of "can't find
rela for retpoline_safe" errors that occur when using x32 or i386 gcc.

You shouldn't use the type 'unsigned long' in objtool at all - because its
size depends on the compiler and not on the kernel you are compiling.

In file included from check.c:26:0:
check.c: In function 'read_retpoline_hints':
warn.h:57:3: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Werror=format=]
   "%s: warning: objtool: " format "\n", \
   ^
check.c:1135:3: note: in expansion of macro 'WARN'
   WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
   ^~~~
check.c:1135:44: note: format string is defined here
   WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
                                          ~~^
                                          %d

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: b5bc2231b8ad ("objtool: Add retpoline validation")

---
 tools/objtool/check.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/tools/objtool/check.c
===================================================================
--- linux-2.6.orig/tools/objtool/check.c	2018-03-08 06:53:03.535471000 +0100
+++ linux-2.6/tools/objtool/check.c	2018-03-08 06:56:32.975471000 +0100
@@ -1131,13 +1131,13 @@ static int read_retpoline_hints(struct o
 		return -1;
 	}
 
-	if (sec->len % sizeof(unsigned long)) {
-		WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
+	if (sec->len % sizeof(uint64_t)) {
+		WARN("retpoline_safe size mismatch: %d %d", sec->len, (int)sizeof(uint64_t));
 		return -1;
 	}
 
-	for (i = 0; i < sec->len / sizeof(unsigned long); i++) {
-		rela = find_rela_by_dest(sec, i * sizeof(unsigned long));
+	for (i = 0; i < sec->len / sizeof(uint64_t); i++) {
+		rela = find_rela_by_dest(sec, i * sizeof(uint64_t));
 		if (!rela) {
 			WARN("can't find rela for retpoline_safe[%d]", i);
 			return -1;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-08 15:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08  6:11 [PATCH] fix compilation of 64-bit kernel with 32-bit compiler Mikulas Patocka
2018-03-08  7:39 ` Peter Zijlstra
2018-03-08  9:09   ` Mikulas Patocka
2018-03-08  9:39     ` Peter Zijlstra
2018-03-08 15:17       ` Josh Poimboeuf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.