From 865c7e1722d96b37ef2684fc76d8daecc29c1f21 Mon Sep 17 00:00:00 2001 From: eric_tian Date: Mon, 30 Jun 2008 06:25:43 +0000 Subject: Provide source level debug ability in *unix environment. [Background] The UnixPkg provide an simulator in *unix. To support source level debug, we need force all modules be built as ELF shard objects and dynamically load all of modules using dlopen(). For peicore, peim and dxecore, we provide a wrapper to provide PeCoffLoader interface git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5382 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Conf/tools_def.template | 3 ++- UnixPkg/Sec/SecMain.c | 15 +++++++++++++++ UnixPkg/UnixPkg.dsc | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 1b2e44c85f..76cbec5152 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -504,7 +504,8 @@ RELEASE_WINDDK3790x1830_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT *_ELFGCC_*_MAKE_FLAGS = -i *_ELFGCC_IA32_CC_FLAGS = -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -*_ELFGCC_*_DLINK_FLAGS = -melf_i386 -nostdlib -n -q -Ttext 0x220 --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) +*_ELFGCC_*_DLINK_FLAGS = -melf_i386 -nostdlib --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) +#*_ELFGCC_*_DLINK_FLAGS = -melf_i386 -nostdlib -n -q -Ttext 0x220 --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) *_ELFGCC_*_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h *_ELFGCC_*_PP_FLAGS = -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h *_ELFGCC_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include AutoGen.h diff --git a/UnixPkg/Sec/SecMain.c b/UnixPkg/Sec/SecMain.c index a6da20b135..bfa44e7a17 100644 --- a/UnixPkg/Sec/SecMain.c +++ b/UnixPkg/Sec/SecMain.c @@ -983,6 +983,21 @@ SecNt32PeCoffRelocateImage ( (unsigned long)ImageContext->ImageAddress, (unsigned long)ImageContext->EntryPoint); + Handle = dlopen(ImageContext->PdbPointer, RTLD_NOW); + + if (Handle) { + Entry = dlsym(Handle, "_ModuleEntryPoint"); + } else { + printf("%s\n", dlerror()); + } + + if (Entry != NULL) { + ImageContext->EntryPoint = Entry; + printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry); + } else { + printf("Could not find _ModuleEntryPoint Entry, Module may be built error\n"); + } + SecUnixLoaderBreak (); return Status; diff --git a/UnixPkg/UnixPkg.dsc b/UnixPkg/UnixPkg.dsc index 2ff9efca2b..7db8d82fc1 100644 --- a/UnixPkg/UnixPkg.dsc +++ b/UnixPkg/UnixPkg.dsc @@ -492,5 +492,5 @@ } [BuildOptions] - #DEBUG_*_IA32_DLINK_FLAGS = --shared + DEBUG_*_IA32_DLINK_FLAGS = --shared *_*_IA32_CC_FLAGS = -idirafter/usr/include -- cgit v1.2.3