blob: 26d18eb6fe80b22645d37aa5e12d827060b06413 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001x86_64: Add support to build kexec-tools with x32 ABI
2
3Summary of changes,
4
5configure.ac: Add test for detect x32 ABI.
6purgatory/arch/x86_64/Makefile: Not use mcmodel large when
7 x32 ABI is set.
8kexec/arch/x86_64/kexec-elf-rel-x86_64.c: When x32 ABI is set
9 use ELFCLASS32 instead of ELFCLASS64.
10kexec/kexec-syscall.h: Add correct syscall number for x32 ABI.
11
12Upstream-Status: Submitted
13
14Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
15Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
16
17---
18 configure.ac | 9 +++++++++
19 kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 ++++
20 kexec/kexec-syscall.h | 4 ++++
21 purgatory/arch/x86_64/Makefile | 4 +++-
22 4 files changed, 20 insertions(+), 1 deletion(-)
23
24Index: kexec-tools-2.0.10/configure.ac
25===================================================================
26--- kexec-tools-2.0.10.orig/configure.ac
27+++ kexec-tools-2.0.10/configure.ac
28@@ -56,6 +56,15 @@ case $target_cpu in
29 ;;
30 ia64|x86_64|alpha|m68k )
31 ARCH="$target_cpu"
32+
33+ dnl ---Test for x32 ABI in x86_64
34+ if test "x$ARCH" = "xx86_64" ; then
35+ AC_EGREP_CPP(x32_test,
36+ [#if defined(__x86_64__) && defined (__ILP32__)
37+ x32_test
38+ #endif
39+ ], SUBARCH='x32', SUBARCH='64')
40+ fi
41 ;;
42 * )
43 AC_MSG_ERROR([unsupported architecture $target_cpu])
44Index: kexec-tools-2.0.10/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
45===================================================================
46--- kexec-tools-2.0.10.orig/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
47+++ kexec-tools-2.0.10/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
48@@ -8,7 +8,11 @@ int machine_verify_elf_rel(struct mem_eh
49 if (ehdr->ei_data != ELFDATA2LSB) {
50 return 0;
51 }
52+#ifdef __ILP32__
53+ if (ehdr->ei_class != ELFCLASS32) {
54+#else
55 if (ehdr->ei_class != ELFCLASS64) {
56+#endif
57 return 0;
58 }
59 if (ehdr->e_machine != EM_X86_64) {
60Index: kexec-tools-2.0.10/kexec/kexec-syscall.h
61===================================================================
62--- kexec-tools-2.0.10.orig/kexec/kexec-syscall.h
63+++ kexec-tools-2.0.10/kexec/kexec-syscall.h
64@@ -31,8 +31,12 @@
65 #define __NR_kexec_load 268
66 #endif
67 #ifdef __x86_64__
68+#ifdef __ILP32__
69+#define __NR_kexec_load 528
70+#else
71 #define __NR_kexec_load 246
72 #endif
73+#endif
74 #ifdef __s390x__
75 #define __NR_kexec_load 277
76 #endif
77Index: kexec-tools-2.0.10/purgatory/arch/x86_64/Makefile
78===================================================================
79--- kexec-tools-2.0.10.orig/purgatory/arch/x86_64/Makefile
80+++ kexec-tools-2.0.10/purgatory/arch/x86_64/Makefile
81@@ -23,4 +23,6 @@ x86_64_PURGATORY_SRCS += purgatory/arch/
82 x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
83 x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c
84
85-x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
86+ifeq ($(SUBARCH),64)
87+ x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
88+endif