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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "gnu-efi"]
path = gnu-efi
url = https://github.com/rhboot/gnu-efi.git
branch = shim-16.1
url = https://github.com/ncroxon/gnu-efi.git
branch = master
3 changes: 0 additions & 3 deletions Cryptlib/Include/OpenSslSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#if defined(__x86_64__)
/* shim.h will check if the compiler is new enough in some other CU */

#if !defined(GNU_EFI_USE_EXTERNAL_STDARG)
#define GNU_EFI_USE_EXTERNAL_STDARG
#endif

#if !defined(GNU_EFI_USE_MS_ABI)
#define GNU_EFI_USE_MS_ABI
Expand Down
4 changes: 0 additions & 4 deletions Cryptlib/Library/BaseLib.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#if defined(__x86_64__)
/* shim.h will check if the compiler is new enough in some other CU */

#if !defined(GNU_EFI_USE_EXTERNAL_STDARG)
#define GNU_EFI_USE_EXTERNAL_STDARG
#endif

#if !defined(GNU_EFI_USE_MS_ABI)
#define GNU_EFI_USE_MS_ABI
#endif
Expand Down
4 changes: 2 additions & 2 deletions Cryptlib/SysCall/BaseStrings.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CHAR8 *
AsciiStrCat(CHAR8 *Destination, const CHAR8 *Source)
{
UINTN dest_len = strlen((CHAR8 *)Destination);
UINTN dest_len = strlen((char *)Destination);
UINTN i;

for (i = 0; Source[i] != '\0'; i++)
Expand Down Expand Up @@ -61,7 +61,7 @@ WriteUnaligned32(UINT32 *Buffer, UINT32 Value)
UINTN
AsciiStrSize(const CHAR8 *string)
{
return strlen(string) + 1;
return strlen((char *)string) + 1;
}

/* Based on AsciiStrDecimalToUintnS() in edk2
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ MokManager.o: $(MOK_SOURCES)
$(MMSONAME): $(MOK_OBJS) $(LIBS)
$(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS) lib/lib.a

gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a: CFLAGS+=-DGNU_EFI_USE_EXTERNAL_STDARG
gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a:
mkdir -p gnu-efi/lib gnu-efi/gnuefi
$(MAKE) -C gnu-efi \
COMPILER="$(COMPILER)" \
CCC_CC="$(COMPILER)" \
CC="$(CC)" \
ARCH=$(ARCH_GNUEFI) \
NO_GLIBC=1 \
TOPDIR=$(TOPDIR)/gnu-efi \
-f $(TOPDIR)/gnu-efi/Makefile \
lib gnuefi inc $(IGNORE_COMPILER_ERRORS)
Expand Down
2 changes: 1 addition & 1 deletion csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parse_csv_data(char *data, char *data_end, size_t n_columns, list_t *list)
}

max = (uintptr_t)end - (uintptr_t)line + (end > line ? 1 : 0);
if (is_utf8_bom(line, max))
if (is_utf8_bom((CHAR8 *)line, max))

line += UTF8_BOM_SIZE;

Expand Down
17 changes: 9 additions & 8 deletions errlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ vdprint_(const CHAR16 *fmt, const char *file, int line, const char *func,
if (verbose) {
ms_va_copy(args2, args);
console_print(L"%a:%d:%a() ", file, line, func);
efi_status = VPrint(fmt, args2);
efi_status = MS_VPrint(fmt, args2);
ms_va_end(args2);
}
return efi_status;
Expand All @@ -35,16 +35,17 @@ VLogError(const char *file, int line, const char *func, const CHAR16 *fmt,
if (file == NULL || func == NULL || fmt == NULL)
return EFI_INVALID_PARAMETER;

newerrs = ReallocatePool(errs, (nerrs + 1) * sizeof(*errs),
(nerrs + 3) * sizeof(*errs));
newerrs = ReallocatePool((nerrs + 1) * sizeof(*errs),
(nerrs + 3) * sizeof(*errs),
errs);
if (!newerrs)
return EFI_OUT_OF_RESOURCES;

newerrs[nerrs] = PoolPrint(L"%a:%d %a() ", file, line, func);
if (!newerrs[nerrs])
return EFI_OUT_OF_RESOURCES;
ms_va_copy(args2, args);
newerrs[nerrs+1] = VPoolPrint(fmt, args2);
newerrs[nerrs+1] = MS_VPoolPrint(fmt, args2);
if (!newerrs[nerrs+1])
return EFI_OUT_OF_RESOURCES;
ms_va_end(args2);
Expand Down Expand Up @@ -134,7 +135,7 @@ log_debug_print(const CHAR16 *fmt, ...)
UINTN ret = 0;

ms_va_start(args, fmt);
buf = VPoolPrint(fmt, args);
buf = MS_VPoolPrint(fmt, args);
if (!buf)
return 0;
ms_va_end(args);
Expand All @@ -148,7 +149,7 @@ log_debug_print(const CHAR16 *fmt, ...)
new_alloc_sz += buf_sz;
new_alloc_sz = ALIGN_UP(new_alloc_sz, EFI_PAGE_SIZE);

new_debug_log = ReallocatePool(debug_log, debug_log_alloc, new_alloc_sz);
new_debug_log = ReallocatePool(debug_log_alloc, new_alloc_sz, debug_log);
if (!new_debug_log)
return 0;
debug_log = (UINT8 *)new_debug_log;
Expand Down Expand Up @@ -260,15 +261,15 @@ save_logs(void)

entry = (struct mok_variable_config_entry *)((uintptr_t)new_table + pos);
if (errlog_sz) {
strcpy(entry->name, "shim-err.txt");
strcpy((char *)entry->name, "shim-err.txt");
entry->data_size = errlog_sz;
format_error_log(&entry->data[0], errlog_sz);

pos += sizeof(*entry) + errlog_sz;
entry = (struct mok_variable_config_entry *)((uintptr_t)new_table + pos);
}
if (dbglog_sz) {
strcpy(entry->name, "shim-dbg.txt");
strcpy((char *)entry->name, "shim-dbg.txt");
entry->data_size = dbglog_sz;
format_debug_log(&entry->data[0], dbglog_sz);

Expand Down
6 changes: 3 additions & 3 deletions fallback.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ find_boot_option(EFI_DEVICE_PATH *dp, EFI_DEVICE_PATH *fulldp,
if (efi_status == EFI_BUFFER_TOO_SMALL) {
VerbosePrint(L"Buffer too small for next variable name, re-allocating it to be %d bytes and retrying\n",
varname_size);
varname = ReallocatePool(varname,
buffer_size,
varname_size);
varname = ReallocatePool(buffer_size,
varname_size,
varname);
if (!varname)
return EFI_OUT_OF_RESOURCES;
buffer_size = varname_size;
Expand Down
2 changes: 1 addition & 1 deletion gnu-efi
20 changes: 10 additions & 10 deletions httpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ find_httpboot (EFI_HANDLE device)

/* Save the current URI */
UriNode = (URI_DEVICE_PATH *)Node;
uri_size = strlen(UriNode->Uri);
uri_size = strlen((char *)UriNode->Uri);
uri = AllocatePool(uri_size + 1);
if (!uri) {
perror(L"Failed to allocate uri\n");
Expand All @@ -201,18 +201,18 @@ generate_next_uri (CONST CHAR8 *current_uri, CONST CHAR8 *next_loader,
UINTN path_len = 0;
UINTN count = 0;

if (strncmp(current_uri, (CHAR8 *)"http://", 7) == 0) {
if (strncmp((char *)current_uri, "http://", 7) == 0) {
ptr = current_uri + 7;
count += 7;
} else if (strncmp(current_uri, (CHAR8 *)"https://", 8) == 0) {
} else if (strncmp((char *)current_uri, "https://", 8) == 0) {
ptr = current_uri + 8;
count += 8;
} else {
return EFI_INVALID_PARAMETER;
}

/* Extract the path */
next_len = strlen(next_loader);
next_len = strlen((char *)next_loader);
while (*ptr != '\0') {
count++;
if (*ptr == '/')
Expand All @@ -237,9 +237,9 @@ extract_hostname (CONST CHAR8 *url, CHAR8 **hostname)
CONST CHAR8 *ptr, *start;
UINTN host_len = 0;

if (strncmp(url, (CHAR8 *)"http://", 7) == 0)
if (strncmp((char *)url, "http://", 7) == 0)
start = url + 7;
else if (strncmp(url, (CHAR8 *)"https://", 8) == 0)
else if (strncmp((char *)url, "https://", 8) == 0)
start = url + 8;
else
return EFI_INVALID_PARAMETER;
Expand Down Expand Up @@ -618,8 +618,8 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINT64 *buf_size)

/* Check the length of the file */
for (i = 0; i < rx_message.HeaderCount; i++) {
if (!strcasecmp(rx_message.Headers[i].FieldName,
(CHAR8 *)"Content-Length")) {
if (!strcasecmp((char *)rx_message.Headers[i].FieldName,
"Content-Length")) {
new_buf_size = ascii_to_int(rx_message.Headers[i].FieldValue);
if (buf_size_set && new_buf_size != *buf_size) {
perror(L"Content-Length is invalid\n");
Expand Down Expand Up @@ -784,8 +784,8 @@ httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINT64 *buf_size,
if (!uri)
return EFI_NOT_READY;

next_loader = (CHAR8 *)AllocatePool((strlen(name) + 1) * sizeof (CHAR8));
translate_slashes(next_loader, name);
next_loader = (CHAR8 *)AllocatePool((strlen((char *)name) + 1) * sizeof (CHAR8));
translate_slashes((char *)next_loader, (char *)name);

/* Create the URI for the next loader based on the original URI */
efi_status = generate_next_uri(uri, next_loader, &next_uri);
Expand Down
4 changes: 0 additions & 4 deletions include/system/efistdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#ifndef _EFISTDARG_H_
#define _EFISTDARG_H_

#ifndef GNU_EFI_USE_EXTERNAL_STDARG
#define GNU_EFI_USE_EXTERNAL_STDARG
#endif

#include <stdarg.h>

#endif /* !_EFISTDARG_H_ */
Expand Down
16 changes: 0 additions & 16 deletions include/system/stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,13 @@ typedef __builtin_va_list __builtin_sysv_va_list;
#pragma GCC diagnostic pop
#endif

#ifndef GNU_EFI_USE_EXTERNAL_STDARG
#define GNU_EFI_USE_EXTERNAL_STDARG
#endif

#ifdef SHIM_UNIT_TEST
#include_next <stdarg.h>
#endif

#if defined(__aarch64__) || defined(__arm__) || defined(__i386__) || \
defined(__i486__) || defined(__i686__) || defined(__COVERITY__)

typedef __builtin_va_list ms_va_list;
typedef __builtin_va_list __builtin_ms_va_list;
#define ms_va_copy(dest, start) __builtin_va_copy(dest, start)
#define ms_va_start(marker, arg) __builtin_va_start(marker, arg)
#define ms_va_arg(marker, type) __builtin_va_arg(marker, type)
#define ms_va_end(marker) __builtin_va_end(marker)

typedef __builtin_va_list sysv_va_list;
#define sysv_va_copy(dest, start) __builtin_va_copy(dest, start)
#define sysv_va_start(marker, arg) __builtin_va_start(marker, arg)
Expand All @@ -49,11 +38,6 @@ typedef __builtin_va_list VA_LIST;

#elif defined(__x86_64__)

typedef __builtin_ms_va_list ms_va_list;
#define ms_va_copy(dest, start) __builtin_ms_va_copy(dest, start)
#define ms_va_start(marker, arg) __builtin_ms_va_start(marker, arg)
#define ms_va_arg(marker, type) __builtin_va_arg(marker, type)
#define ms_va_end(marker) __builtin_ms_va_end(marker)
typedef __builtin_sysv_va_list sysv_va_list;
#define sysv_va_copy(dest, start) __builtin_sysv_va_copy(dest, start)
#define sysv_va_start(marker, arg) __builtin_sysv_va_start(marker, arg)
Expand Down
4 changes: 2 additions & 2 deletions lib/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ console_print(const CHAR16 *fmt, ...)
setup_console(1);

ms_va_start(args, fmt);
ret = VPrint(fmt, args);
ret = MS_VPrint(fmt, args);
ms_va_end(args);

return ret;
Expand All @@ -116,7 +116,7 @@ console_print_at(UINTN col, UINTN row, const CHAR16 *fmt, ...)
co->SetCursorPosition(co, col, row);

ms_va_start(args, fmt);
ret = VPrint(fmt, args);
ret = MS_VPrint(fmt, args);
ms_va_end(args);

return ret;
Expand Down
8 changes: 4 additions & 4 deletions mok.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ format_variable_info(UINT8 *buf, size_t bufsz,
var_set_t *var_set = &var_sets[i];
UINTN rc;
rc = AsciiSPrint((CHAR8 *)buf + pos, bufsz - pos,
"%a_max_storage_sz: 0x%lx\n",
(const CHAR8 *)"%a_max_storage_sz: 0x%lx\n",
var_set->prefix, var_set->max_storage_sz);
pos += rc;
rc = AsciiSPrint((CHAR8 *)buf + pos, bufsz - pos,
"%a_remaining_sz: 0x%lx\n",
(const CHAR8 *)"%a_remaining_sz: 0x%lx\n",
var_set->prefix, var_set->remaining_sz);
pos += rc;
rc = AsciiSPrint((CHAR8 *)buf + pos, bufsz - pos,
"%a_max_var_sz: 0x%lx\n",
(const CHAR8 *)"%a_max_var_sz: 0x%lx\n",
var_set->prefix, var_set->max_var_sz);
pos += rc;
}
Expand Down Expand Up @@ -1422,7 +1422,7 @@ EFI_STATUS import_mok_state(EFI_HANDLE image_handle)
struct mok_state_variable *v = &mok_state_variables[i];

ZeroMem(&config_template, sizeof(config_template));
strncpy(config_template.name, (CHAR8 *)v->rtname8, 255);
strncpy((char *)config_template.name, v->rtname8, 255);
config_template.name[255] = '\0';

config_template.data_size = v->data_size;
Expand Down
22 changes: 11 additions & 11 deletions netboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static CHAR8 *str2ip6(CHAR8 *str)
if (dotcount > MAX_IP6_DOTS)
return (CHAR8 *)ip;

len = strlen(str);
len = strlen((char *)str);
a = b = str;

for (i = 0; i < len; i++) {
Expand Down Expand Up @@ -203,7 +203,7 @@ static BOOLEAN extract_tftp_info(CHAR8 *url, CHAR8 *name)

while (name[template_len++] != '\0');
template = (CHAR8 *)AllocatePool((template_len + 1) * sizeof (CHAR8));
translate_slashes(template, name);
translate_slashes((char *)template, (char *)name);

// to check against str2ip6() errors
memset(ip6inv, 0, sizeof(ip6inv));
Expand Down Expand Up @@ -243,17 +243,17 @@ static BOOLEAN extract_tftp_info(CHAR8 *url, CHAR8 *name)
FreePool(template);
return FALSE;
}
full_path = AllocateZeroPool(strlen(end)+strlen(template)+1);
full_path = AllocateZeroPool(strlen((char *)end)+strlen((char *)template)+1);
if (!full_path) {
FreePool(template);
return FALSE;
}
memcpy(full_path, end, strlen(end));
memcpy(full_path, end, strlen((char *)end));
end = (CHAR8 *)strrchr((char *)full_path, '/');
if (!end)
end = (CHAR8 *)full_path;
memcpy(end, template, strlen(template));
end[strlen(template)] = '\0';
memcpy(end, template, strlen((char *)template));
end[strlen((char *)template)] = '\0';

FreePool(template);
return TRUE;
Expand Down Expand Up @@ -284,8 +284,8 @@ static EFI_STATUS parseDhcp4(CHAR8 *name)

while (name[template_len++] != '\0');
template = (CHAR8 *)AllocatePool((template_len + 1) * sizeof (CHAR8));
translate_slashes(template, name);
template_len = strlen(template) + 1;
translate_slashes((char *)template, (char *)name);
template_len = strlen((char *)template) + 1;

if(pxe->Mode->ProxyOfferReceived) {
/*
Expand All @@ -305,7 +305,7 @@ static EFI_STATUS parseDhcp4(CHAR8 *name)
pkt_v4 = &pxe->Mode->PxeReply.Dhcpv4;
}

INTN dir_len = strnlen((CHAR8 *)pkt_v4->BootpBootFile, 127);
INTN dir_len = strnlen((char *)pkt_v4->BootpBootFile, 127);
INTN i;
UINT8 *dir = pkt_v4->BootpBootFile;

Expand All @@ -323,7 +323,7 @@ static EFI_STATUS parseDhcp4(CHAR8 *name)
}

if (dir_len > 0) {
strncpy(full_path, (CHAR8 *)dir, dir_len);
strncpy((char *)full_path, (char *)dir, dir_len);
if (full_path[dir_len-1] == '/' && template[0] == '/')
full_path[dir_len-1] = '\0';
/*
Expand All @@ -338,7 +338,7 @@ static EFI_STATUS parseDhcp4(CHAR8 *name)
}
if (dir_len == 0 && dir[0] != '/' && template[0] == '/')
template_ofs++;
strcat(full_path, template + template_ofs);
strcat((char *)full_path, (char *)template + template_ofs);
memcpy(&tftp_addr.v4, pkt_v4->BootpSiAddr, 4);

FreePool(template);
Expand Down
Loading