Commit Graph

796 Commits

Author SHA1 Message Date
Rui Ueyama 07fae9691b [PECOFF] Fix /entry option.
This is yet another edge case of ambiguous name resolution.
When a symbol is specified with /entry:SYM, SYM may be resolved
to the C++ mangled function name (?SYM@@YAXXZ).

llvm-svn: 218706
2014-09-30 21:39:49 +00:00
Tim Northover cf78d37fd6 [mach-o] create __unwind_info section on x86_64
This is a minimally useful pass to construct the __unwind_info section in a
final object from the various __compact_unwind inputs. Currently it doesn't
produce any compressed pages, only works for x86_64 and will fail if any
function ends up without __compact_unwind.

rdar://problem/18208653

llvm-svn: 218703
2014-09-30 21:29:54 +00:00
Rui Ueyama fa67adc28d [PECOFF] Allow /export:<symbol>,PRTVATE.
PRIVATE option is also an undocumented feature.

llvm-svn: 218696
2014-09-30 20:09:31 +00:00
Rui Ueyama 3837e10002 [PECOFF] Fix /export option.
MSDN doesn't say about /export:foo=bar style option, but
it turned out MSVC link.exe actually accepts that. So we need that
too.

It also means that the export directive in the module definition
file and /export command line option are functionally equivalent.

llvm-svn: 218695
2014-09-30 20:03:11 +00:00
Rui Ueyama 3041443b5c [PECOFF] Fix __imp_ prefix on x64.
"__imp_" prefix always starts with double underscores.
When I was writing the original code I misunderstood
that it's "_imp_" on x64.

llvm-svn: 218690
2014-09-30 19:42:04 +00:00
Rafael Auler 5a1000dddc [lld] [ELF] Support for general dynamic TLS relocations on X86_64
Summary:
This patch adds support for the general dynamic TLS access model for X86_64 (see www.akkadia.org/drepper/tls.pdf).

To properly support TLS, the patch also changes the __tls_get_addr atom to be a shared library atom instead of a regularly defined atom (the previous lld approach). This closely models the reality of a function that will be resolved at runtime by the dynamic linker and loader itself (ld.so). I was tempted to force LLD to link against ld.so itself to resolve these symbols, but since GNU ld does not need the ld.so library to resolve this symbol, I decided to mimic its behavior and keep hardwired a definition of __tls_get_addr in the lld code.

This patch also moves some important logic that previously was only available to the MIPS lld backend to be used to all ELF backends. This logic, which now lives in the DefaultLayout class, will monitor which external (shared lib) symbols are really imported by the current module and will only populate the dynamic symbol table with used symbols, as opposed to the previous approach of dumping all shared lib symbols in the dynamic symbol table. This is important to this patch to avoid __tls_get_addr from getting injected into all dynamic symbol tables.

By solving the previous problem of always adding __tls_get_addr, now the produced symbol tables are slightly smaller. But this impacted several tests that relied on hardwired/predefined sizes of the symbol table, requiring this patch to update such tests.

Test Plan: Added a LIT test case that exercises a simple use case of TLS variable in a shared library.

Reviewers: ruiu, rafael, Bigcheese, shankarke

Reviewed By: Bigcheese, shankarke

Subscribers: emaste, shankarke, joerg, kledzik, mcrosier, llvm-commits

Projects: #lld

Differential Revision: http://reviews.llvm.org/D5505

llvm-svn: 218633
2014-09-29 22:05:26 +00:00
Rui Ueyama 1b0e68353d [PECOFF] Fix module definition file output
Previously we emit two or more identical definitions for an
exported symbol if the same /export option is given more than
once. This patch fixes that bug.

llvm-svn: 218433
2014-09-25 00:52:38 +00:00
Nick Kledzik 38cd67624b [mach-o] fix test case to work with latest llvm-objdump output
Take opporunity to clean up test to only run llvm-objdump once now that
llvm-objdump can disassemble mixed thumb and arm code.

llvm-svn: 218429
2014-09-24 23:55:06 +00:00
Rui Ueyama a370c3ee35 [PECOFF] Exported name should match C++ mangled name
Currently you can omit the leading underscore from exported
symbol name. LLD will look for mangled name for you. But it won't
look for C++ mangled name.

This patch is to support that.

If "sym" is specified to be exported, the linker looks for not
only "sym", but also "_sym" and "?sym@@<whatever>", so that you
can export a C++ function without decorating it.

llvm-svn: 218355
2014-09-24 02:01:10 +00:00
Rui Ueyama 7ea46bab26 [PECOFF] Fix duplicate /export options
If two or more /export options are given for the same symbol, we should
always print a warning message and use the first one regardless of other
parameters.
Previously there was a case that the first parameter is not used.

llvm-svn: 218342
2014-09-23 23:49:41 +00:00
Rui Ueyama a3eff3afd9 Make -core/-flavor options have higher priority than linker name
Also allows -core/flavor to appear at any position in the command line.
Patch from Oleg Ranevskyy!

http://reviews.llvm.org/D5384

llvm-svn: 218321
2014-09-23 18:09:38 +00:00
Rui Ueyama 117ef70c98 [PECOFF] Handle PRIVATE keyword in the module definition file
A symbol in a module definition file may be annotated with the
PRIVATE keyword like this.

  EXPORTS
    func PRIVATE

The PRIVATE keyword does not affect the resulting .dll file.
But it prevents the symbol to be listed in the .lib (import
library) file.

llvm-svn: 218273
2014-09-22 20:50:46 +00:00
Rui Ueyama 45f4d54c07 Re-commit r218259.
llvm-svn: 218272
2014-09-22 20:48:04 +00:00
Rui Ueyama 869c0019b1 Revert "[ELF] Fix linking when a regular object defines a symbol that is used in a DSO"
This commit reverts r218259 because it needed to be checked in with
a few binary files for the test.

llvm-svn: 218262
2014-09-22 18:08:34 +00:00
Rui Ueyama 508a007ae6 [ELF] Fix linking when a regular object defines a symbol that is used in a DSO
Patch from Rafael Auler!

When a shared lib has an undefined symbol that is defined in a regular object
(the program), the final executable must export this symbol in the dynamic
symbol table. However, in the current logic, lld only puts the symbol in the
dynamic symbol table if the symbol is weak. This patch fixes lld to put the
symbol in the dynamic symbol table regardless if it is weak or not.

