Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ef0949c
Copy sources from Versions.props to NuGet.config (#7191)
Jul 11, 2019
0c9ccae
Only check distinct errors (#7140)
forki Jul 11, 2019
598db3e
Use 1-based column numbers in tests (#7141)
forki Jul 11, 2019
fe0426a
Merge pull request #7197 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 11, 2019
bf1055c
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 11, 2019
13596c4
Merge pull request #7201 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 12, 2019
da432e1
Better record and value formatting in tools (#7021)
cartermp Jul 12, 2019
660a545
fix portable PDBs for anon records (#7099)
dsyme Jul 12, 2019
9dc9d0e
fix portable PDBs for anon records (#7099)
dsyme Jul 12, 2019
60c915a
Moving ElseBranchHasWrongTypeTests over to NUnit (#7104)
forki Jul 12, 2019
869c2bb
Port tests for missing else branch to NUnit (#7209)
forki Jul 12, 2019
c80a0cb
Merge pull request #7208 from KevinRansom/cherrypickfix
KevinRansom Jul 12, 2019
2fabdaa
Merge pull request #7213 from dotnet/merges/master-to-release/dev16.3
brettfo Jul 12, 2019
59bfc83
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 12, 2019
8ab272a
Update dependencies from https://github.com/dotnet/arcade build 20190…
Jul 13, 2019
1ad5657
Merge pull request #7222 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 13, 2019
b7d5efd
Merge branch 'release/dev16.3' into merges/release/fsharp47-to-releas…
KevinRansom Jul 13, 2019
7780cab
Fix Supplementary Character / Surrogate Pair info (no code changes) (…
srutzky Jul 13, 2019
30cce45
Merge pull request #7228 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 14, 2019
0abf39c
Merge pull request #7223 from dotnet/merges/release/fsharp47-to-relea…
KevinRansom Jul 14, 2019
f9a8e2a
Update IlxGen.fs (#7227)
TIHan Jul 14, 2019
c79a8ab
Merge pull request #7225 from dotnet/darc-master-1d1b7b40-d7f9-4b9d-9…
KevinRansom Jul 14, 2019
ec8a424
Check for exit code in compiler tests (#7211)
forki Jul 14, 2019
c4dba1f
Moving AccessOfTypeAbbreviationTests over to NUnit (#7226)
sergey-tihon Jul 14, 2019
f720c73
Merge pull request #7230 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 14, 2019
75cef56
Moving ConstructorTests over to NUnit (#7236)
sergey-tihon Jul 15, 2019
c7cd220
[master] Update dependencies from dotnet/arcade (#7233)
dotnet-maestro[bot] Jul 15, 2019
0f24b3e
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 16, 2019
863ec25
Moving UpcastDowncastTests over to NUnit (#7229)
sergey-tihon Jul 16, 2019
c8bac72
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 17, 2019
6980587
Move ErrorMessages/NameResolution Tests to NUnit (#7237)
kMutagene Jul 17, 2019
4cf7b5b
Moving WarnExpressionTests over to NUnit (#7232)
sergey-tihon Jul 17, 2019
2f270f2
Merge pull request #7241 from dotnet/merges/master-to-release/dev16.3
KevinRansom Jul 17, 2019
650805b
move some error and warning tests to NUnit (#7244)
smcl Jul 17, 2019
375fd7c
Update dependencies from https://github.com/dotnet/arcade build 20190…
Jul 18, 2019
8d74566
Merge pull request #7253 from dotnet/darc-master-648345c2-b59c-4cd2-9…
KevinRansom Jul 19, 2019
c423de9
Move UnitGenericAbstractType To Nunit (#7257)
falfaddaghi Jul 19, 2019
4151eb2
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 19, 2019
bdb2b79
Moving TypeMismatchTests over to NUnit (#7250)
sergey-tihon Jul 19, 2019
b0e5926
publish pdbs in FSharp.Core.nupkg (#7255)
brettfo Jul 19, 2019
3e7b66d
Enable hash algorithm selection (#7252)
KevinRansom Jul 20, 2019
c70ead8
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 20, 2019
ff7b8ff
Improve netcore reference selection (#7263)
KevinRansom Jul 22, 2019
d53a38c
Moving Libraries Control tests to NUnit (#7234)
thinkbeforecoding Jul 22, 2019
5efa8a7
Member constraints and PrimitiveConstraints (#7210)
forki Jul 22, 2019
a7c68c3
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 23, 2019
a67156b
Merge branch 'master' into merges/release/dev16.2-to-master
brettfo Jul 24, 2019
0bd851b
Merge pull request #7272 from dotnet/merges/release/dev16.2-to-master
Jul 25, 2019
37970b4
fixes issue #6832 (#7259)
KevinRansom Jul 25, 2019
8e843ae
[master] Update dependencies from dotnet/arcade (#7269)
dotnet-maestro[bot] Jul 26, 2019
b3811d2
Merge pull request #7279 from dotnet/merges/release/fsharp47-to-relea…
Jul 26, 2019
ce483c0
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 26, 2019
969a9c4
Fix test assert (#7283)
KevinRansom Jul 26, 2019
2304ea4
merge
KevinRansom Jul 26, 2019
c03755f
disablewarningtests
KevinRansom Jul 27, 2019
d488458
Merge pull request #7266 from dotnet/merges/master-to-release/dev16.3
Jul 27, 2019
cc60ed6
code cleanup prior to optional interop improvements (#7276)
dsyme Jul 27, 2019
e72ded1
Update dependencies from https://github.com/dotnet/arcade build 20190…
dotnet-maestro[bot] Jul 27, 2019
bdb229c
Moving ClassesTests over to NUnit (#7264)
sergey-tihon Jul 27, 2019
8370ef6
Move Basic Constants to NUnit (#7262)
falfaddaghi Jul 27, 2019
3ce8eb1
Moved Don't Suggest Tests over to NUnit (#7288)
sergey-tihon Jul 29, 2019
868b76a
[master] Update dependencies from dotnet/arcade (#7287)
dotnet-maestro[bot] Jul 29, 2019
9c1a0d1
Fix langversion with multiple projects (#7293)
KevinRansom Jul 30, 2019
8edf449
Merge remote-tracking branch 'upstream/master' into merges/master-to-…
brettfo Jul 30, 2019
54f13f0
Merge pull request #7292 from dotnet/merges/master-to-release/dev16.3
Jul 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enable hash algorithm selection (#7252)
* Enable hash algorithm selection

* Feedback

* More feedback

* Revert "Feedback"

This reverts commit 6ab1b07.

* feedback
  • Loading branch information
KevinRansom authored Jul 20, 2019
commit 3e7b66dcd0bb58c575eda182a0aee24819577942
127 changes: 78 additions & 49 deletions src/absil/ilwrite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,7 +3025,8 @@ let generateIL requiredDataFixups (desiredMetadataVersion, generatePdb, ilg : IL
//=====================================================================
// TABLES+BLOBS --> PHYSICAL METADATA+BLOBS
//=====================================================================
let chunk sz next = ({addr=next; size=sz}, next + sz)
let chunk sz next = ({addr=next; size=sz}, next + sz)
let emptychunk next = ({addr=next; size=0}, next)
let nochunk next = ({addr= 0x0;size= 0x0; }, next)

let count f arr =
Expand Down Expand Up @@ -3516,7 +3517,7 @@ let writeBytes (os: BinaryWriter) (chunk: byte[]) = os.Write(chunk, 0, chunk.Len

let writeBinaryAndReportMappings (outfile,
ilg: ILGlobals, pdbfile: string option, signer: ILStrongNameSigner option, portablePDB, embeddedPDB,
embedAllSource, embedSourceList, sourceLink, emitTailcalls, deterministic, showTimes, dumpDebugInfo, pathMap)
embedAllSource, embedSourceList, sourceLink, checksumAlgorithm, emitTailcalls, deterministic, showTimes, dumpDebugInfo, pathMap)
modul normalizeAssemblyRefs =
// Store the public key from the signer into the manifest. This means it will be written
// to the binary and also acts as an indicator to leave space for delay sign
Expand Down Expand Up @@ -3565,7 +3566,7 @@ let writeBinaryAndReportMappings (outfile,
with e ->
failwith ("Could not open file for writing (binary mode): " + outfile)

let pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugEmbeddedPdbChunk, textV2P, mappings =
let pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugChecksumPdbChunk, debugEmbeddedPdbChunk, debugDeterministicPdbChunk, textV2P, mappings =
try

let imageBaseReal = modul.ImageBase // FIXED CHOICE
Expand Down Expand Up @@ -3670,42 +3671,61 @@ let writeBinaryAndReportMappings (outfile,
let pdbOpt =
match portablePDB with
| true ->
let (uncompressedLength, contentId, stream) as pdbStream =
generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic pathMap
let (uncompressedLength, contentId, stream, algorithmName, checkSum) as pdbStream =
generatePortablePdb embedAllSource embedSourceList sourceLink checksumAlgorithm showTimes pdbData pathMap

if embeddedPDB then Some (compressPortablePdbStream uncompressedLength contentId stream)
if embeddedPDB then
let uncompressedLength, contentId, stream = compressPortablePdbStream uncompressedLength contentId stream
Some (uncompressedLength, contentId, stream, algorithmName, checkSum)
else Some pdbStream

| _ -> None

let debugDirectoryChunk, next =
chunk (if pdbfile = None then
0x0
else if embeddedPDB && portablePDB then
sizeof_IMAGE_DEBUG_DIRECTORY * 2
let debugDirectoryChunk, next =
chunk (if pdbfile = None then
0x0
else
sizeof_IMAGE_DEBUG_DIRECTORY
sizeof_IMAGE_DEBUG_DIRECTORY * 2 +
(if embeddedPDB then sizeof_IMAGE_DEBUG_DIRECTORY else 0) +
(if deterministic then sizeof_IMAGE_DEBUG_DIRECTORY else 0)
) next

// The debug data is given to us by the PDB writer and appears to
// typically be the type of the data plus the PDB file name. We fill
// this in after we've written the binary. We approximate the size according
// to what PDB writers seem to require and leave extra space just in case...
let debugDataJustInCase = 40
let debugDataChunk, next =
let debugDataChunk, next =
chunk (align 0x4 (match pdbfile with
| None -> 0
| Some f -> (24
+ System.Text.Encoding.Unicode.GetByteCount f // See bug 748444
+ debugDataJustInCase))) next

let debugEmbeddedPdbChunk, next =
let streamLength =
match pdbOpt with
| Some (_, _, stream) -> int stream.Length
| None -> 0
chunk (align 0x4 (match embeddedPDB with
| true -> 8 + streamLength
| _ -> 0 )) next
let debugChecksumPdbChunk, next =
chunk (align 0x4 (match pdbOpt with
| Some (_, _, _, algorithmName, checkSum) ->
let alg = System.Text.Encoding.UTF8.GetBytes(algorithmName)
let size = alg.Length + 1 + checkSum.Length
size
| None -> 0)) next

let debugEmbeddedPdbChunk, next =
if embeddedPDB then
let streamLength =
match pdbOpt with
| Some (_, _, stream, _, _) -> int stream.Length
| None -> 0
chunk (align 0x4 (match embeddedPDB with
| true -> 8 + streamLength
| _ -> 0 )) next
else
nochunk next

let debugDeterministicPdbChunk, next =
if deterministic then emptychunk next
else nochunk next


let textSectionSize = next - textSectionAddr
let nextPhys = align alignPhys (textSectionPhysLoc + textSectionSize)
Expand Down Expand Up @@ -3804,35 +3824,39 @@ let writeBinaryAndReportMappings (outfile,
if pCurrent <> pExpected then
failwith ("warning: "+chunkName+" not where expected, pCurrent = "+string pCurrent+", p.addr = "+string pExpected)
writeBytes os chunk

let writePadding (os: BinaryWriter) _comment sz =
if sz < 0 then failwith "writePadding: size < 0"
for i = 0 to sz - 1 do
os.Write 0uy

// Now we've computed all the offsets, write the image

write (Some msdosHeaderChunk.addr) os "msdos header" msdosHeader

write (Some peSignatureChunk.addr) os "pe signature" [| |]

writeInt32 os 0x4550

write (Some peFileHeaderChunk.addr) os "pe file header" [| |]

if (modul.Platform = Some AMD64) then
writeInt32AsUInt16 os 0x8664 // Machine - IMAGE_FILE_MACHINE_AMD64
elif isItanium then
writeInt32AsUInt16 os 0x200
else
writeInt32AsUInt16 os 0x014c // Machine - IMAGE_FILE_MACHINE_I386

writeInt32AsUInt16 os numSections

let pdbData =
let pdbData =
// Hash code, data and metadata
if deterministic then
// Hash code, data and metadata
use sha = System.Security.Cryptography.SHA1.Create() // IncrementalHash is core only
use sha =
match checksumAlgorithm with
| HashAlgorithm.Sha1 -> System.Security.Cryptography.SHA1.Create() :> System.Security.Cryptography.HashAlgorithm
| HashAlgorithm.Sha256 -> System.Security.Cryptography.SHA256.Create() :> System.Security.Cryptography.HashAlgorithm

let hCode = sha.ComputeHash code
let hData = sha.ComputeHash data
let hMeta = sha.ComputeHash metadata
Expand All @@ -3848,6 +3872,7 @@ let writeBinaryAndReportMappings (outfile,
// Use last 4 bytes for timestamp - High bit set, to stop tool chains becoming confused
let timestamp = int final.[16] ||| (int final.[17] <<< 8) ||| (int final.[18] <<< 16) ||| (int (final.[19] ||| 128uy) <<< 24)
writeInt32 os timestamp

// Update pdbData with new guid and timestamp. Portable and embedded PDBs don't need the ModuleID
// Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-determinsitic Windows native code
{ pdbData with ModuleID = final.[0..15] ; Timestamp = timestamp }
Expand Down Expand Up @@ -4133,10 +4158,14 @@ let writeBinaryAndReportMappings (outfile,
if pdbfile.IsSome then
write (Some (textV2P debugDirectoryChunk.addr)) os "debug directory" (Array.create debugDirectoryChunk.size 0x0uy)
write (Some (textV2P debugDataChunk.addr)) os "debug data" (Array.create debugDataChunk.size 0x0uy)
write (Some (textV2P debugChecksumPdbChunk.addr)) os "debug checksum" (Array.create debugChecksumPdbChunk.size 0x0uy)

if embeddedPDB then
write (Some (textV2P debugEmbeddedPdbChunk.addr)) os "debug data" (Array.create debugEmbeddedPdbChunk.size 0x0uy)

if deterministic then
write (Some (textV2P debugDeterministicPdbChunk.addr)) os "debug deterministic" Array.empty

writePadding os "end of .text" (dataSectionPhysLoc - textSectionPhysLoc - textSectionSize)

// DATA SECTION
Expand Down Expand Up @@ -4182,7 +4211,7 @@ let writeBinaryAndReportMappings (outfile,
FileSystemUtilites.setExecutablePermission outfile
with _ ->
()
pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugEmbeddedPdbChunk, textV2P, mappings
pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugChecksumPdbChunk, debugEmbeddedPdbChunk, debugDeterministicPdbChunk, textV2P, mappings

// Looks like a finally
with e ->
Expand All @@ -4207,11 +4236,11 @@ let writeBinaryAndReportMappings (outfile,
try
let idd =
match pdbOpt with
| Some (originalLength, contentId, stream) ->
| Some (originalLength, contentId, stream, algorithmName, checkSum) ->
if embeddedPDB then
embedPortablePdbInfo originalLength contentId stream showTimes fpdb debugDataChunk debugEmbeddedPdbChunk
embedPortablePdbInfo originalLength contentId stream showTimes fpdb debugDataChunk debugEmbeddedPdbChunk debugDeterministicPdbChunk debugChecksumPdbChunk algorithmName checkSum embeddedPDB deterministic
else
writePortablePdbInfo contentId stream showTimes fpdb pathMap debugDataChunk
writePortablePdbInfo contentId stream showTimes fpdb pathMap debugDataChunk debugDeterministicPdbChunk debugChecksumPdbChunk algorithmName checkSum embeddedPDB deterministic
| None ->
#if FX_NO_PDB_WRITER
Array.empty<idd>
Expand All @@ -4232,16 +4261,17 @@ let writeBinaryAndReportMappings (outfile,
writeInt32AsUInt16 os2 i.iddMajorVersion
writeInt32AsUInt16 os2 i.iddMinorVersion
writeInt32 os2 i.iddType
writeInt32 os2 i.iddData.Length // IMAGE_DEBUG_DIRECTORY.SizeOfData
writeInt32 os2 i.iddChunk.addr // IMAGE_DEBUG_DIRECTORY.AddressOfRawData
writeInt32 os2 (textV2P i.iddChunk.addr) // IMAGE_DEBUG_DIRECTORY.PointerToRawData
writeInt32 os2 i.iddData.Length // IMAGE_DEBUG_DIRECTORY.SizeOfData
writeInt32 os2 i.iddChunk.addr // IMAGE_DEBUG_DIRECTORY.AddressOfRawData
writeInt32 os2 (textV2P i.iddChunk.addr) // IMAGE_DEBUG_DIRECTORY.PointerToRawData

// Write the Debug Data
for i in idd do
// write the debug raw data as given us by the PDB writer
os2.BaseStream.Seek (int64 (textV2P i.iddChunk.addr), SeekOrigin.Begin) |> ignore
if i.iddChunk.size < i.iddData.Length then failwith "Debug data area is not big enough. Debug info may not be usable"
writeBytes os2 i.iddData
if i.iddChunk.size <> 0 then
// write the debug raw data as given us by the PDB writer
os2.BaseStream.Seek (int64 (textV2P i.iddChunk.addr), SeekOrigin.Begin) |> ignore
if i.iddChunk.size < i.iddData.Length then failwith "Debug data area is not big enough. Debug info may not be usable"
writeBytes os2 i.iddData
os2.Dispose()
with e ->
failwith ("Error while writing debug directory entry: "+e.Message)
Expand All @@ -4250,9 +4280,7 @@ let writeBinaryAndReportMappings (outfile,
with e ->
reraise()

end
ignore debugDataChunk
ignore debugEmbeddedPdbChunk
end
reportTime showTimes "Finalize PDB"

/// Sign the binary. No further changes to binary allowed past this point!
Expand Down Expand Up @@ -4280,15 +4308,16 @@ type options =
embedAllSource: bool
embedSourceList: string list
sourceLink: string
checksumAlgorithm: HashAlgorithm
signer: ILStrongNameSigner option
emitTailcalls : bool
deterministic : bool
emitTailcalls: bool
deterministic: bool
showTimes: bool
dumpDebugInfo: bool
pathMap: PathMap }

let WriteILBinary (outfile, (args: options), modul, normalizeAssemblyRefs) =
writeBinaryAndReportMappings (outfile,
args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource,
args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo, args.pathMap) modul normalizeAssemblyRefs
args.embedSourceList, args.sourceLink, args.checksumAlgorithm, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo, args.pathMap) modul normalizeAssemblyRefs
|> ignore
10 changes: 6 additions & 4 deletions src/absil/ilwrite.fsi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

/// The IL Binary writer.
module internal FSharp.Compiler.AbstractIL.ILBinaryWriter
module internal FSharp.Compiler.AbstractIL.ILBinaryWriter

open Internal.Utilities
open FSharp.Compiler.AbstractIL
open FSharp.Compiler.AbstractIL.Internal
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL
open FSharp.Compiler.AbstractIL.Internal
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL.ILPdbWriter

[<Sealed>]
type ILStrongNameSigner =
Expand All @@ -24,6 +25,7 @@ type options =
embedAllSource: bool
embedSourceList: string list
sourceLink: string
checksumAlgorithm: HashAlgorithm
signer : ILStrongNameSigner option
emitTailcalls: bool
deterministic: bool
Expand Down
Loading