Generate debug symbol with Xcode8

Quick patch to make DumpEfiCalls works with OpenCore.
This commit is contained in:
jief666 2020-09-14 15:56:48 +03:00
parent f4b3445135
commit e7fe794c4d
6 changed files with 44 additions and 12 deletions

View File

@ -425,7 +425,7 @@
@"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff @"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
@"echo" [MTOC] $(MODULE_NAME) @"echo" [MTOC] $(MODULE_NAME)
# create symbol file for GDB debug # create symbol file for GDB debug
#@-$(DSYMUTIL) ${src} @-$(DSYMUTIL) ${src}
@"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS) @"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
@$(CP) ${dst} $(DEBUG_DIR) @$(CP) ${dst} $(DEBUG_DIR)
@$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi @$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi

View File

@ -2503,13 +2503,13 @@ RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64
*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h *_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -DNO_MSABI_VA_FUNCS DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -DNO_MSABI_VA_FUNCS
# -mno-implicit-float # -mno-implicit-float
# -Wno-varargs # -Wno-varargs
# -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang # -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
# $(PLATFORM_FLAGS) # $(PLATFORM_FLAGS)
NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -DNO_MSABI_VA_FUNCS NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -DNO_MSABI_VA_FUNCS
# -mno-implicit-float # -mno-implicit-float
# -Wno-varargs # -Wno-varargs
# -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang # -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
@ -2577,7 +2577,7 @@ RELEASE_XCODE8_X64_ASM_FLAGS = -c -x assembler -arch x86_64
*_XCODE8_*_PP_FLAGS = DEF(GCC_PP_FLAGS) *_XCODE8_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_XCODE8_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h *_XCODE8_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
DEBUG_XCODE8_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare "-DNO_MSABI_VA_FUNCS" -mno-red-zone DEBUG_XCODE8_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare "-DNO_MSABI_VA_FUNCS" -mno-red-zone
# -Wno-varargs # -Wno-varargs
# -mno-implicit-float # -mno-implicit-float
RELEASE_XCODE8_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare "-DNO_MSABI_VA_FUNCS" -mno-red-zone RELEASE_XCODE8_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare "-DNO_MSABI_VA_FUNCS" -mno-red-zone

View File

@ -13,6 +13,8 @@
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Library/PeCoffLib.h> #include <Library/PeCoffLib.h>
#include <Library/PrintLib.h>
#include <Library/SerialPortLib.h>
#include <Protocol/LoadedImage.h> #include <Protocol/LoadedImage.h>
//#include <Protocol/Runtime.h> //#include <Protocol/Runtime.h>
@ -136,6 +138,27 @@ DumpUefiCallsEntrypoint (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
#ifdef JIEF_DEBUG
{
EFI_LOADED_IMAGE* LoadedImage;
EFI_STATUS Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
if ( !EFI_ERROR(Status) ) {
CHAR8 buf[50];
AsciiSPrint(buf, sizeof(buf)-1, "DumpEfiCalls : Image base = 0x%X\n", (UINTN)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
SerialPortWrite((UINT8*)buf, AsciiStrLen(buf));
AsciiSPrint(buf, sizeof(buf)-1, "LoadedImage.DeviceHandle = 0x%X\n", (UINTN)LoadedImage->DeviceHandle); // do not change, it's used by grep to feed the debugger
SerialPortWrite((UINT8*)buf, AsciiStrLen(buf));
}
// if ( !EFI_ERROR(Status) ) DBG("DumpEfiCalls : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
gBS->Stall(3500000); // to give time to gdb to connect
// gBS->Stall(0500000); // to give time to gdb to connect
// PauseForKey(L"press\n");
}
#endif
// //
// Override StartImage // Override StartImage
// other overrides will be done from there when boot loader is started // other overrides will be done from there when boot loader is started

View File

@ -41,6 +41,8 @@
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
[Components] [Components]
Protocols/DumpUefiCalls/DumpUefiCalls.inf Protocols/DumpUefiCalls/DumpUefiCalls.inf

View File

@ -81,6 +81,13 @@ FsGetSelfFileSystem(VOID)
if (gLoadedImage == NULL) { if (gLoadedImage == NULL) {
return NULL; return NULL;
} }
if( gLoadedImage->DeviceHandle != NULL ) return FsGetFileSystem(gLoadedImage->DeviceHandle);
EFI_STATUS Status = gBS->HandleProtocol(gLoadedImage->ParentHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &gLoadedImage);
if (Status != EFI_SUCCESS) {
Print(L"FsGetLoadedImage: HandleProtocol(gEfiLoadedImageProtocolGuid) = %r\n", Status);
return NULL;
}
return FsGetFileSystem(gLoadedImage->DeviceHandle); return FsGetFileSystem(gLoadedImage->DeviceHandle);
} }

View File

@ -53,7 +53,7 @@ case `uname` in
echo DumpUefiCalls requires Snow Leopard or later OS echo DumpUefiCalls requires Snow Leopard or later OS
exit 1 exit 1
else else
TARGET_TOOLS=XCODE5 TARGET_TOOLS=XCODE8
fi fi
;; ;;
Linux*) Linux*)
@ -80,12 +80,12 @@ do
if [[ $arg == cleanall ]]; then if [[ $arg == cleanall ]]; then
make -C $WORKSPACE/BaseTools clean make -C $WORKSPACE/BaseTools clean
build -p $WORKSPACE/Clover/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean build -p $WORKSPACE/Protocols/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
exit $? exit $?
fi fi
if [[ $arg == clean ]]; then if [[ $arg == clean ]]; then
build -p $WORKSPACE/Clover/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean build -p $WORKSPACE/Protocols/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
exit $? exit $?
fi fi
done done
@ -95,6 +95,6 @@ done
# Build the edk2 ShellPkg # Build the edk2 ShellPkg
# #
echo Running edk2 build for DumpUefiCalls echo Running edk2 build for DumpUefiCalls
build -p $WORKSPACE/Clover/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 build -p $WORKSPACE/Protocols/DumpUefiCalls/DumpUefiCalls.dsc -a $PROCESSOR -t $TARGET_TOOLS -b DEBUG -n 3
exit $? exit $?