Add support library.

The parsing routines in the linker script to parse strings encoded in various
formats(hexadecimal, octal, decimal, etc), is needed by the GNU driver too. This
library provides helper functions for all flavors and flavors to add helper
functions which other flavors may make use of.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221583 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Support -z max-page-size option

The GNU linker allows the user to change the page size by using the option -z
max-page-size.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221584 91177308-0d34-0410-b5e6-96231b3b80d8
[Gnu] Add options that are ignored

Add options that are ignored and exists just for compatibility reasons.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221585 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] .dynamic should have SHT_DYNAMIC flag

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221586 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Fix values of linker created dynamic variables.

The value of _DYNAMIC should be pointing at the start of the .dynamic segment.
This was pointing to the end of the dynamic segment. Similarly the value of
_GLOBAL_OFFSET_TABLE_ was not proper too.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221587 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Fix DT_INIT_ARRAY{SZ} and DT_FINI_ARRAY{SZ}

The dynamic table was creating the entry DT_FINI_ARRAY{SZ} even when there was
no .fini_array section. The entries should be creating in the dynamic section
only if there are sections .init_array/.fini_array in the output.

Fixes the tests that checked for errroneous outputs.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221588 91177308-0d34-0410-b5e6-96231b3b80d8
[Gnu] Support --image-base option

The value for --image-base is used as the base address of the program.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221589 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] add missing test for max-page-size

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221594 91177308-0d34-0410-b5e6-96231b3b80d8
[Mips] Do not read addends for relocations which do not use them

No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221602 91177308-0d34-0410-b5e6-96231b3b80d8
[Mips] Replace the redundant condition by assert call

No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221603 91177308-0d34-0410-b5e6-96231b3b80d8
[Gnu][Driver] Use StringRef conversion functions

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221648 91177308-0d34-0410-b5e6-96231b3b80d8
Revert "Add support library."

This reverts commit r221583.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221649 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Change order of section match.

Addressed comments from Sean silva.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221650 91177308-0d34-0410-b5e6-96231b3b80d8
[mach-o] Fix lazy binding offsets

The way lazy binding works in mach-o is that the linker generates a helper
function and has the stub (PLT) initially jump to it.  The helper function
pushes an extra parameter then jumps into dyld.  The extra parameter is an
offset into the lazy binding info where dyld will find the information about
which symbol to bind and way lazy binding pointer to update.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221654 91177308-0d34-0410-b5e6-96231b3b80d8
[mach-o] Support linker synthesized mach_header symbols.

On darwin in final linked images, the __TEXT segment covers that start of the
file.  That means in memory a process can see the mach_header (and load commands)
for every loaded image in a process.  There are APIs that take and return the
mach_header addresses as a way to specify a particular loaded image.

For completeness, any code can get the address of the mach_header of the image
it is in by using &__dso_handle.  In addition there are mach-o type specific
symbols like __mh_execute_header.

The linker needs to supply a definition for any of these symbols if used.  But
the address the symbol it resolves to is not in any section.  Instead it is the
address of the start of the __TEXT segment.

I needed to make a small change to SimpleFileNode to not override
resetNextIndex() because the Driver creates a SimpleFileNode to hold the
internal/implicit files that the context/writer can create. For some reason
SimpleFileNode overrode resetNextIndex() to do nothing instead of reseting
the index (which mach-o needs if the internal file is an archive).

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221822 91177308-0d34-0410-b5e6-96231b3b80d8
[mach-o] Sort GOT entries by name to make links reproducible

The GOT slots were being laid out in a random order by the GOTPass which
caused randomness in the output file.

Note: With this change lld now bootstraps on darwin.  That is:
1) link lld using system linker to make lld.1
2) link lld using lld.1 to make lld.2
3) link lld using lld.2 to make lld.3
Now lld.2 and lld.3 are identical.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221831 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Fix delay-import address table contents.

Each entry in the delay-import address table had a wrong alignment
requirement if 32 bit. As a result it got wrong delay-import table.

Because llvm-readobj doesn't print out that field, we don't have a
test for that. I'll submit a test that would catch this bug after
improving llvm-readobj.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221853 91177308-0d34-0410-b5e6-96231b3b80d8
Update COFF delay-import table tests for r221855.

This test should now have caught a bug fixed in r221853.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221856 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Check linker created dynamic variables

Check the values of _GLOBAL_OFFSET_TABLE_ and _DYNAMIC variables created by
linker.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221857 91177308-0d34-0410-b5e6-96231b3b80d8
[ELF] Fix max-page-size option.

The user can use the max-page-size option and set the maximum page size. Dont
check for maximum allowed values for page size, as its what the kernel is
configured with.

Fix the test as well.

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