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 e200314 commit e363477
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
54 changes: 38 additions & 16 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 $< $@
Expand All @@ -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]*' > $@

Expand Down Expand Up @@ -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 $@

###############################################################################
#
Expand Down
2 changes: 2 additions & 0 deletions src/script.lds
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SECTIONS {
_prefix = .;
*(.prefix)
*(.prefix.*)
BYTE(1)
. = 0x400;
_eprefix = .;
}
_prefix_len = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix );
Expand Down

0 comments on commit e363477

Please sign in to comment.