This caused a problem in FreeBSD10, whose programs link against a crt1.o
that defines the symbol __progname, which is, in turn, undefined in libc.so.7
and will only be resolved in runtime.

http://reviews.llvm.org/D5424

llvm-svn: 218259
2014-09-22 17:52:50 +00:00
Rui Ueyama 44a7c7f1aa [PECOFF] Set ordinal to alias atoms
Atoms are ordered in the output file by ordinal. File has file ordinal,
and atom has atom ordinal which is unique within the file.
No two atoms should have the same combination of ordinals.

However that contract was not satisifed for alias atoms. Alias atom
is defined by /alternatename:sym1=sym2. In this case sym1 is defined
as an alias for sym2. sym1 always got ordinal 0.

As a result LLD failed with an assertion failure.

This patch assigns ordinal to alias atoms.

llvm-svn: 218158
2014-09-19 21:58:54 +00:00
Rui Ueyama 6bf091c656 [PECOFF] /safeseh:no on x64 is not an error
I made LLD to report an error if /safeseh:no option is given on x64,
but it turned out MSVC link.exe doesn't report error on it.
Removing the check.

llvm-svn: 218077
2014-09-18 21:18:05 +00:00
Rui Ueyama 9f1215b2d8 [PECOFF] Support TLS callbacks.
The contents from section .CRT$XLA to .CRT$XLZ is an array of function
pointers. They are called by the runtime when a new thread is created
or (gracefully) terminated.

You can make your own initialization function to be called by that
mechanism. All you have to do is:

- Define a pointer to a function in a .CRT$XL* section using pragma
- Make an external reference to "__tls_used" symbol

That technique is used in many projects. This patch is to support that.

What this patch does is to set the relative virtual address of
"__tls_used" to the PECOFF directory table. __tls_used is actually a
struct containing pointers to a symbol in .CRT$XLA and another symbol
in .CRT$XLZ. The runtime looks at the directory table, gets the address
of the struct, and call the function pointers between XLA and XLZ.

llvm-svn: 218007
2014-09-18 02:02:52 +00:00
Nick Kledzik b54bbe358a [mach-o] update test case to match new llvm-objdump output
llvm-svn: 217932
2014-09-17 00:51:18 +00:00
Nick Kledzik 1050b57a0b [mach-o] Fix two-level namespace ordinals
On darwin, the linker tools records which dylib (DSO) each undefined was found
in, and then at runtime, the loader (dyld) only looks in that one specific
dylib for each undefined symbol.  Now that llvm-objdump can display that info
I can write test cases.

llvm-svn: 217898
2014-09-16 20:27:28 +00:00
Ed Maste 933daef54f Add FreeBSD to system-linker-elf case
llvm-svn: 217672
2014-09-12 13:16:30 +00:00
Tim Northover 1684a614b3 [mach-o]: support optional "0x" prefix for -image_base
llvm-svn: 217578
2014-09-11 10:31:46 +00:00
Tim Northover 5d95bd7037 [mach-o]: tighten up diagnostics for -image_base option
The provided base must also be a multiple of the system's page size, which is a
reasonable enough demand.

Also check the other diagnostics more thoroughly.

llvm-svn: 217577
2014-09-11 10:31:42 +00:00
Nick Kledzik 50bda292c8 If lld is renamed (or symlinked) to "ld" automatically pick the right flavor.
The existing system linkers on Darwin and Linux are called "ld".  We'd like to
eventually drop in lld as "ld" and have it just work.  But lld is a universal
linker that requires the first option to be -flavor to know which command line
mode to emulate (gnu or darwin).

This change tests if argv[0] is "ld" and if so, if the tool was built on MacOSX
then assume the darwin flavor otherwise the gnu flavor.  There are two test
cases which copy lld to "ld" and then run it. One for darwin and one for linux.

llvm-svn: 217566
2014-09-11 00:52:05 +00:00
Tim Northover af3075b93f [mach-o]: implement -image_base option on Darwin.
As suggested by Nick, this will make __unwind_info implementation more natural,
and it'd have to be done at some point anyway.

llvm-svn: 217486
2014-09-10 10:39:57 +00:00
Nick Kledzik 1bebb2832e [mach-o] Add support for arm64 (AAarch64)
Most of the changes are in the new file ArchHandler_arm64.cpp.  But a few
things had to be fixed to support 16KB pages (instead of 4KB) which iOS arm64
requires.  In addition the StubInfo struct had to be expanded because
arm64 uses two instruction (ADRP/LDR) to load a global which requires two
relocations.  The other mach-o arches just needed one relocation.

llvm-svn: 217469
2014-09-09 23:52:59 +00:00
Nick Kledzik 8a8c3ba38c [mach-o] add testing coverage for -single_module
llvm-svn: 217412
2014-09-09 02:20:34 +00:00
Nick Kledzik 4ce63c2a54 [mach-o] Fix so no options causes usage message to be printed
llvm-svn: 217409
2014-09-09 00:45:35 +00:00
Nick Kledzik b7035ae367 [mach-o] Add support for -pie and -no_pie
There is a bit (MH_PIE) in the flags field of the mach_header which tells
the kernel is a program was built position independent (for ASLR).  The linker
automatically attempts to build programs PIE if they are built for a recent
OS version.  But the -pie and -no_pie options override that default behavior.

llvm-svn: 217408
2014-09-09 00:17:52 +00:00
Simon Atanasyan 07000878f8 [ELF] Export strong defined symbol if it coalesces away a weak symbol
defined in a shared library.

Now LLD does not export a strong defined symbol if it coalesces away a
weak symbol defined in a shared library. This bug affects all ELF
architectures and leads to segfault:

  % cat foo.c
  extern int __attribute__((weak)) flag;
  int foo() { return flag; }

  % cat main.c
  int flag = 1;
  int foo();
  int main() { return foo() == 1 ? 0 : -1; }

  % clang -c -fPIC foo.c main.c
  % lld -flavor gnu -target x86_64 -shared -o libfoo.so ... foo.o
  % lld -flavor gnu -target x86_64 -o a.out ... main.o libfoo.so
  % ./a.out
  Segmentation fault

The problem is caused by the fact that we lose all information about
coalesced symbols after the `Resolver::resolve()` method is finished.

The patch solves the problem by overriding the
`LinkingContext::notifySymbolTableCoalesce()` method and saving names
of coalesced symbols. Later in the `buildDynamicSymbolTable()` routine
we use this information to export these symbols.

