From e363477b6704f2bae5139d46841c0c0d12e81ee7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 27 Nov 2023 16:02:45 +0000 Subject: [PATCH] WIP - HACKS --- src/Makefile | 54 +++++++++++++++++++++++++++++++++++--------------- src/script.lds | 2 ++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index c7ab421..a9b0e6e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,24 +2,30 @@ VERSION := v2.7.6 SBAT_GENERATION := 1 -OBJECTS := prefix.o startup.o callback.o main.o vsprintf.o string.o peloader.o -OBJECTS += int13.o vdisk.o cpio.o stdio.o lznt1.o xca.o die.o efi.o efimain.o +OBJECTS := vsprintf.o string.o peloader.o +OBJECTS += vdisk.o cpio.o stdio.o lznt1.o xca.o die.o efi.o efimain.o OBJECTS += efiguid.o efifile.o efipath.o efiboot.o efiblock.o cmdline.o OBJECTS += wimpatch.o huffman.o lzx.o wim.o wimfile.o pause.o sha1.o cookie.o -OBJECTS += paging.o memmap.o -OBJECTS_i386 := $(patsubst %.o,%.i386.o,$(OBJECTS)) -OBJECTS_x86_64 := $(patsubst %.o,%.x86_64.o,$(OBJECTS)) -OBJECTS_i386_x86_64 := $(patsubst %.o,%.i386.x86_64.o,$(OBJECTS)) +OBJECTS_x86 := $(OBJECTS) +OBJECTS_x86 += prefix.o startup.o callback.o main.o int13.o paging.o memmap.o + +OBJECTS_i386 := $(patsubst %.o,%.i386.o,$(OBJECTS_x86)) +OBJECTS_x86_64 := $(patsubst %.o,%.x86_64.o,$(OBJECTS_x86)) +OBJECTS_i386_x86_64 := $(patsubst %.o,%.i386.x86_64.o,$(OBJECTS_x86)) + +OBJECTS_arm64 := $(OBJECTS) HEADERS := $(wildcard *.h) HOST_CC := $(CC) -AS := $(AS) +CC := $(CROSS)gcc +AS := $(CROSS)$(AS) +LD := $(CROSS)$(LD) ECHO := echo -OBJCOPY := objcopy -AR := ar -RANLIB := ranlib +OBJCOPY := $(CROSS)objcopy +AR := $(CROSS)ar +RANLIB := $(CROSS)ranlib CP := cp RM := rm GCAB := gcab @@ -61,7 +67,7 @@ MS_ABI_TEST = $(ECHO) '$(MS_ABI_TEST_CODE)' | \ $(CC) -m64 -mno-accumulate-outgoing-args -x c -c - -o /dev/null \ >/dev/null 2>&1 MS_ABI_FLAGS := $(shell $(MS_ABI_TEST) || $(ECHO) '-maccumulate-outgoing-args') -WORKAROUND_CFLAGS += $(MS_ABI_FLAGS) +#WORKAROUND_CFLAGS += $(MS_ABI_FLAGS) # Inhibit warnings from taking address of packed struct members WNAPM_TEST = $(CC) -Wno-address-of-packed-member -x c -c /dev/null \ @@ -100,9 +106,9 @@ wimboot : wimboot.x86_64 Makefile $(CP) $< $@ $(CP) $@ ../$@ -wimboot.%.elf : prefix.%.o lib.%.a script.lds Makefile - $(LD) -m elf_$* -T script.lds -o $@ -q -Map wimboot.$*.map \ - prefix.$*.o lib.$*.a +wimboot.%.elf : lib.%.a script.lds Makefile + # $(LD) -m elf_$* -T script.lds -o $@ -q -Map wimboot.$*.map lib.$*.a + $(LD) -T script.lds -o $@ -q -Map wimboot.$*.map lib.$*.a wimboot.i386.unsigned : wimboot.i386.elf elf2efi32 Makefile $(OBJCOPY) -Obinary $< $@ @@ -112,6 +118,10 @@ wimboot.x86_64.unsigned : wimboot.x86_64.elf elf2efi64 Makefile $(OBJCOPY) -Obinary $< $@ ./elf2efi64 --hybrid $< $@ +wimboot.arm64.unsigned : wimboot.arm64.elf elf2efi64 Makefile + $(OBJCOPY) -Obinary $< $@ + ./elf2efi64 --hybrid $< $@ + wimboot.%.unsigned.hash : wimboot.%.unsigned Makefile $(PESIGN) -h -i $< | $(XARGS) -n 1 $(ECHO) | $(GREP) -x '[0-9a-f]*' > $@ @@ -174,15 +184,27 @@ lib.x86_64.a : $(OBJECTS_x86_64) $(OBJECTS_i386_x86_64) Makefile $(AR) r $@ $(OBJECTS_x86_64) $(OBJECTS_i386_x86_64) $(RANLIB) $@ +############################################################################### +# +# arm64 objects + +%.arm64.o : %.c $(HEADERS) Makefile + $(CC) $(CFLAGS) $(CFLAGS_arm64) -c $< -o $@ + +lib.arm64.a : $(OBJECTS_arm64) Makefile + $(RM) -f $@ + $(AR) r $@ $(OBJECTS_arm64) + $(RANLIB) $@ + ############################################################################### # # EFI relocator elf2efi32 : elf2efi.c Makefile - $(CC) $(HOST_CFLAGS) -idirafter . -DEFI_TARGET32 $< -o $@ + $(HOST_CC) $(HOST_CFLAGS) -idirafter . -DEFI_TARGET32 $< -o $@ elf2efi64 : elf2efi.c Makefile - $(CC) $(HOST_CFLAGS) -idirafter . -DEFI_TARGET64 $< -o $@ + $(HOST_CC) $(HOST_CFLAGS) -idirafter . -DEFI_TARGET64 $< -o $@ ############################################################################### # diff --git a/src/script.lds b/src/script.lds index 9dc8039..4c30fc2 100644 --- a/src/script.lds +++ b/src/script.lds @@ -24,6 +24,8 @@ SECTIONS { _prefix = .; *(.prefix) *(.prefix.*) + BYTE(1) + . = 0x400; _eprefix = .; } _prefix_len = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix );