[COFF] Don't hard-code the load configuration size
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 15 Mar 2016 09:48:27 +0000 (09:48 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 15 Mar 2016 09:48:27 +0000 (09:48 +0000)
commit22dff0aafc380ff8162d12ea5a17e922b9d8cecc
tree2bc36c30f09e86b1462008eb7ddcdcbd64ddfbb2
parent17067199724060bffaa8c9effd7bd8f7db87bb8f
[COFF] Don't hard-code the load configuration size

The load configuration directory is a structure whose size varies as the
OS gains additional functionality.  To account for this, the structure's
layout begins with a size field; this allows loaders to know which
fields are available.

However, LLD hard-coded the sizes (112 bytes for 64-bit and 64 for
32-bit).  This means that we might not inform the loader of all the
pertinent fields or we might claim that there are more fields than are
actually present.

To correctly account for this, the size field must be loaded from the
_load_config_used symbol.

N.B.  The COFF spec is either wrong or out of date, the load
configuration directory is not correctly documented in the
specification: it omits the size field.

llvm-svn: 263543
lld/COFF/Chunks.h
lld/COFF/Writer.cpp
lld/test/COFF/loadcfg.ll
lld/test/COFF/loadcfg.test
lld/test/COFF/loadcfg32.test