Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cryptlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ WERRFLAGS += -Wno-error=unused-but-set-variable \
CFLAGS = $(FEATUREFLAGS) \
$(OPTIMIZATIONS) \
$(WARNFLAGS) \
$(ARCH_CFLAGS) \
$(WERRFLAGS) \
$(INCLUDES) \
$(DEFINES)
Expand Down
1 change: 1 addition & 0 deletions Cryptlib/OpenSSL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WERRFLAGS += -Wno-error=unused-but-set-variable \
CFLAGS = $(FEATUREFLAGS) \
$(OPTIMIZATIONS) \
$(WARNFLAGS) \
$(ARCH_CFLAGS) \
$(WERRFLAGS) \
$(INCLUDES) \
$(DEFINES)
Expand Down
12 changes: 9 additions & 3 deletions Make.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ CLANG_BUGS = $(if $(findstring gcc,$(CC)),-maccumulate-outgoing-args,) \
COMMIT_ID ?= $(shell if [ -e .git ] ; then git log -1 --pretty=format:%H ; elif [ -f commit ]; then cat commit ; else echo master; fi)

ifeq ($(ARCH),x86_64)
ARCH_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \
ARCH_TEST_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \
$(CLANG_BUGS) -m64 \
-DMDE_CPU_X64 -DPAGE_SIZE=4096
ARCH_CFLAGS ?= $(ARCH_TEST_CFLAGS) $(if $(findstring gcc,$(CC)),-mabi=ms)
ARCH_GNUEFI ?= x86_64
ARCH_SUFFIX ?= x64
ARCH_SUFFIX_UPPER ?= X64
ARCH_LDFLAGS ?=
ARCH_SECTION_ALIGNMENT ?= 0x1000
endif
ifeq ($(ARCH),ia32)
ARCH_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \
ARCH_TEST_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \
$(CLANG_BUGS) -m32 -malign-double \
-DMDE_CPU_IA32 -DPAGE_SIZE=4096
ARCH_CFLAGS ?= $(ARCH_TEST_CFLAGS)
ARCH_GNUEFI ?= ia32
ARCH_SUFFIX ?= ia32
ARCH_SUFFIX_UPPER ?= IA32
Expand All @@ -83,6 +85,7 @@ ifeq ($(ARCH),ia32)
endif
ifeq ($(ARCH),aarch64)
ARCH_CFLAGS ?= -DMDE_CPU_AARCH64 -DPAGE_SIZE=4096 -mstrict-align
ARCH_CFLAGS ?= $(ARCH_TEST_CFLAGS)
ARCH_GNUEFI ?= aarch64
ARCH_SUFFIX ?= aa64
ARCH_SUFFIX_UPPER ?= AA64
Expand All @@ -91,7 +94,8 @@ ifeq ($(ARCH),aarch64)
ARCH_SECTION_ALIGNMENT ?= 0x10000
endif
ifeq ($(ARCH),arm)
ARCH_CFLAGS ?= -DMDE_CPU_ARM -DPAGE_SIZE=4096 -mno-unaligned-access
ARCH_TEST_CFLAGS ?= -DMDE_CPU_ARM -DPAGE_SIZE=4096 -mno-unaligned-access
ARCH_CFLAGS ?= $(ARCH_TEST_CFLAGS)
ARCH_GNUEFI ?= arm
ARCH_SUFFIX ?= arm
ARCH_SUFFIX_UPPER ?= ARM
Expand Down Expand Up @@ -209,5 +213,7 @@ export VERBOSE
endif

export DEFINES
export OPTIMIZATIONS
export ARCH_CFLAGS

# vim:filetype=make
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ gnu-efi/gnuefi/libgnuefi.a gnu-efi/lib/libefi.a:
CCC_CC="$(COMPILER)" \
CC="$(CC)" \
ARCH=$(ARCH_GNUEFI) \
OPTIMIZATION_CFLAGS="$(OPTIMIZATIONS)" \
DEBUG_CFLAGS="-ggdb -gdwarf-4 -gstrict-dwarf" \
NO_GLIBC=1 \
TOPDIR=$(TOPDIR)/gnu-efi \
VPATH=$(TOPDIR)/gnu-efi \
OBJDIR=. \
GNU_EFI_EXPORT_MS_ABI=1 \
-f $(TOPDIR)/gnu-efi/Makefile \
lib gnuefi inc $(IGNORE_COMPILER_ERRORS)

Expand Down Expand Up @@ -555,5 +558,6 @@ archive: tag
.PHONY : install-deps shim.key

export ARCH CC CROSS_COMPILE LD OBJCOPY EFI_INCLUDE EFI_INCLUDES OPTIMIZATIONS
export ARCH_CFLAGS
export FEATUREFLAGS WARNFLAGS WERRFLAGS
unexport CFLAGS CPPFLAGS LDFLAGS
8 changes: 7 additions & 1 deletion elf_x86_64_efi.lds
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ SECTIONS
.data :
{
_data = .;
*(.rodata*)
*(.got.plt)
*(.got)
*(.data*)
Expand All @@ -60,6 +59,13 @@ SECTIONS
*(.reloc)
}

. = ALIGN(4096);
.rodata :
{
_rodata = .;
*(.rodata*)
}

. = ALIGN(4096);
.vendor_cert :
{
Expand Down
6 changes: 6 additions & 0 deletions include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,11 @@
_ret; \
})

#if defined(__x86_64__)
#define SYSVAPI __attribute__((sysv_abi))
#else
#define SYSVAPI
#endif

