The open coded varargs implementation that performs pointer arithmetic on the last named parameter of a function to calculate the addresses of variadic parameters and subsequently derefences them is fragile, and break spectacularly when used under GCC with optimization enabled. So explicitly disallow this combination.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <[email protected]> --- MdePkg/Include/Base.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index e03fa8239284..95400f993e6b 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -635,6 +635,11 @@ typedef __builtin_va_list VA_LIST; #endif #else + +#if defined(__GNUC__) && defined(__OPTIMIZE__) +#error This VA_LIST implementation is incompatible with GCC optimization +#endif + /// /// Variable used to traverse the list of arguments. This type can vary by /// implementation and could be an array or structure. -- 1.9.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

