Re: Having problems when trying to instrument all code of a specific UEFI driver (including the library code)
For ASan and MSan I just add the relevant flags to CC_FLAGS and sometimes I have to add custom flags. I must mention that I enabled Windows as a target for MSan, this wasn't the case for my LLVM version.
[BuildOptions]For ASan I had to remove link-time optimizations, due to errors related to comdat sections which I could not fix. The more difficult part for me is setting up the shadow memory and implementing enough of the sanitizer runtime in order for it to work.
Also, some functions have other dependencies which are out of the instrumentation still, for instance :
InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);This initializes the gSmst variable, with the function SmmBase2GetSmstLocation()  in PiSmmIpl.c, and will now cause MSan to error on the ASSERT() call. I still have to work out these cases. That said, it is still very much a work in progress and it is all a bit hacky.