From a3233a5c7c175c00173815d282004e5febc3d30c Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Tue, 6 Feb 2024 14:16:46 -0700 Subject: [PATCH] [build] Fix elf2elks libelf build on Apple M1 --- elks/tools/elf2elks/Makefile | 4 ++-- elks/tools/elf2elks/lib/elftoolchain2.patch | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 elks/tools/elf2elks/lib/elftoolchain2.patch diff --git a/elks/tools/elf2elks/Makefile b/elks/tools/elf2elks/Makefile index 282b3a0aa..f6429eb4e 100644 --- a/elks/tools/elf2elks/Makefile +++ b/elks/tools/elf2elks/Makefile @@ -57,10 +57,10 @@ elf2elks.o: elf2elks.c $(LIBELF) # make. To avoid roping in BSD make as yet another dependency, we directly # run the commands to generate and compile the libelf sources here. This # still requires m4 as a dependency though. -$(LIBELF): $(ELFTOOLCHAIN).tar.bz2 lib/elftoolchain.patch +$(LIBELF): $(ELFTOOLCHAIN).tar.bz2 lib/elftoolchain.patch lib/elftoolchain2.patch rm -rf $(ELFTOOLCHAIN) cd lib && tar -xvjf elftoolchain-0.7.1.tar.bz2 - cd $(ELFTOOLCHAIN) && patch -p1 <'$(abspath lib/elftoolchain.patch)' + cd $(ELFTOOLCHAIN) && patch -p1 <'$(abspath lib/elftoolchain.patch)' && patch -p1 <'$(abspath lib/elftoolchain2.patch)' ifeq "Linux" "$(shell uname -s)" set -e; \ cd $(ELFTOOLCHAIN)/common; \ diff --git a/elks/tools/elf2elks/lib/elftoolchain2.patch b/elks/tools/elf2elks/lib/elftoolchain2.patch new file mode 100644 index 000000000..ad131ade1 --- /dev/null +++ b/elks/tools/elf2elks/lib/elftoolchain2.patch @@ -0,0 +1,13 @@ +--- elftoolchain-0.7.1/libelf/_libelf_config.h 2024-02-06 14:09:41.000000000 -0700 ++++ 1 2024-02-06 14:09:27.000000000 -0700 +@@ -36,6 +36,10 @@ + #define LIBELF_ARCH EM_386 + #define LIBELF_BYTEORDER ELFDATA2LSB + #define LIBELF_CLASS ELFCLASS32 ++#elif defined(__aarch64__) ++#define LIBELF_ARCH EM_AARCH64 ++#define LIBELF_BYTEORDER ELFDATA2LSB ++#define LIBELF_CLASS ELFCLASS64 + #endif + + #endif /* __DragonFly__ */