Re: Having problems when trying to instrument all code of a specific UEFI driver (including the library code)


Andrew Fish
 

Mick,

Are you trying to do runtime or static analysis? That would help guide my answers.

What your are are doing in the INF file you can generally do in the DSC file too per driver. There is the concept of override of things per single INF file entry in the DSC [1]. This syntax include <BuildOptions> and pointing at alternate libraries for just those drivers. If you have common libs that you need 2 flavors of you could fork a copy and point to those from the per driver entries in the DSC, for the drivers that you care about. Conceptually you could fork a DSC file, or !if def your DSC file to support multiple modes (normal and analysis) of build.

We added the overrides to the DSC file so your platform could override things without having to override the driver source (or INF) that you might have gotten from a vendor. Thinking act would be easier to maintain over the long run, and easier to merge changes from updates to the vendor code.


[1] https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L937

ShellPkg/Application/Shell/Shell.inf {
<LibraryClasses>
ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
!if $(NETWORK_IP6_ENABLE) == TRUE
NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
!endif
HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf

<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
}

Anyway always happy to help folks brainstorm on the easiest way to do things. Sometimes with the edk2 it is not always obvious….

Thanks,

Andrew Fish

On Apr 10, 2021, at 5:19 AM, mick21@live.nl wrote:

Hi Andrew,

Thank you for your reply, I didn't know this report option existed!

If you add the --report-file=REPORTFILE to the build command when you compile it will generate a report about your build. I think the info in this report can help you out.
I have looked at the output of the report file, though, it did provide some clarity on what libraries are included, it seemed to match with the "OUTPUT/static_library_files.lst" library listing that is created when a driver is built.

I found that I can change the file paths in the GNUmakefile of a UEFI driver (for example Build/OvmfX64/DEBUG_CLANGPDB/X64/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm/GNUmakefile). By changing the STATIC_LIBRARY_FILES or CC_FLAGS variables for a specific UEFI driver or library, I am maybe able to compile certain drivers with other library code than others, as the build script doesn't seem to overwrite the GNUmakefile file when I change it. I hope this will work, despite it being not so elegant.

Thank you,

Mick

Join discuss@edk2.groups.io to automatically receive all group messages.