llvm-svn: 217363
2014-09-08 09:43:38 +00:00
Shankar Easwaran c7701e9a8c [ELF][Driver] Produce a proper error when file is not found
When a file is not found, produce a proper error message. The previous error
message produced a file format error, which made me wonder for a while why
there is a file format error, but essentially the file was not found.

This fixes the problem by producing a proper error message.

llvm-svn: 217359
2014-09-08 04:18:11 +00:00
Shankar Easwaran 595e056dce [ELF] Implement --rosegment
By default linker would not create a separate segment to hold read only data.

This option overrides that behavior by creating the a separate read only segment
for read only data.

llvm-svn: 217358
2014-09-08 04:05:52 +00:00
Shankar Easwaran 24511fc426 [ELF] Undefined symbols should be allowed when building dynamic libraries
When dynamic libraries are built, undefined symbols should always be allowed and
the linker should not exit with an error.

llvm-svn: 217356
2014-09-08 03:11:50 +00:00
Nick Kledzik 635f9c7158 [mach-o] Let darwin driver infer arch from .o files if -arch not used.
Mach-O has a "fat" (or "universal") variant where the same contents built for
different architectures are concatenated into one file with a table-of-contents
header at the start.  But this leaves a dilemma for the linker - which
architecture to use.

Normally, the linker command line -arch is used to force which slice of any fat
files are used.  The clang compiler always passes -arch to the linker when
invoking it.  But some Makefiles invoke the linker directly and don’t specify
the -arch option.  For those cases, the linker scans all input files in command
line order and finds the first non-fat object file.  Whatever architecture it
is becomes the architecture for the link.

llvm-svn: 217189
2014-09-04 20:08:30 +00:00
Nick Kledzik 0e3e6155fe [mach-o] Improve x86_64 reference kind switch statements.
The use of default: was disabling the warning about unused enumerators. Fix
that, then fix the one enumerator that was not handled. Add coverage for
it in test suite.

llvm-svn: 217078
2014-09-03 21:09:24 +00:00
Nick Kledzik 141330aef6 [mach-o] Add support for using export tries
On Darwin at runtime, dyld will prefer to use the export trie of a dylib instead
of the traditional symbol table (which is large and requires a binary search).

This change enables the linker to generate an export trie and to prefer it if
found in a dylib being linked against.  This also simples the yaml for dylibs
because the yaml form of the trie can be reduced to just a sequence of names.

