Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a PE file section to indicate that the timestamp isn't a real timestamp #5940

Closed
gafter opened this issue Oct 13, 2015 · 5 comments
Closed
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time.
Milestone

Comments

@gafter
Copy link
Member

gafter commented Oct 13, 2015

With the /deterministic flag, we place some bits into the PE file's timestamp field that isn't a timestamp. So that tools can tell that it isn't really a timestamp, we currently set the upper bit. We are also specifying an additional PE debug directory entry that, if present, is a specific indicator that the timestamp field contains a non-timestamp. We should produce this PE section when compiling to produce a deterministic output.

The following is the closest thing we have to a spec. I hope it makes sense:

So here is the proposal on how we determine whether time stamp field in a PE actually store a real time date stamp.

Like how we add incremental LTCG signature or COFF group info into PE, we can just define a new debug directory entry type.

Here are all debug directory entry types that have already been defined:

#define IMAGE_DEBUG_TYPE_UNKNOWN          0
#define IMAGE_DEBUG_TYPE_COFF             1
#define IMAGE_DEBUG_TYPE_CODEVIEW         2
#define IMAGE_DEBUG_TYPE_FPO              3
#define IMAGE_DEBUG_TYPE_MISC             4
#define IMAGE_DEBUG_TYPE_EXCEPTION        5
#define IMAGE_DEBUG_TYPE_FIXUP            6
#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC      7
#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC    8
#define IMAGE_DEBUG_TYPE_BORLAND          9
#define IMAGE_DEBUG_TYPE_RESERVED10       10
#define IMAGE_DEBUG_TYPE_CLSID            11
#define IMAGE_DEBUG_TYPE_VC_FEATURE       12
#define IMAGE_DEBUG_TYPE_POGO             13
#define IMAGE_DEBUG_TYPE_ILTCG            14
#define IMAGE_DEBUG_TYPE_MPX              15

We can add a new one:

#define IMAGE_DEBUG_TYPE_NO_TIMESTAMP  16

Here is what debug directory looks like for ntdll.dll:

        Time Type       Size      RVA  Pointer
    -------- ------ -------- -------- --------
    5609EE9F cv           22 0011DFE4   11AFE4    Format: RSDS, {FBA98142-7084-4ADE-9DDE-27DC9D6986ED}, 1, ntdll.pdb
    5609EE9F pogo        590 0011E01C   11B01C    50475500 (PGU)

With repurposed time date stamp field in PE, the above will change to:

        Time Type       Size      RVA  Pointer
    -------- ------ -------- -------- --------
    5609EE9F cv           22 0011DFE4   11AFE4    Format: RSDS, {FBA98142-7084-4ADE-9DDE-27DC9D6986ED}, 1, ntdll.pdb
    5609EE9F pogo        590 0011E01C   11B01C    50475500 (PGU)
    5609EE9F (16)        0  00000000   0 

The last entry will indicate the time date stamp field in this binary doesn't represent a real time date stamp.

@gafter gafter added Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. labels Oct 13, 2015
@gafter gafter added this to the 1.1 milestone Oct 13, 2015
@gafter
Copy link
Member Author

gafter commented Oct 13, 2015

@jaredpar @tmat @dotnet/roslyn-compiler

@gafter
Copy link
Member Author

gafter commented Oct 14, 2015

@tmat Since we generate none of these sections today (I think)... do you have any idea what this spec means?

@tmat
Copy link
Member

tmat commented Oct 14, 2015

We generate "cv". I don't think we generate any other, but I'd need to double check. We only generate CODEVIEW entry (cv)

@tmat
Copy link
Member

tmat commented Oct 14, 2015

We should also make sure that the Debug Directory is fully documented.

//cc @vargaz

@gafter
Copy link
Member Author

gafter commented Oct 19, 2015

The debug directory itself is specified in the PE/COFF, section 5.1.1. (pages 71-72):
https://msdn.microsoft.com/en-us/windows/hardware/gg463119.aspx

The IMAGE_DEBUG_TYPE_REPRO is a new value for Debug Type.

(that info was sent to me by private email from @tmat)

@gafter gafter added 4 - In Review A fix for the issue is submitted for review. and removed 3 - Working labels Oct 20, 2015
@gafter gafter closed this as completed in f82ffe4 Oct 26, 2015
tannergooding added a commit that referenced this issue Oct 26, 2015
* origin/stabilization:
  Fix closed build break
  Responded to PR feedback
  Remove PumpingWait
  Ensure that the new deterministic-timestamp section is generated in non-debug scenarios
  Correct referenced version of System.Reflection.Metadata
  Properly map snapshot points up when testing if adornments should be visible or not.
  Enable deploying of extensions if you have Update 1 installed
  Remove left-over package.config refs
  Replace mocks of the IVsExtension manager with Moq-based mocks
  Remove old-style NuGet restore support
  Update project.jsons to support building with Update 1.
  Mark class library projects that don't need to deploy dependencies as such
  Add a PE file section fir determinism to indicate that the timestamp isn't a real timestamp Fixes #5940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time.
Projects
None yet
Development

No branches or pull requests

2 participants