[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LRH.2.02.1711061812460.18820@file01.intranet.prod.int.rdu2.redhat.com>
Date: Mon, 6 Nov 2017 18:27:53 -0500 (EST)
From: Mikulas Patocka <mpatocka@...hat.com>
To: Josh Poimboeuf <jpoimboe@...hat.com>
cc: Andy Lutomirski <luto@...nel.org>, Borislav Petkov <bp@...en8.de>,
Brian Gerst <brgerst@...il.com>,
Denys Vlasenko <dvlasenk@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Jiri Slaby <jslaby@...e.cz>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
live-patching@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] objtool: fix build of 64-bit kernel with 32-bit userspace
This patch fixes building of 64-bit kernel on 32-bit userspace (I tested
it on RHEL-6-i686 and Debian-Sid-x32).
There are still some more bugs - when building 64-bit kernel on 32-bit
Debian 7 distribution, objtool corrupts object files so that the linker
doesn't recognize them (ld doesn't recognize the format of the file at all
and gold prints a lot of errors).
Another problem - when building 32-bit kernel, why do you force frame
pointers on and why did you hide CONFIG_GUESS_UNWINDER behind
CONFIG_EXPERT? Frame pointers increase code size and register pressure,
most users don't need precise stacktraces, so CONFIG_GUESS_UNWINDER should
be default for non-expert users just like it was before.
Is there some technical reason why do you want to avoid
CONFIG_GUESS_UNWINDER?
From: Mikulas Patocka <mpatocka@...hat.com>
Subject: [PATCH] objtool: fix build of 64-bit kernel with 32-bit userspace
The new orc unwinder breaks building 64-bit kernel with 32-bit userspace.
Building the kernel with i386 or x32 userspace fails with this error:
CC /usr/src/git/linux-2.6/tools/objtool/orc_dump.o
orc_dump.c: In function 'orc_dump':
orc_dump.c:105:26: error: passing argument 2 of 'elf_getshdrnum' from incompatible pointer type [-Werror=incompatible-pointer-types]
if (elf_getshdrnum(elf, &nr_sections)) {
^
In file included from /usr/local/include/gelf.h:32:0,
from elf.h:22,
from warn.h:26,
from orc_dump.c:20:
/usr/local/include/libelf.h:304:12: note: expected 'size_t * {aka unsigned int *}' but argument is of type 'long unsigned int *'
extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
^~~~~~~~~~~~~~
orc_dump.c:190:17: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'Elf64_Sxword {aka long long int}' [-Werror=format=]
printf("%s+%lx:", name, rela.r_addend);
~~^ ~~~~~~~~~~~~~
%llx
cc1: all warnings being treated as errors
This patch fixes the build failure.
Another problem is that if the user specifies HOSTCC or HOSTLD variables,
they are ignored in the makefile tools/objtool/Makefile. This patch
changes the makefile so that it respects these variables.
Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>
---
tools/objtool/Makefile | 5 +++--
tools/objtool/orc_dump.c | 7 ++++---
2 files changed, 7 insertions(+), 5 deletions(-)
Index: linux-2.6/tools/objtool/orc_dump.c
===================================================================
--- linux-2.6.orig/tools/objtool/orc_dump.c
+++ linux-2.6/tools/objtool/orc_dump.c
@@ -76,7 +76,8 @@ int orc_dump(const char *_objname)
int fd, nr_entries, i, *orc_ip = NULL, orc_size = 0;
struct orc_entry *orc = NULL;
char *name;
- unsigned long nr_sections, orc_ip_addr = 0;
+ size_t nr_sections;
+ Elf64_Addr orc_ip_addr = 0;
size_t shstrtab_idx;
Elf *elf;
Elf_Scn *scn;
@@ -187,10 +188,10 @@ int orc_dump(const char *_objname)
return -1;
}
- printf("%s+%lx:", name, rela.r_addend);
+ printf("%s+%llx:", name, (unsigned long long)rela.r_addend);
} else {
- printf("%lx:", orc_ip_addr + (i * sizeof(int)) + orc_ip[i]);
+ printf("%llx:", (unsigned long long)(orc_ip_addr + (i * sizeof(int)) + orc_ip[i]));
}
Index: linux-2.6/tools/objtool/Makefile
===================================================================
--- linux-2.6.orig/tools/objtool/Makefile
+++ linux-2.6/tools/objtool/Makefile
@@ -7,8 +7,9 @@ ARCH := x86
endif
# always use the host compiler
-CC = gcc
-LD = ld
+CC = $(HOSTCC)
+HOSTLD ?= ld
+LD = $(HOSTLD)
AR = ar
ifeq ($(srctree),)
Powered by blists - more mailing lists