[llvm] [llvm-readobj][COFF] Add support for more CET and hotpatch flags (PR #150967)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 02:05:45 PDT 2025


mstorsjo wrote:

> With a combination of MSVC linker flags and a special stub, the binary being commited to the repo can be made much smaller (around ~5kb).
> 
> * `/ENTRY:raw_main`: Avoid CRT wrappers being linked
> * `/STUB:stub`: A specifically crafted DOS stub (minimum possible size of 64 bytes -- which isless than the default)
>   
>   * ```
>     4D 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>     ```
> * `/NOCOFFGRPINFO`: No POGO metadata in debug directory
> * `/EMITTOOLVERSIONINFO:NO`: No Rich header
> * `/EMITPOGOPHASEINFO`: Eliminates ILTCG debug directory entry
> * `/NOVCFEATURE`: Eliminate `IMAGE_DEBUG_TYPE_VC_FEATURE` debug directory (contains tool version data but different one from Rich)
> * `/MANIFEST:NO`: No manifest.xml being made in `.rsrc`

Nice, and thanks for documenting it in the test scripts!

> > Instead of adding a handful of binaries, one for checking each individual flag, can we have one binary with as many flags set as possible within one file? Or are these flags mutually exclusive? (Or perhaps we don't need test coverage for every single possible flag, as long as we test some of them?)
> 
> None of those flags are mutually exclusive. I will squash all those new `has-*.exe` into the one and will add comments on how-to generate the binary. But we'd probably want to keep every test file separated (or should I squash `has-*.test` into the one as well?).

No, there's very little value to keeping multiple separate test files for just checking individual flags here; as we have one input file and one command, just check all flags in one test file. Other than that, this is starting to look good, thanks!

https://github.com/llvm/llvm-project/pull/150967


More information about the llvm-commits mailing list