Simplify. No functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216257 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Explicitly pass machine type

x86 and x64 are created equal -- taking x86 as the default argument
made it hard to find bugs.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216295 91177308-0d34-0410-b5e6-96231b3b80d8
Update for LLVM api change

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216395 91177308-0d34-0410-b5e6-96231b3b80d8
Use LLD naming style.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216402 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Add /HighEntropyVA.

This is yet another command line flag to set a bit in
DLLCharacteristics. Default on Win64 is "on".

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216414 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Fix AMD64_ADDR64 relocation.

IMAGE_REL_AMD64_ADDR64 relocation should set 64-bit *VA* (virtual
address) instead of *RVA* (relative virtual address), so we have
to add the iamge base to the target's RVA.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216512 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Implement Win64 base relocations

Image Base field in the PE/COFF header is used as hint for the loader.
If the loader can load the executable at the specified address, that's
fine, but if not, it has to load it at a different address.

If that happens, the loader has to fix up the addresses in the
executable by adding the offset. The list of addresses that need to
be fixed is in .reloc section.

This patch is to emit x64 .reloc section contents.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216636 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Another Win64 relocation bug fix

When a relocation is applied to a location, the new value needs
to be added to the existing value at the location. Existing
value is in most cases zero, but if not, the current code does
not work.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216680 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Fix AMD64_REL_[1-5] and AMD64_SECTION relocations

I hope this is the last fix for x64 relocations as I've wasted
a few days on this.

This caused a mysterious issue that some C++ programs crash on
startup. It was because a null pointer is passed as argv to main.
__tmainCRTStartup calls main, but before that it calls all
initialization routines between .text$xc_a and .text$xc_z.
pre_cpp_init is one of such routines, and it is the one who
initializes a heap pointer for argv for later use. That routine
was not called for some reason.

It turned out that __tmainCRTStartup was skipping a block of
code because of the relocation bug. A condition in the function
depends on a memory load, and that memory load was referring
a wrong location. As a result a jump instruction took the
wrong branch, skipping pre_cpp_init and so on.

This patch fixes the issue. Also added more tests to fix them
once and for all.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216772 91177308-0d34-0410-b5e6-96231b3b80d8