mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
GCC 17 (upcoming release) is updating the type of __stack_chk_guard from a void * to a uintptr_t. This is only a type change, not a size change. However, it does cause the GCC 17 build to fail because of the type mismatch. uintptr_t is defined as unsigned long, which is not a type edk2 defines. It has the same size as UINTN on a given system, but on 64 bit systems we have the same type issue because UINTN is defined as unsigned long long, not unsigned long. To work around this and avoid defining a new type in edk2, use the compiler built in __UINTPTR_TYPE__ which is the underlying definition in GCC. This is a backwards compatible change with previous versions of GCC and CLANGDWARF but also fixes the upcoming definition change for GCC 17. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
40 lines
1,020 B
C
40 lines
1,020 B
C
/** @file
|
|
Provides the required functionality for handling stack
|
|
cookie check failures in GCC.
|
|
|
|
Copyright (c) Microsoft Corporation.
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
**/
|
|
|
|
#include <Base.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/StackCheckLib.h>
|
|
#include <Library/StackCheckFailureHookLib.h>
|
|
|
|
/**
|
|
Triggers an interrupt using the vector specified by PcdStackCookieExceptionVector
|
|
**/
|
|
VOID
|
|
TriggerStackCookieInterrupt (
|
|
VOID
|
|
);
|
|
|
|
__UINTPTR_TYPE__ __stack_chk_guard = (__UINTPTR_TYPE__)STACK_COOKIE_VALUE;
|
|
|
|
/**
|
|
This function gets called when a gcc/clang generated stack cookie fails. This implementation calls into a platform
|
|
failure hook lib and then triggers the stack cookie interrupt.
|
|
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
__stack_chk_fail (
|
|
VOID
|
|
)
|
|
{
|
|
DEBUG ((DEBUG_ERROR, "Stack cookie check failed at address 0x%llx!\n", RETURN_ADDRESS (0)));
|
|
StackCheckFailureHook (RETURN_ADDRESS (0));
|
|
TriggerStackCookieInterrupt ();
|
|
}
|