<div dir="ltr"><div>I'm not sure I know enough about COFF and debug directories to know how useful this feature will be, but I do have some thoughts on the syntax, based on my experience working with the ELF part of yaml2obj. From reading the spec you linked, I would think it might look something like the following:</div><div><br></div><div>DebugDirectory:</div><div> - Characteristics: 1234 # Optional, defaults to 0. Contains value to write in Characteristics field.</div><div> TimeDateStamp: 4321 # Optional, defaults to 0(?).</div><div> MajorVersion: 1 # Optional, defaults to 0.</div><div> MinorVersion: 2 # Optional, defaults to 0.</div><div> Data: # Required<br></div><div> - Type: 12 # Required, contains the value of the Type field, can be written as raw number or enum value (see how ELF works for various fields).</div><div> Size: 1111 # Optional, derives size from data field, if not specified.</div><div> Address: 2222 # Optional, defaults to 0(?)</div><div> Pointer: 3333 # Optional, defaults to wherever yaml2obj chooses to place the data.</div><div> RawData: '12345678abcdef0' # Optional byte string (see 'Content' fields for ELF sections). Defaults to empty if not specified.</div><div> ## The following fields are all defined based on the Type value (for unrecognised values, by default only RawData is allowed). Cannot be mixed with RawData field. Only those actually required need to be implemented up front.<br></div><div> ExtendedDLLCharacteristics: # Used for
IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS
</div><div>
- ... # Fields related to DLL Characteristics</div><div> FPOInfo: # Used for
IMAGE_DEBUG_TYPE_FP
</div><div> - ...<br></div><div> - ... # FPO Information array</div><div> ...</div><div><br></div><div>Does this make sense? It's somewhat similar to how Sections are defined in ELF yaml2obj.</div><div><br></div><div>James<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Mar 2020 at 03:10, Penzin, Petr <<a href="mailto:petr.penzin@intel.com">petr.penzin@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_3365831823353643412WordSection1">
<p class="gmail-m_3365831823353643412FirstParagraph"><i>Spoiler:</i> the following only applies to Windows binary format handling.<u></u><u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText">Potential for extending <span class="gmail-m_3365831823353643412VerbatimChar">yaml2obj</span> to support COFF
<a href="https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#debug-directory-image-only" target="_blank">
debug directories</a> recently came up during <a href="https://reviews.llvm.org/D70606#1873185" target="_blank">
a code review</a>. Currently, its <a href="http://llvm.org/docs/yaml2obj.html#coff-syntax" target="_blank">
COFF syntax</a> allows for specifying section data, but not debug directories, that's why
<span class="gmail-m_3365831823353643412VerbatimChar">llvm-readobj</span> tests which depend on debug directory contents use pre-built executable images instead of
<span class="gmail-m_3365831823353643412VerbatimChar">yaml2obj</span>.<u></u><u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText">It is possible to extend the tool, but first I would be interested in gathering feedback on usability of this, especially on potential uses of this change. It looks like porting
<span class="gmail-m_3365831823353643412VerbatimChar">llvm-readobj</span> tests for codeview would depend on this and also
<a href="https://reviews.llvm.org/D70606" target="_blank">D70606</a> is introducing another possible use. But I am not sure how trivial would the codeview effort, would it be worth it or is it easier to leave things as they are for now?<u></u><u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText">In case this is interesting, base Yaml syntax for COFF debug directory may look like this (enum values representing
<a href="https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#debug-type" target="_blank">
COFF Debug Types</a>):<u></u><u></u></p>
<p class="gmail-m_3365831823353643412SourceCode"><span class="gmail-m_3365831823353643412VerbatimChar">DebugDirectory:</span><br>
<span class="gmail-m_3365831823353643412VerbatimChar"> - Type: [ {type: str, enum: [...]}, {type: int} ]</span><br>
<span class="gmail-m_3365831823353643412VerbatimChar"> - DebugDirectoryData: {type: str}</span><u></u><u></u></p>
<p class="gmail-m_3365831823353643412FirstParagraph">This may have to be further specialized for sub-categories, specifically codeview.<u></u><u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText"><u></u> <u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText">Best,<u></u><u></u></p>
<p class="gmail-m_3365831823353643412MsoBodyText">Petr<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</blockquote></div>