#endif /* !COMPILER_H_ */
// vim:fenc=utf-8:tw=75:et
8 changes: 4 additions & 4 deletions include/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ CFLAGS = $(OPTIMIZATIONS) -std=gnu11 \
$(EFI_INCLUDES) \
-Iinclude -iquote . \
-isystem /usr/include \
-isystem $(shell $(CC) $(ARCH_CFLAGS) -print-file-name=include) \
$(ARCH_CFLAGS) \
-isystem $(shell $(CC) $(ARCH_TEST_CFLAGS) -print-file-name=include) \
$(ARCH_TEST_CFLAGS) \
$(CFLAGS_LTO) \
$(CFLAGS_GCOV) \
-fshort-wchar \
Expand Down Expand Up @@ -48,13 +48,13 @@ CFLAGS = $(OPTIMIZATIONS) -std=gnu11 \

# On some systems (e.g. Arch Linux), limits.h is in the "include-fixed" instead
# of the "include" directory
INCLUDE_FIXED = $(shell $(CC) $(ARCH_CFLAGS) -print-file-name=include-fixed)
INCLUDE_FIXED = $(shell $(CC) $(ARCH_TEST_CFLAGS) -print-file-name=include-fixed)
ifneq ($(strip $(INCLUDE_FIXED)),include-fixed)
CFLAGS += -isystem $(INCLUDE_FIXED)
endif

# And on Debian also check the multi-arch include path
MULTIARCH_ISYSTEM = $(if $(findstring gcc,$(CC)),$(shell $(CC) $(ARCH_CFLAGS) -print-multiarch))
MULTIARCH_ISYSTEM = $(if $(findstring gcc,$(CC)),$(shell $(CC) $(ARCH_TEST_CFLAGS) -print-multiarch))
ifneq ($(strip $(MULTIARCH_ISYSTEM)),)
CFLAGS += -isystem /usr/include/$(MULTIARCH_ISYSTEM)
endif
Expand Down
6 changes: 3 additions & 3 deletions include/verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ init_openssl(void);
* If secure boot is enabled, verify that the provided buffer is signed
* with a trusted key.
*/
EFI_STATUS
SYSVAPI EFI_STATUS
shim_verify(void *buffer, UINT32 size);

EFI_STATUS
SYSVAPI EFI_STATUS
shim_hash(char *data, int datasize, PE_COFF_LOADER_IMAGE_CONTEXT *context,
UINT8 *sha256hash, UINT8 *sha1hash);

EFI_STATUS
SYSVAPI EFI_STATUS
shim_read_header(void *data, unsigned int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context);

Expand Down
2 changes: 2 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ LDFLAGS = -nostdlib -znocombreloc
CFLAGS = $(FEATUREFLAGS) \
$(OPTIMIZATIONS) \
$(WARNFLAGS) \
$(if $(findstring clang,$(CC)),$(CLANG_WARNINGS)) \
$(ARCH_CFLAGS) \
$(WERRFLAGS) \
$(INCLUDES) \
$(DEFINES)
Expand Down
7 changes: 7 additions & 0 deletions pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,13 @@ handle_image (void *data, unsigned int datasize,
if (size < Section->Misc.VirtualSize)
ZeroMem(base + size, Section->Misc.VirtualSize - size);
}
char name[9];
memcpy(name, Section->Name, 8);
name[8] = '\0';

dprint(L"Loading section %d \"%c%c%c%c%c%c%c%c\" at 0x%lx\n", i,
name[0], name[1], name[2], name[3], name[4], name[5], name[6], name[7],
base);
}

if (context.NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
Expand Down
3 changes: 0 additions & 3 deletions shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,6 @@ shim_fini(void)
console_fini();
}

extern EFI_STATUS
efi_main(EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab);

static void
__attribute__((__optimize__("0")))
debug_hook(void)
Expand Down
6 changes: 3 additions & 3 deletions shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@
INTERFACE_DECL(_SHIM_LOCK);

typedef
EFI_STATUS
SYSVAPI EFI_STATUS
(*EFI_SHIM_LOCK_VERIFY) (
IN VOID *buffer,
IN UINT32 size
);

typedef
EFI_STATUS
SYSVAPI EFI_STATUS
(*EFI_SHIM_LOCK_HASH) (
IN char *data,
IN int datasize,
Expand All @@ -243,7 +243,7 @@ EFI_STATUS
);

typedef
EFI_STATUS
SYSVAPI EFI_STATUS
(*EFI_SHIM_LOCK_CONTEXT) (
IN VOID *data,
IN unsigned int datasize,
Expand Down
6 changes: 3 additions & 3 deletions verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ verify_buffer (char *data, int datasize,
* Protocol entry point. If secure boot is enabled, verify that the provided
* buffer is signed with a trusted key.
*/
EFI_STATUS
SYSVAPI EFI_STATUS
shim_verify(void *buffer, UINT32 size)
{
EFI_STATUS efi_status = EFI_SUCCESS;
Expand Down Expand Up @@ -782,7 +782,7 @@ shim_verify(void *buffer, UINT32 size)
return efi_status;
}

EFI_STATUS
SYSVAPI EFI_STATUS
shim_hash(char *data, int datasize, PE_COFF_LOADER_IMAGE_CONTEXT *context,
UINT8 *sha256hash, UINT8 *sha1hash)
{
Expand All @@ -799,7 +799,7 @@ shim_hash(char *data, int datasize, PE_COFF_LOADER_IMAGE_CONTEXT *context,
return efi_status;
}

EFI_STATUS
SYSVAPI EFI_STATUS
shim_read_header(void *data, unsigned int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context)
{
Expand Down
Loading