[edk2-devel] EmulatorPkg and the state of DlLoadImage()

Marvin Häuser mhaeuser at posteo.de
Fri Jul 30 10:37:56 UTC 2021


Good day everyone,

I'm currently refining the port of EmulatorPkg to my new PE/COFF loader 
library instance.
In the process, I found the function DlOpenImage() [1], which loads UEFI 
Images via the OS loader to utilise its symbol loading capability. 
Theoretically, this should e.g. allow arbitrary debuggers using the OS 
APIs to symbolise the backtrace.

macOS: The function seems to be unused entirely. [2]

Linux: On my system running Fedora 34, the function neither works 
out-of-the-box, nor after significant time of trying to fix it. The 
first issue is that it only proceeds if the Image has a PDB path with 
".pdb" extension [3], while the GCC5 toolchain generates Images with 
".dll" files for PDB paths (see errors below). Once this is resolved, 
there is an error message indicating insufficient Image section alignment:

[...]/Build/EmulatorX64/DEBUG_GCC5/X64/MdeModulePkg/Universal/EbcDxe/EbcDxe/DEBUG/EbcDxe.dll: 
ELF load command alignment not page-aligned

Resolving this yields an error that executable files cannot be loaded 
dynamically:

[...]/Build/EmulatorX64/DEBUG_GCC5/X64/MdeModulePkg/Core/Pei/PeiMain/DEBUG/PeiCore.dll: 
cannot dynamically load executable

With my very limited knowledge about Linux and ELF I tried the naive 
approach of building the Images as shared (hoping it would be similar to 
DLLs, which are built on Windows), but this just silently crashes.

So my questions are:
1) Does this code currently work for anyone?
2) Does anyone use a debugging setup that is incompatible with Images 
loaded by EDK II rather than the OS?
3) Are the issues above known and planned to be fixed?

Thank you for your time!

Best regards,
Marvin


[1]
https://github.com/tianocore/edk2/blob/be282b14938846960cce30825a9fe762e14ca8c9/EmulatorPkg/Unix/Host/Host.c#L1065-L1113

[2]
https://github.com/tianocore/edk2/blob/be282b14938846960cce30825a9fe762e14ca8c9/EmulatorPkg/Unix/Host/Host.c#L1071-L1073

[3]
https://github.com/tianocore/edk2/blob/be282b14938846960cce30825a9fe762e14ca8c9/EmulatorPkg/Unix/Host/Host.c#L1084-L1086
https://github.com/tianocore/edk2/blob/be282b14938846960cce30825a9fe762e14ca8c9/EmulatorPkg/Unix/Host/Host.c#L1003-L1026



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78435): https://edk2.groups.io/g/devel/message/78435
Mute This Topic: https://groups.io/mt/84547497/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list