Skip to content

Commit

Permalink
Add __fastfail for x64 MSVC 2010 compilation of freeldr + related ASM…
Browse files Browse the repository at this point in the history
… 'fixes'.

Addendum of commit 9122687.
  • Loading branch information
HBelusca committed Oct 14, 2023
1 parent d0fa554 commit 7c5fa6f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
41 changes: 41 additions & 0 deletions boot/freeldr/freeldr/freeldr_i386.msvc.lds
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,47 @@

#include <asm.inc>


#ifdef _M_AMD64
_TEXT SEGMENT 'CODE'

/*
__declspec(noreturn) __forceinline
void __fastfail(unsigned int Code) // __cdecl
*/
PUBLIC __fastfail
__fastfail:

#ifdef _M_IX86 // _X86_
push ebp
mov ebp, esp
mov ecx, [ebp+8/*Code*/]
#elif defined(_M_AMD64)
/* First argument already in rcx */
#else
#error Unsupported architecture
#endif

int HEX(29)

/* Never return */
cli
die:
hlt
jmp die

#ifdef _M_IX86 // _X86_
pop ebp
#elif !defined(_M_AMD64)
#error Unsupported architecture
#endif
ret

_TEXT ENDS
#endif // _M_AMD64



/*
#pragma bss_seg(".bss")
// __declspec(allocate(".bss"))
Expand Down
5 changes: 5 additions & 0 deletions sdk/include/asm/asm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef __ASM_INC__
#define __ASM_INC__

// /* Makes "x" a global variable or label */
// #define EXTERN(x) .global x; x:

/*
* Common definitions for the FPO macro.
* See https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_fpo_data
Expand Down Expand Up @@ -99,7 +102,9 @@ ENDM

.code32 MACRO
.code
#ifdef _M_IX86
.586P
#endif
ENDM

.code16 MACRO
Expand Down
2 changes: 2 additions & 0 deletions sdk/include/crt/msc/intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void __fastfail(unsigned int Code)
}
}
#else
__declspec(noreturn) __forceinline
void __fastfail(unsigned int Code);
#endif // defined(_M_IX86)
#endif
Expand Down Expand Up @@ -356,6 +357,7 @@ void _sgdt(void *Destination)
}
}
#else
__forceinline
void _sgdt(void *Destination);
#endif // defined(_M_IX86)
#endif
Expand Down

0 comments on commit 7c5fa6f

Please sign in to comment.