[lld][LayoutPass] Order the atoms that are in the same chain

We need to order atoms that exist in the same chain. This is to make sure that
the command line order is preserved when we emit the atoms to the output file.

Credits: BigCheese for finding the bug.

Adds a test which otherwise would fail.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@190608 91177308-0d34-0410-b5e6-96231b3b80d8
[lld][ELF] Fix the readonly section order.

This associates rodata and sections which just have the SHF_ALLOC flag
to be set to typeConstant.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@190609 91177308-0d34-0410-b5e6-96231b3b80d8
[lld][ELF] Fix vaddr of the first section

The first section in the output was not aligned to the alignment of the section.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@190610 91177308-0d34-0410-b5e6-96231b3b80d8
[lld][LayoutPass] change comments to reflect the sort order

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@190612 91177308-0d34-0410-b5e6-96231b3b80d8
[lld][tests] Fix buildbot failure on darwin

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@190619 91177308-0d34-0410-b5e6-96231b3b80d8
Add a fallback mechanism for undefined atom.

In COFF, an undefined symbol can have up to one alternative name. If a symbol
is resolved by its regular name, then it's linked normally. If a symbol is not
found in any input files, all references to the regular name are resolved using
the alternative name. If the alternative name is not found, it's a link error.
This mechanism is called "weak externals".

To support this mechanism, I added a new member function fallback() to undefined
atom. If an undefined atom has the second name, fallback() returns a new undefined
atom that should be used instead of the original one to resolve undefines. If it
does not have the second name, the function returns nullptr.

Differential Revision: http://llvm-reviews.chandlerc.com/D1550

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