I am building a UEFI DXE/EFI (UDK2018) driver (on Windows, using VS2017) into which I need to link an existing object (.obj
) file. I'm fairly certain this should be done from inside the INF file, but I don't see anything specific about object file inclusion in the EDK2 documentation. I did find these two examples for reference:
https://github.com/tianocore/edk2/blob/UDK2018/StdLib/LibC/LibC.inf#L96
[Binaries.X64]
LIB|Twofish_x64.obj|*
LIB|Camellia_aesni_x64.obj|*
LIB|Camellia_x64.obj|*
https://github.com/veracrypt/VeraCrypt-DCS/blob/master/Library/VeraCryptLib/VeraCryptLib.inf#L79
[Binaries.IA32]
LIB|Main/Ia32/ftol2.obj|*|MSFT
However, even with these as reference (which I assume work), I am unable to figure out the right way to configure the INF file to get the object_files.lst
to include the .obj
. (The actual error is, of course, an unresolved external. -- I have verified that if I manually add the .obj
file to the object_files.lst
, the link of the .efi
driver succeeds.)
Without the .obj
, my INF looks like this:
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SampleDxe
FILE_GUID = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = SampleDxe_Main
[Sources]
SampleDXE.c
SampleDXE.h
SampleProtocol.h
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
UefiDriverEntryPoint
BaseMemoryLib
UefiLib
DebugLib
BaseLib
PcdLib
DevicePathLib
[Depex]
TRUE
I have tried inserting the following sections between the [Sources]
and [Packages]
sections, without any success:
[Binaries]
LIB|path/to/my/file.obj|*|MSFT
[Binaries.X64]
LIB|path/to/my/file.obj|*|MSFT
[Binaries]
LIB|path/to/my/file.obj|*
[Binaries.X64]
LIB|path/to/my/file.obj|*
[Binaries]
LIB|path/to/my/file.obj
[Binaries.X64]
LIB|path/to/my/file.obj
(.obj
placed with source files)
[Binaries]
LIB|file.obj|*|MSFT
[Binaries.X64]
LIB|file.obj|*|MSFT
[Binaries]
LIB|file.obj|*
[Binaries.X64]
LIB|file.obj|*
[Binaries]
LIB|file.obj
[Binaries.X64]
LIB|file.obj
I have also modified the INF_VERSION to later versions (0x0001001A, 1.25, etc.), although not with every combination of the sections above.
I also believe I could create an intermediate .lib
file, but if I'm going to do that, there are other, more direct options that make sense in my case. The use of the stand-alone object file would be preferable, simpler, and more cooperative with other pieces of the larger project, and the examples above sure seem to indicate this should be possible.
Can anyone tell me how I can get a pre-existing object file to link into the DXE/EFI (presumably by getting it added to the object_files.lst
)?
Well, I should have figured that after several days of trying, the answer would appear just after I posted this question...and it did.
I was first directed to the default EDK\Conf\build_rule.txt
file, and looking through there, I found a build rule for .obj
files (as well as .o
files)! This looked a lot like a plain copy (well, actually adding it to the same list as the output of .c
/.cpp
/.asm
/etc. files), so the idea was suggested to try placing the .obj
file into the [Sources]
section. I had not seen that anywhere else, so I tried, and sure enough, it worked:
[Sources]
SampleDXE.c
SampleDXE.h
SampleProtocol.h
path/to/my/file.obj