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 <mpato...@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;

Reply via email to