llvm-svn: 217066
2014-09-03 19:52:50 +00:00
Rui Ueyama 495a031ce4 [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.

llvm-svn: 216772
2014-08-29 20:33:27 +00:00
Rui Ueyama 4a6ead7a9f [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.

llvm-svn: 216680
2014-08-28 19:00:40 +00:00
Rui Ueyama f4b0d5e050 [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.

llvm-svn: 216636
2014-08-28 00:47:11 +00:00
Rui Ueyama 06970fe7fd [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.

llvm-svn: 216512
2014-08-27 01:10:01 +00:00
Rui Ueyama d718c73f0b [PECOFF] Add /HighEntropyVA.
This is yet another command line flag to set a bit in
DLLCharacteristics. Default on Win64 is "on".

llvm-svn: 216414
2014-08-25 22:23:34 +00:00
Rui Ueyama 5711df44b8 [PECOFF] Fix PE+ relocations
The implementation of AMD64 relocations was imcomplete
and wrong. On AMD64, we of course have to use AMD64
relocations instead of i386 ones. This patch fixes the
issue.

LLD is now able to link hello64.obj (created from
hello64.asm) against user32.lib and kernel32.lib to
create a Win64 binary.

llvm-svn: 216253
2014-08-22 01:15:43 +00:00
Nick Kledzik 7820c80f7d [mach-o] support N_NO_DEAD_STRIP nlist.desc bit
Mach-O symbols can have an attribute on them means their content should never be
dead code stripped.  This translates to deadStrip() == deadStripNever.

llvm-svn: 216234
2014-08-21 22:18:30 +00:00
Nick Kledzik 77afc71426 [mach-o] Fix initial live atoms with -dead_strip
When -dead_strip is used with -exported_symbols_list the initial set of
live atoms are those in the export list.

llvm-svn: 216213
2014-08-21 20:25:50 +00:00
Nick Kledzik 8c0bf75ef5 [mach-o] Add support for -exported_symbols_list and -keep_private_externs
Both options control the final scope of atoms.

When -exported_symbols_list <file> is used, the file is parsed into one
symbol per line in the file.  Only those symbols will be exported (global)
in the final linked image.

The -keep_private_externs option is only used with -r mode. Normally, -r
mode reduces private extern (scopeLinkageUnit) symbols to non-external. But
add the -keep_private_externs option keeps them private external.

llvm-svn: 216146
2014-08-21 01:59:11 +00:00
Rui Ueyama a0b988cb63 [PECOFF] Emit PE+ idata tables.
Import tables in the PE+ format is an array of 64 bit numbers,
although the executable size is still limited to 4GB in PE+.

llvm-svn: 216039
2014-08-20 01:09:42 +00:00
Nick Kledzik 94174f755c [mach-o] Support -filelist option in darwin driver
The darwin linker has an option, heavily used by Xcode, in which, instead
of listing all input files on the command line, the input file paths are
written to a text file and the path of that text file is passed to the linker
with the -filelist option (similar to @file).

In order to make test cases for this, I generalized the -test_libresolution
option to become -test_file_usage.

llvm-svn: 215762
2014-08-15 19:53:41 +00:00
Nick Kledzik 2d835dad0a [mach-o] Support -F and -framework options in darwin driver
Darwin has a packaging mechanism for shared libraries and headers called
frameworks.  A directory Foo.framework contains a shared library binary file
"Foo" and a subdirectory "Headers". Most OS frameworks are all in one
directory /System/Library/Frameworks/.  As a linking convenience, the linker
option "-framework Foo" means search the framework directories specified
with -F (analogous to -L) looking for a shared library Foo.framework/Foo.

llvm-svn: 215680
2014-08-14 22:20:41 +00:00
Nick Kledzik 8fc67fba01 [mach-o] Support re-exported dylibs
In general two-level namespace means each program records exactly which dylib
each undefined (imported) symbol comes from.  But, sometimes the implementor
wants to hide the implementation dylib.  For instance libSytem.dylib is the base
dylib all Darwin programs must link with.  A few years ago it was split up
into two dozen dylibs by all are hidden behind libSystem.dylib which re-exports
each sub-dylib.  All clients still think libSystem.dylib is the implementor.

To support this, the linker must load "indirect" dylibs and not just the
"direct" dylibs specified on the command line.  This is done in the
createImplicitFiles() method after all command line specified files are
loaded.  Since an indirect dylib may have already been loaded as a direct dylib
(or indirectly via a previous direct dylib), the MachOLinkingContext keeps
a list of all loaded dylibs.

With this change hello world can now be linked against the real OS or SDK.

llvm-svn: 215605
2014-08-13 23:55:41 +00:00
Nick Kledzik ebf09360ec [mach-o] Fix stub generation to work for dylibs and bundles
Split up the CRuntimeFile into one part for output types that need an entry
point and another part for output types that use stubs.

Add file 'test/mach-o/Inputs/libSystem.yaml' for use by test cases that
use -dylib and therefore may now need the helper symbol in libSystem.dylib.

llvm-svn: 215602
2014-08-13 23:31:07 +00:00
Nick Kledzik b47683223f [mach-o] set ordinal in n_desc for undefined symbols
Mach-o uses "two-level namespace" where each undefined symbols is associated
with a specific dylib. This means at runtime the loader (dyld) does need to
search all loaded dylibs for that symbol but rather just the one specified.

Now that llvm-nm -m prints out that info, properly set that info, and test
it in the hello world test cases.

llvm-svn: 215598
2014-08-13 23:11:42 +00:00
Chad Rosier 69e2881070 [AArch64] Initial ELF/AArch64 Support
This patch adds the initial ELF/AArch64 support to lld. Only a basic "Hello
World" app has been successfully tested for both dynamic and static compiling.

Differential Revision: http://reviews.llvm.org/D4778
Patch by Daniel Stewart <stewartd@codeaurora.org>!

llvm-svn: 215544
2014-08-13 13:16:38 +00:00
Daniel Sanders df153c1a7e [mips] Remove .end and .end from test/elf/Mips/hilo16-3.test
The commit of the .ent/.end implementation will change the result of the
relocation evaluations (because of a new section and additional relocations)
which will lead to a failure if the .ent/.end directives are present in this
test.
We don't really need the .ent/.end directives in this test so let's just remove
them to preserve the current output.

llvm-svn: 215534
2014-08-13 10:04:59 +00:00
Rui Ueyama 145ef0186c [PECOFF] Fix /include option in .drectve section.
/INCLUDE arguments passed as command line options are handled in the
same way as Unix -u. All option values are converted to an undefined
symbol and added to a dummy input file, so that the specified symbols
are resolved.

One tricky thing on Windows is that the option is also allowed to
appear in the object file's directive section. At the time when
it's being read, all (regular) command line options have already
been processed. We cannot add undefined atoms to the dummy file
anymore.

Previously, we added such /INCLUDE to a set that has already been
processed. As a result the options were ignored.

This patch fixes the issue. Now, /INCLUDE symbols in the directive
section are handled as real undefined symbol in the COFF file.
We create an undefined symbol for each /INCLUDE argument and add
it to the file being parsed.

llvm-svn: 214824
2014-08-04 23:48:57 +00:00
Simon Atanasyan 0670abdd2e [Mips] Replace assembler code by YAML to make the 'gotsym.test' test
target independent.

llvm-svn: 214641
2014-08-02 20:18:31 +00:00
Simon Atanasyan 91af42fb7b [Mips] Replace assembler code by YAML to make the 'interpreter.test' test
target independent.

llvm-svn: 214495
2014-08-01 09:47:21 +00:00
Rui Ueyama 140f6029ce [PECOFF] Fix section header.
The PE/COFF spec says that SizeOfRawData field in the section
header must be a multiple of FileAlignment from the optional
header. LLD emits 512 as FileAlignment, so it must have been
a multiple of 512.

LLD did not follow that. It emitted the actual section size
without the last padding as the SizeOfRawData. Although it's
not correct as per the spec, the Windows loader doesn't seem
to actually bother to check that. Executables created by LLD
worked fine.

However, tools dealing with executalbe files may expect it
to be the correct value, and one instance of it is mt.exe
tool distributed as a part of Windows SDK.

If CMake is invoked with "-E vs_link_exe" option, it silently
run mt.exe to embed a resource file to the resulting file.
And mt.exe sometimes breaks an input file if it's section
header does not follow the standard. That caused a misterous
error that CMake with Ninja occasionally produces a broken
executable.

This patch fixes the section header to make mt.exe and
other tools happy.

llvm-svn: 214453
2014-07-31 22:40:35 +00:00
Simon Atanasyan d7bc5d0119 XFAIL the ARM test when we don't have this target.
llvm-svn: 214420
2014-07-31 19:02:10 +00:00
Nick Kledzik 76689d0202 [mach-o] Fix test case comment and stray file copy
llvm-svn: 214278
2014-07-30 01:43:21 +00:00
Nick Kledzik 9b7b8ff32d [mach-o] Fix arm interworking with movw/movt
In some cases the address of a function will be materialized with a movw/movt
pair.  If the function is a thumb function, the low bit needs to be set on
the movw immediate value.

llvm-svn: 214277
2014-07-30 01:41:38 +00:00
Nick Kledzik 2fcbe822c0 [mach-o] Add support for -sectalign option
The -sectalign option is used to increase the alignment required for a section.
It required some reworking of how the __TEXT segment is laid out because that
segment also contains the mach_header and load commands. And the size of load
commands depend on the number of segments, sections, and dependent dylibs used.

Using this option will simplify some future test cases because the final
address of code can be pinned down, making tests of its content easier.

llvm-svn: 214268
2014-07-30 00:58:06 +00:00
Nick Kledzik 54fd4e5fcb [mach-o] Implement interworking between thumb and arm code
All iOS arm processor support switching between arm and thumb mode at call sites
by using the BLX instruction (instead of BL).  But the compiler does not know
the implementation mode for extern functions, so the linker must update BL/BLX
instructions to match what is linked is actually linked together.  In addition,
pointers to functions (such as vtables) must have the low bit set if the target
of the pointer is a thumb mode function.

llvm-svn: 214140
2014-07-28 23:06:09 +00:00
Rui Ueyama 7385120d65 [PECOFF] Fix failing test.
This should be covered by the Driver's unit tests.

llvm-svn: 214134
2014-07-28 22:31:37 +00:00
Simon Atanasyan 6052f045d7 [Mips] Remove redundant REQUIRES clause.
The exe-got.test test case is target independent.

llvm-svn: 214085
2014-07-28 14:19:18 +00:00
Nick Kledzik 21921375cc [mach-o] Add support for LC_DATA_IN_CODE
Sometimes compilers emit data into code sections (e.g. constant pools or
jump tables). These runs of data can throw off disassemblers.  The solution
in mach-o is that ranges of data-in-code are encoded into a table pointed to
by the LC_DATA_IN_CODE load command.

The way the data-in-code information is encoded into lld's Atom model is that
that start and end of each data run is marked with a Reference whose offset
is the start/end of the data run.  For arm, the switch back to code also marks
whether it is thumb or arm code.

llvm-svn: 213901
2014-07-24 23:06:56 +00:00
Simon Atanasyan 4b6d090bd3 [Mips] Replace assembler code by YAML to make the 'exe-dynsym.test' test
target independent.

llvm-svn: 213868
2014-07-24 15:42:11 +00:00
Rui Ueyama 23314e1ca6 [PECOFF] Fix entry point address.
Because of a bug, the entry point address in the PE/COFF header
was not correct.

llvm-svn: 213802
2014-07-23 20:51:04 +00:00
Rui Ueyama a27bb08e73 [PECOFF] Fix entry point functions selection
On Windows there are four "main" functions -- main, wmain, WinMain,
or wWinMain. Their parameter types are diffferent. The standard
library provides four different entry functions (i.e.
{w,}{WinMain,main}CRTStartup) for them. You need to use the right
entry routine for your "main" function.

If you give an /entry option, the specified name is used
unconditionally.

Otherwise, the linker needs to select the right one based on
user-supplied entry point function. This can be done after the
linker reads all the input files.

This patch moves the code to determine the entry point function
from the driver to a virtual input file. It also implements the
correct logic for the entry point function selection.

llvm-svn: 213713
2014-07-23 00:57:57 +00:00
Nick Kledzik 7e9808f7de [mach-o] add initial support for modes in arm code.
This patch just supports marking ranges that are thumb code (vs arm code).
Future patches will mark data and jump table ranges. The ranges are encoded
as References with offsetInAtom being the start of the range and the target
being the same atom.

llvm-svn: 213712
2014-07-23 00:51:37 +00:00
Nick Kledzik b78ad899e5 [mach-o] add support for round tripping all arm/thumb relocations
Update the parse-arm-relocs.yaml test case to run the linker back to back
to ensure all relocations round trip in and out of mach-o.

llvm-svn: 213700
2014-07-22 23:07:49 +00:00
Simon Atanasyan bcb865a8ce [Mips] Replace assembler code by YAML to make the 'entry-name.test' test target
independent.

llvm-svn: 213690
2014-07-22 21:47:34 +00:00
Nick Kledzik e1aaced0cb [mach-o] Add test case for armv6 (arm not thumb) hello world
llvm-svn: 213592
2014-07-22 00:49:49 +00:00
Nick Kledzik 03e16f2ab4 [mach-o] add support for old x86 __eh_frame sections
Over time the symbols and relocations have changed for dwarf unwind info
in the __eh_frame section.  Add test cases for older and new style.

llvm-svn: 213585
2014-07-21 22:06:57 +00:00
Simon Atanasyan 09f45ca39b [Mips] Replace assembler code by YAML to make the 'dynlib-fileheader.test'
test target independent.

llvm-svn: 213480
2014-07-20 20:03:46 +00:00
Simon Atanasyan 5ecadda642 [Mips] Replace assembler code by YAML to make the test 'dynlib-dynamic.test'
target independent.

llvm-svn: 213462
2014-07-19 20:18:46 +00:00
Simon Atanasyan f7ce3ea024 [Mips] Replace assembler code by YAML to make the test 'base-address.test'
target independent.

llvm-svn: 213390
2014-07-18 17:23:21 +00:00
Nick Kledzik 7e246a47f9 [mach-o] Add support for x86 pointers which use scattered relocations
llvm-svn: 213344
2014-07-18 01:05:35 +00:00
Nick Kledzik 68a1abdf14 [mach-o] Add support for x86 CALL instruction that uses a scattered relocation
llvm-svn: 213340
2014-07-18 00:37:52 +00:00
Nick Kledzik 2d432353ba [mach-o] implement more x86 and x86_64 relocation support
Add support for adding section relocations in -r mode.  Enhance the test
cases which validate the parsing of .o files to also round trip.  They now
write out the .o file and then parse that, verifying all relocations survived
the round trip.

llvm-svn: 213333
2014-07-17 23:16:21 +00:00
Rui Ueyama 286691ad5e [PECOFF] Set DLL bit in PE header if DLL.
Windows loader can load a DLL without this bit but it wouldn't
call the initializer function in the DLL if the bit is absent.

llvm-svn: 213216
2014-07-17 00:22:26 +00:00
Nick Kledzik 2458bec7e7 [mach-o] refactor KindHandler into ArchHandler and simplify passes.
All architecture specific handling is now done in the appropriate
ArchHandler subclass.

The StubsPass and GOTPass have been simplified.  All architecture specific
variations in stubs are now encoded in a table which is vended by the
current ArchHandler.

llvm-svn: 213187
2014-07-16 19:49:02 +00:00
Simon Atanasyan 64c0ac2b35 [ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script command.
There are two forms of `-l` prefixed expression:

* -l<libname>
* -l:<filename>

In the first case a linker should construct a full library name
`lib + libname + .[so|a]` and search this library as usual. In the second case
a linker should use the `<filename>` as is and search this file through library
search directories.

The patch reviewed by Shankar Easwaran.

llvm-svn: 213077
2014-07-15 17:17:30 +00:00
Simon Atanasyan 35ad71adad [Mips] Fix test case expectations due the latest changes in the LLVM.
llvm-svn: 212949
2014-07-14 15:31:47 +00:00
Simon Atanasyan 355f7ed602 [Mips] Remove unused test input file.
llvm-svn: 212927
2014-07-14 08:54:40 +00:00
Simon Atanasyan c97126b1c9 [Mips] Make rel-dynamic-11.test test case independent from external input files.
llvm-svn: 212813
2014-07-11 13:42:04 +00:00
Rui Ueyama 8cb0f1e3c0 [PECOFF] Set resource table entry in header.
The resource table entry should have the RVA of the
embedded resource file.

llvm-svn: 212765
2014-07-10 21:43:19 +00:00
Rui Ueyama 31fd9d09b2 [PECOFF] Invoke cvtres.exe in the driver.
Previously we invoked cvtres.exe for each compiled Windows
resource file. The generated files were then concatenated
and embedded to the executable.

That was not the correct way to merge compiled Windows
resource files. If you just concatenate generated files,
only the first file would be recognized and the rest would
be ignored as trailing garbage.

The right way to merge them is to call cvtres.exe with
multiple input files. In this patch we do that in the
Windows driver.

llvm-svn: 212763
2014-07-10 20:53:37 +00:00
Simon Atanasyan d092f0e64a [Mips] Make rel-dynamic-10.test test case independent from external input files.
llvm-svn: 212758
2014-07-10 19:47:23 +00:00
Tim Northover 73c532e8a9 [mach-o]: support -Z option to skip standard library paths
llvm-svn: 212713
2014-07-10 11:46:13 +00:00
Tim Northover 18af0573df [mach-o]: support user-specified (-L) library search paths
llvm-svn: 212712
2014-07-10 11:46:08 +00:00
Tim Northover 77d82202d1 [mach-o]: support -syslibroot and -l options
These behave slightly idiosyncratically in the best of cases, and have
additional hacks layered on top of that for compatibility with badly behaved
build systems (via ld64).

For -lXYZ:
  + If XYZ is actually XY.o then search all library paths for XY.o
  + Otherwise search all library paths, first for libXYZ.dylib, then libXYZ.a
  + By default the library paths are /usr/lib and /usr/local/lib in that order.

For -syslibroot:
  + -syslibroot options apply to absolute paths in the search order.
  + All -syslibroot prefixes that exist are added to the search path *instead*
    of the original.
  + If no -syslibroot prefixed path exists, the original is kept.
  + Hacks^WExceptions:
      + If only 1 -syslibroot is given and doesn't contain /usr/lib or
        /usr/local/lib, that path is dropped entirely. (rdar://problem/6438270).
      + If the last -syslibroot is "/", all of them are ignored entirely.
        (rdar://problem/5829579).

At least, that's my best interpretation of what ld64 does in buildSearchPaths.

llvm-svn: 212706
2014-07-10 11:21:06 +00:00
Nick Kledzik 0edfdeb0be Move GOTPass and StubsPass from Core to MachO
llvm-svn: 212652
2014-07-09 21:04:24 +00:00
Simon Atanasyan 0acd5447b4 [Mips] Make rel-dynamic-08.test test case independent from external input files.
llvm-svn: 212613
2014-07-09 12:31:11 +00:00
Nick Kledzik 2552a09978 Change llvm-nm to use -M instead of -s to work with latest llvm-nm
llvm-svn: 212579
2014-07-09 00:25:52 +00:00
Rui Ueyama 39dc40af07 [PECOFF] Fix .bss section alignment
Previously the alignment of the .bss section was not
properly set because of a bug in AtomizeDefinedSymbolsInSection.
We set the alignment of the section at the end of the function,
but we use an eraly return for the .bss section, so the code had
been skipped.

llvm-svn: 212571
2014-07-08 23:11:01 +00:00
Simon Atanasyan e693e8f8f0 [Mips] Make rel-dynamic-07.test test case independent from external input files.
llvm-svn: 212542
2014-07-08 15:47:55 +00:00
Simon Atanasyan 49eafe909b [Mips] Make rel-dynamic-05.test test case independent from external input files.
llvm-svn: 212480
2014-07-07 20:14:49 +00:00
Simon Atanasyan 611b7a11b5 [Mips] Make rel-dynamic-04.test test case independent from external input files.
llvm-svn: 212409
2014-07-06 17:44:40 +00:00
Nick Kledzik 4576c115ac [mach-o] Add parsing of arm/thumb relocations
This converts the very complicated mach-o arm
relocations into the simple Reference Kinds in lld.

The next patch will use the internal Reference kinds
to fix up arm/thumb code.

llvm-svn: 212306
2014-07-04 00:11:09 +00:00
Tim Northover ca2e63daf8 [mach-o]: remove dylib install-name test with a.out
Unfortunately, the creation of (the default) output file, a.out races with all
the other tests in this directory. When the wrong one is read by macho-dump,
the test fails.

llvm-svn: 212269
2014-07-03 12:50:23 +00:00
Nick Kledzik b6e8ce8250 [mach-o] add x86 test case to build hello world. Fix bugs it uncovered.
llvm-svn: 212247
2014-07-03 02:01:21 +00:00
Nick Kledzik de0860aae4 [mach-o] add parsing of x86 relocations
llvm-svn: 212239
2014-07-02 23:52:22 +00:00
Rui Ueyama 408d4d470d Add missing dependency to macho-dump.
r212094 added a few tests that use macho-dump.

llvm-svn: 212200
2014-07-02 18:16:31 +00:00
Tim Northover 9bdf90e5c2 [mach-o]: make the default dylib install-name the output filename.
llvm-svn: 212094
2014-07-01 08:41:45 +00:00
Tim Northover 301c4e690a [mach-o] add representation for LC_ID_DYLIB to MachONormalizedFile
It still needs to be tied into BinaryReader, but this allows reasonably
sensible creation of SharedLibrary atoms on MachO.

llvm-svn: 212093
2014-07-01 08:15:41 +00:00
Nick Kledzik 378066c80e [mach-o] improve errors when mixing architectures
llvm-svn: 212072
2014-06-30 22:57:33 +00:00
Tim Northover b5bf686b58 MachO: stop iterating past the end of an array
When trying to map atom types to sections, we were iterating through an array
until we hit a sentinel value. There's no need for such dances when range-based
for loops are available.

llvm-svn: 212035
2014-06-30 10:30:00 +00:00
Tim Northover 9ee9935358 MachO: re-enable writing of compact-unwind sections.
This isn't really the right place to put them in final object files (that would
be __TEXT,__unwind_info), but the format is different between relocatable and
final objects, which means we really need a pass to handle the translation.

For now, re-emitting in __LD,__compact_unwind is harmless (dyld ignores it and
moves straight on to inspecting __TEXT,__eh_frame), and sidesteps an assertion
failure when processing files containing compact-unwind info.

llvm-svn: 212032
2014-06-30 09:49:37 +00:00
Tim Northover 7b0a1306b4 MachO: align segment virtual addresses to page size.
Segments must occupy a multiple of the page size in memory (4096 currently). We
check for this when emitting files, but the placement algorithm broke down for
the second non-__TEXT segment encountered: the offset wasn't aligned up to 4096
before starting its layout.

llvm-svn: 212031
2014-06-30 09:49:33 +00:00
Tim Northover 08d6a7bfef MachO: calculate segment offsets in final MachO files properly.
Because of how we were calculating fileOffset and fileSize for segments, most
ended up at a single offset in a finalised MachO file. This meant the data
often didn't even get written in the final object, let alone where it would be
useful.

llvm-svn: 212030
2014-06-30 09:49:30 +00:00
Tim Northover f9b13d6766 MachO: support atomization of dylibs.
For .dylib files, we refrain from actually creating any atoms until they're
requested via the "exports" method.

llvm-svn: 212027
2014-06-30 09:11:38 +00:00
Nick Kledzik 3f69076278 [mach-o] refactor x86_64 relocation handling.
This is first step in reworking how mach-o relocations are processed.
The existing KindHandler is going to become a delgate/helper object for
processing architecture specific references.  The KindHandler knows how
to convert mach-o relocations into References and back, as well, as fixing
up the content the relocation is on.

One of the messy things about mach-o relocations is that they sometime 
come in pairs, but the pairs still convert to one lld::Reference. So, the
conversion has to detect pairs (arch specific) and change the stride.

llvm-svn: 211921
2014-06-27 18:25:01 +00:00
Simon Atanasyan 65e2464667 [Driver] Improve the `isPathUnderSysroot()` function. Now it returns a
correct result even if checking paths: a) symlinks and/or b) contains relative
parts like /dir1/dir2/../dir2.

llvm-svn: 211772
2014-06-26 10:48:52 +00:00
Tim Northover f48f0620ed [mach-o]: atomize zero-terminated literals correctly.
When looking through sections with zero-terminated string-literals (__cstring
or __ustring) we were constantly rechecking the first few bytes of the string
for '\0' rather than advancing along. This obviously failed unless all strings
within the section had the same length as that first one.

llvm-svn: 211682
2014-06-25 11:21:51 +00:00
Tim Northover 36bd9ab2c5 [mach-o] don't assume all sections have symbols
We were trying to examine the first symbol in a section that we wanted to
atomize by symbols, even when there wasn't one. Instead, we should make the
initial anonymous symbol cover the entire section in that situation.

llvm-svn: 211681
2014-06-25 10:59:37 +00:00
Simon Atanasyan d449fc8671 [ELF] Add two new virtual functions to the `OutputELFWriter` class to control
dynamic symbol table populating and DT_NEEDED tag creation.

The `isDynSymEntryRequired` function returns true if the specified shared
library atom requires a dynamic symbol table entry. The `isNeededTagRequired`
function returns true if we need to create DT_NEEDED tag for the shared
library defined specified shared atom.

By default the both functions return true. So there is no functional changes
for all targets except MIPS. Probably we need to spread the same modifications
on other ELF targets but I want to implement and fully tested complete set of
changes for MIPS target first.

For MIPS we create a dynamic symbol table entry for a shared library atom iif
this atom is referenced by a regular defined atom. For example, if library L1
defines symbol T1, library L2 defines symbol T2 and uses symbol T1
and executable file E1 uses symbol T2 but does not use symbol T1 we create
an entry in the E1 dynamic symbol table for symbol T2 and do not create
an entry for T1.

The patch creates DT_NEEDED tags for shared libraries contain shared library
atoms which a) referenced by regular defined atoms; b) have corresponding
copy dynamic relocations (R_MIPS_COPY).

Now the patch does not take in account --as-needed / --no-as-needed command
line options. So it is too restrictive and create DT_NEEDED tags for really
needed shared libraries only. I plan to fix that by subsequent patches.

llvm-svn: 211674
2014-06-25 07:55:55 +00:00
Simon Atanasyan 3b8c86b985 [Mips] Make rel-dynamic-03.test test case independent from external input files.
llvm-svn: 211491
2014-06-23 12:28:11 +00:00
Simon Atanasyan b1032ad260 [Mips] Make rel-dynamic-01.test test case independent from external input files.
llvm-svn: 211463
2014-06-22 11:58:08 +00:00
Simon Atanasyan e8a2875774 [Mips] Make rel-copy.test test case independent from external input files.
llvm-svn: 211355
2014-06-20 12:54:06 +00:00
Simon Atanasyan 825c5992d8 [Mips] Make r26-1.test test case independent from external input files.
llvm-svn: 211263
2014-06-19 10:18:58 +00:00
Rui Ueyama 61d7f97000 [PECOFF] Support COMDAT associative sections.
COFF supports a feature similar to ELF's section groups. This
patch implements it.

In ELF, section groups are identified by their names, and they are
treated somewhat differently from regular symbols. In COFF, the
feature is realized in a more straightforward way. A section can
have an annotation saying "if Nth section is linked, link this
section too."

I added a new reference type, kindAssociate. If a target atom is
coalesced away, the referring atom is removed by Resolver, so that
they are treated as a group.

Differential Revision: http://reviews.llvm.org/D4028

llvm-svn: 211106
2014-06-17 16:19:33 +00:00
Simon Atanasyan e5b03cb790 [Mips] Make plt-header.test test case independent from external input files.
llvm-svn: 211099
2014-06-17 13:08:11 +00:00
Simon Atanasyan 0469dbd43f [Mips] Make hilo16-5.test test case independent from external input files.
llvm-svn: 211017
2014-06-16 11:54:42 +00:00
Simon Atanasyan 004c49b017 [Mips] Make gp-sym-2.test test case independent from external input files.
llvm-svn: 210987
2014-06-15 12:04:40 +00:00
Simon Atanasyan 2e67be3cc2 [Mips] Make gp-sym-1.test test case independent from external input files.
llvm-svn: 210981
2014-06-14 21:18:50 +00:00
Simon Atanasyan 4156ac2ecd [Mips] Make exe-got.test test case independent from external input files.
llvm-svn: 210977
2014-06-14 12:55:03 +00:00
Simon Atanasyan f0f8207995 [Mips] Make exe-fileheader.test test case independent from external input files.
llvm-svn: 210893
2014-06-13 11:44:23 +00:00
Simon Atanasyan 033ecd1cc8 [Mips] Make exe-dynamic.test test case independent from external input files.
llvm-svn: 210796
2014-06-12 16:46:47 +00:00
Rui Ueyama 8ab4e2ce25 group-cmd-search test is not supposed to pass on Windows.
llvm-svn: 210697
2014-06-11 20:00:22 +00:00
Simon Atanasyan 87a06716e6 [Mips] Fix the bug -- symbol referred by the R_MIPS_TLS_GD relocation
does not get an entry in the dynamic symbol table.

llvm-svn: 210648
2014-06-11 10:08:08 +00:00
Nick Kledzik 936d5205bb [mach-o] fix use of resolver functions to not cause duplicate sections.
The previous commit uncovered a bug in the mach-o writer whereby two __text
sections were created.  But the test case did not catch that.  So I updated
the test case to run the linker a second time, reading the output of the
first pass.  

llvm-svn: 210624
2014-06-11 01:30:55 +00:00
Nick Kledzik 6085539bed [mach-o] add support for parsing resolver functions
llvm-svn: 210612
2014-06-11 00:24:16 +00:00
Simon Atanasyan 6790b14ebb [ELF] Fix the bug -- LLD crashes if the --whole-archive option
is around non-archive.

llvm-svn: 210530
2014-06-10 13:43:13 +00:00
Nick Kledzik b423266e93 [mach-o] parse multiple symbols on same address into aliases
llvm-svn: 210502
2014-06-09 23:35:37 +00:00
Simon Atanasyan 1de1d63aec [Mips] Make dt-textrel.test test case independent from external input files.
llvm-svn: 210469
2014-06-09 13:45:58 +00:00
Rui Ueyama c97b661475 Re-commit r210425.
llvm-svn: 210456
2014-06-09 08:57:37 +00:00
Rui Ueyama 8708a0ea7e Add missing dependency for check-lld.
llvm-svn: 210455
2014-06-09 08:42:38 +00:00
Rui Ueyama 2ad8c22a55 Revert "[Mips] Make got16.test test case independent from external input files."
This reverts commit r210425 because the test added in the commit
is broken.

llvm-svn: 210451
2014-06-09 08:23:58 +00:00
Simon Atanasyan 8804e5cb49 [Mips] Make got16.test test case independent from external input files.
llvm-svn: 210425
2014-06-08 11:33:05 +00:00
Simon Atanasyan c8e86fb032 [Mips] Handle Mips TLS relocations R_MIPS_TLS_GOTTPREL / R_MIPS_TLS_GD / R_MIPS_TLS_LDM etc.
llvm-svn: 210394
2014-06-07 13:20:53 +00:00
Simon Atanasyan 8065fb761e [Mips] Make dynlib-dynsym.test self contained.
llvm-svn: 210258
2014-06-05 12:39:12 +00:00
Rui Ueyama 0291dd2c8a Revert "[PECOFF] Support COMDAT associative sections."
This reverts accidental commit r210240.

llvm-svn: 210243
2014-06-05 07:40:59 +00:00
Rui Ueyama f3cb9d1d57 [PECOFF] Support COMDAT associative sections.
COFF supports a feature similar to ELF's section groups. This
patch implements it.

In ELF, section groups are identified by their names, and they are
treated somewhat differently from regular symbols. In COFF, the
feature is realized in a more straightforward way. A section can
have an annotation saying "if Nth section is linked, link this
section too."

Implementing such feature is easy. We can add a reference from a
target atom to an original atom, so that if the target is linked,
the original atom is also linked. If not linked, both will be
dead-stripped. So they are treated as a group.

I added a new reference type, kindAssociate. It does nothing except
preventing referenced atoms from being dead-stripped.

No change to the Resolver is needed.

Reviewers: Bigcheese, shankarke, atanasyan

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D3946

llvm-svn: 210240
2014-06-05 07:37:20 +00:00
Iain Sandoe c4d9bedcfc Initial set of Makefiles
This provides support for the autoconfing & make build style.
The format, style and implementation follows that used within the llvm and clang projects.

TODO: implement out-of-source documentation builds.
llvm-svn: 210177
2014-06-04 09:54:07 +00:00
Nick Kledzik a2d602560b [mach-o] Make anonymous atom out of section content before any symbol
In sections that are broken into atoms at symbols, if the first symbol in the
section is not at the start of the section, then make an anonymous atom for
the section content that is before the first symbol.

llvm-svn: 210142
2014-06-04 00:34:27 +00:00
Nick Kledzik cb9f890b77 [mach-o] Refactor sections -> atoms to be table driven.
Previously each section kind had its own code to loop over the section and
parse it into atoms.  This refactoring has two tables.  The first maps sections
to ContentType.  The second maps ContentType to information on how to find 
the atom boundaries.  

A few bugs in test cases were discovered as part of the refactoring.  
No change in functionality intended.

llvm-svn: 210138
2014-06-03 23:36:50 +00:00
Simon Atanasyan fd5b2346cc [Mips] Make la25-stub.test self contained.
No functional changes.

llvm-svn: 210094
2014-06-03 09:59:42 +00:00
Rui Ueyama 9aee050a0c Remove group-parent references.
Previously section groups are doubly linked to their children.
That is, an atom representing a group has group-child references
to its group contents, and content atoms also have group-parent
references to the group atom. That relationship was invariant;
if X has a group-child edge to Y, Y must have a group-parent
edge to X.

However we were not using group-parent references at all. The
resolver only needs group-child edges.

This patch simplifies the section group by removing the unused
reverse edge. No functionality change intended.

Differential Revision: http://reviews.llvm.org/D3945

llvm-svn: 210066
2014-06-03 03:07:49 +00:00
Rui Ueyama 23487e878b Make dead-striping to handle reverse edges.
Layout-before edges are no longer used for layout, but they are
still there for dead-stripping. If we would just remove them
from code, LLD would wrongly remove live atoms that were
referenced by layout-befores.

This patch fixes the issue. Before dead-stripping, it scans all
atoms to construct a reverse map for layout-after edges. Dead-
stripping pass uses the map to traverse the graph.

Differential Revision: http://reviews.llvm.org/D3986

llvm-svn: 210057
2014-06-03 01:59:02 +00:00
Simon Atanasyan 2c2486446c [Mips] Reduce number of input files used my Mips tests.
No functional changes.

llvm-svn: 210004
2014-06-02 04:20:01 +00:00