Skip to content

Commit

Permalink
WIP - HACKS
Browse files Browse the repository at this point in the history
  • Loading branch information
mcb30 committed Nov 27, 2023
1 parent 033af42 commit 1709c50
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ 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_arm64 := $(patsubst %.o,%.arm64.o,$(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
Expand Down Expand Up @@ -61,7 +64,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 \
Expand Down Expand Up @@ -100,8 +103,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 \
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 \
prefix.$*.o lib.$*.a

wimboot.i386.unsigned : wimboot.i386.elf elf2efi32 Makefile
Expand All @@ -112,6 +116,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]*' > $@

Expand Down Expand Up @@ -174,15 +182,33 @@ 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.s : %.S $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CFLAGS_arm64) -DASSEMBLY -E $< -o $@

%.arm64.s : %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CFLAGS_arm64) -S $< -o $@

%.arm64.o : %.arm64.s Makefile
$(AS) $< -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 $@

###############################################################################
#
Expand All @@ -191,6 +217,7 @@ elf2efi64 : elf2efi.c Makefile
clean :
$(RM) -f *.s *.o *.a *.elf *.map
$(RM) -f elf2efi32 elf2efi64
$(RM) -f wimboot wimboot.i386 wimboot.x86_64 ../wimboot
$(RM) -f wimboot.i386.unsigned wimboot.x86_64.unsigned
$(RM) -f wimboot.i386.efi wimboot.x86_64.efi wimboot.cab
$(RM) -f wimboot.i386 wimboot.i386.*
$(RM) -f wimboot.x86_64 wimboot.x86_64.*
$(RM) -f wimboot.arm64 wimboot.arm64.*
$(RM) -f wimboot wimboot.cab

0 comments on commit 1709c50

Please sign in to comment.