Commit Graph

1209 Commits

Author SHA1 Message Date
Shankar Easwaran d87a021c79 [InputGraph][Gnu] Add LinkerScript support.
This adds LinkerScript support by creating a type Script which is of type
FileNode in the InputGraph. Once the LinkerScript Parser converts the
LinkerScript into a sequence of command, the commands are handled by the
equivalent LinkerScript node for the current Flavor/Target. For ELF, a
ELFGNULdScript gets created which converts the commands to ELF nodes and ELF
control nodes(ELFGroup for handling Group nodes).

Since the Inputfile type has to be determined in the Driver, the Driver needs
to determine the complete path of the file that needs to be processed by the
Linker. Due to this, few tests have been removed since the Driver uses paths
that doesnot exist.

llvm-svn: 195583
2013-11-24 23:12:36 +00:00
Shankar Easwaran 98758cbe85 [Gnu] Move code from .h to .cpp.
No change in functionality.

llvm-svn: 195582
2013-11-24 22:29:19 +00:00
Shankar Easwaran 67e98f5197 [InputGraph] Add capability to process Hidden nodes.
Hidden nodes could be a result of expansion, where a flavor might decide to keep
the node that we want to expand but discard it from being processed by the
resolver.

Verifies with unittests.

llvm-svn: 195516
2013-11-22 23:19:53 +00:00
Shankar Easwaran 3ac09bcb8f [InputGraph] Expand InputGraph nodes.
Flavors may like to expand InputGraph nodes, when a filenode after parsing
results in more elements. One such example is while parsing GNU linker scripts.
The linker scripts after parsing would result in a lot of filenodes and probably
controlnodes too.

Adds unittests to verify functionality.

llvm-svn: 195515
2013-11-22 23:08:24 +00:00
Rui Ueyama 82e366e78f [PECOFF] Do not set the entry address if /noentry option is given.
This is the first step towards DLL creation support. Resource-only DLLs
don't have entry point address.

llvm-svn: 195510
2013-11-22 22:52:15 +00:00
Rui Ueyama 340cdda2f6 Fix file header comment.
llvm-svn: 195393
2013-11-21 23:54:13 +00:00
Rui Ueyama fd133b300c Fix indentation and whitespace.
llvm-svn: 195389
2013-11-21 23:41:53 +00:00
Shankar Easwaran fb473c280f [test] Add InputGraph tests
llvm-svn: 195388
2013-11-21 23:37:45 +00:00
Shankar Easwaran 178324d903 [LinkingContext] Limit shared library undefined atoms to be added.
This adds functionality to limit shared library undefined atoms to be added
only once by the Resolver.

Dynamic libraries may be processed more than once if they exist within a
Group.

Also adds a test to verify the change.

llvm-svn: 195307
2013-11-21 03:50:59 +00:00
Rui Ueyama dae2ef47f1 [PECOFF] Move files with ".lib" extension to the end of the input file list.
It's allowed to specify library files *before* object files in the command
line. Object files seems to be processed first, and then their undefined
symbols are resolved from the libraries. This patch implements the compatible
behavior.

llvm-svn: 195295
2013-11-21 01:08:53 +00:00
Rui Ueyama 2a10b6401b [PECOFF] Do not check if library is already added.
llvm-svn: 195289
2013-11-21 00:43:46 +00:00
Rui Ueyama 90bcd114ac Rename allocateString -> allocate.
llvm-svn: 195284
2013-11-21 00:17:31 +00:00
Rui Ueyama 9c9d7d14d1 Reverse the condition for readability.
llvm-svn: 195282
2013-11-20 23:54:52 +00:00
Rui Ueyama 9114439df2 Move member functions to its own cpp file.
llvm-svn: 195281
2013-11-20 23:51:41 +00:00
Rui Ueyama 56215d84dc Remove blank return at the end of a function returning void.
llvm-svn: 195279
2013-11-20 23:12:03 +00:00
Rui Ueyama f8b41867c8 [PECOFF] Recognize but ignore /implib and /safeseh for now.
So that the LLD won't print error message saying that it couldn't find
/implib or /safeseh files.

llvm-svn: 195276
2013-11-20 21:57:30 +00:00
Rui Ueyama e05b629d39 Use NativeReferenceIvarsV2 if necessary.
NativeReferenceIvarsV1 cannot handle more than 65535 relocation targets
because its field to point to the target table is of type uint16_t. Because
of that limitation, the LLD couldn't link a file containing more than 65535
relocations. 65535 is not a big number - the LLD couldn't even link itself
with V1.

This patch solves the issue by adding NativeReferenceIvarsV2 support. The
new structure has more bits for the target table, so it can handle a large
number of relocatinos.

V2 structure is larger than V1. In order to prevent file bloating, V2 format
is used only when the resulting file cannot be represented in V1 format. The
writer and the reader support both V1 and V2 formats.

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

llvm-svn: 195270
2013-11-20 20:54:18 +00:00
Rui Ueyama 70f11d7589 Fix Weak External symbol handling.
The fallback atom was used only when it's searching for a symbol in a library;
if an undefined symbol was not found in a library, the LLD looked for its
fallback symbol in the library.

Although it worked in most cases, because symbols with fallbacks usually occur
only in OLDNAMES.LIB (a standard library), that behavior was incompatible with
link.exe. This patch fixes the issue so that the semantics is the same as
MSVC's link.exe

The new (and correct, I believe) behavior is this:

 - If there's no definition for an undefined atom, replace the undefined atom
   with its fallback and then proceed (e.g. look in the next file or stop
   linking as usual.)

Weak External symbols are underspecified in the Microsoft PE/COFF spec. However,
as long as I observed the behavior of link.exe, this seems to be what we want
for compatibility.

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

llvm-svn: 195269
2013-11-20 20:51:55 +00:00
Rui Ueyama 7b3c42a508 Do not inline large member functions. No functionality change.
llvm-svn: 195169
2013-11-19 23:40:44 +00:00
Rui Ueyama 4eb61120b5 Do not inline large member functions.
This should improve code readability as the class definitions are now
more readable than before.

llvm-svn: 195159
2013-11-19 22:12:26 +00:00
Rui Ueyama 935c5eda6f [PECOFF] Now that identify_magic() recognizes COFF import library.
No need to do that in ReaderCOFF.cpp.

llvm-svn: 195109
2013-11-19 06:29:57 +00:00
Rui Ueyama 03198d7cfa Remove meaningless "explicit" keywords.
llvm-svn: 195108
2013-11-19 06:20:56 +00:00
Rui Ueyama d9b26dc84b Remove extraneous curly braces and blank lines.
llvm-svn: 195107
2013-11-19 06:18:39 +00:00
Rui Ueyama 9a01d155b6 Use early continue. Style fix. No functionality change.
llvm-svn: 195106
2013-11-19 06:10:13 +00:00
Rui Ueyama d52cfdc9ab [PECOFF] Ignore /tlbid, /tlbout, /idlout and /ignoreigl for now.
llvm-svn: 195105
2013-11-19 05:55:08 +00:00
Rui Ueyama 86f32f40cf Use UINT16_MAX instead of 0xFFFF.
llvm-svn: 195096
2013-11-19 03:48:23 +00:00
Rui Ueyama 265134c731 Write temporary file names if debugging is enabled.
llvm-svn: 195062
2013-11-19 00:11:28 +00:00
Rui Ueyama 69c71cc827 Simplify. No functionality change.
llvm-svn: 195051
2013-11-18 22:42:03 +00:00
Rui Ueyama 11d1f18783 Replace unnecessary vector copy with reference.
llvm-svn: 194988
2013-11-18 04:05:28 +00:00
Rui Ueyama 2bafe7353e Add an assert for NativeReferenceIvarsV1.
The maximum number of references the file with NativeReferenceIvarsV1 can
contain is 65534. If a file larger than that is converted to Native format,
the conversion will fail without any error message. This caused a subtle bug
that the LLD would produce a broken executable only when input files contain
too many references.

This issue exists since the RoundTripNativeTest is introduced in r193585. Since
then, it seems that nobody have linked any program having more than 65534
relocations with the LLD. Otherwise we would have found it earlier.

llvm-svn: 194987
2013-11-18 03:50:50 +00:00
Rui Ueyama f45198b4bf Remove superfluous "explicit" keyword.
llvm-svn: 194982
2013-11-17 22:05:24 +00:00
Rui Ueyama b37c431d53 Move the entire debug print loop into DEBUG_WITH_TYPE.
No functionality change.

llvm-svn: 194914
2013-11-16 01:41:47 +00:00
Rui Ueyama a3ada6b0f7 Replace one more magic number with sizeof().
llvm-svn: 194913
2013-11-16 01:31:24 +00:00
Rui Ueyama 5dcabbc9e8 Use early continue.
llvm-svn: 194911
2013-11-16 01:14:37 +00:00
Rui Ueyama e4d20ab786 Simplify. No functionality change.
llvm-svn: 194909
2013-11-16 01:01:35 +00:00
Rui Ueyama 4072d91a58 Replace duplicate code with calls to getOrPushAttribute().
llvm-svn: 194908
2013-11-16 00:55:08 +00:00
Rui Ueyama 12027e58e1 Use range-based for loop.
end() was evaluated every time through a loop. This patch eliminates it.

llvm-svn: 194894
2013-11-15 23:53:32 +00:00
Rui Ueyama 249becb831 Use llvm_unreachable() instead of assert() at where control should never get.
llvm-svn: 194890
2013-11-15 23:36:48 +00:00
Rui Ueyama 559b0aa89e Duplicate code removal.
llvm-svn: 194887
2013-11-15 23:28:58 +00:00
Rui Ueyama 085886430a Replace magic number with sizeof(). No functionality change.
llvm-svn: 194877
2013-11-15 23:11:00 +00:00
Rui Ueyama 3f823e3af1 Remove duplicate code.
llvm-svn: 194866
2013-11-15 22:37:34 +00:00
Rui Ueyama fbd82d0813 [PECOFF] Use INT3 instead of NOP.
This patch does not change the meaning of the program, but if something's wrong
in the linker or the compiler and the control reaches to the gap of imported
function table, it will stop immediately because of the presence of INT3. If
NOP, it'd fall through to the next call instruction, which is usually a
completely foreign function call.

llvm-svn: 194860
2013-11-15 22:11:43 +00:00
Rui Ueyama 94f2271d63 [PECOFF] Remove unnecessary static member.
llvm-svn: 194851
2013-11-15 21:12:11 +00:00
Rui Ueyama 9442a79914 [PECOFF] Give a better name to the linker generated file.
llvm-svn: 194847
2013-11-15 21:04:23 +00:00
Rui Ueyama 9a4fd7e582 Fix Windows buildbot on which size_t is not unsinged long.
llvm-svn: 194793
2013-11-15 08:08:29 +00:00
Rui Ueyama dbce022caf [PECOFF] Minimum size of DOS stub is 64 byte.
llvm-svn: 194791
2013-11-15 08:00:22 +00:00
Rui Ueyama 478d9f9e7d [PECOFF] Avoid using statically initialized std::vector.
Also slightly reduces PECOFFLinkingContext's memory footprint (~128B).

llvm-svn: 194787
2013-11-15 05:45:20 +00:00
Rui Ueyama 3429d01f1a Refactor copy-paste-and-modifed code using callback.
llvm-svn: 194784
2013-11-15 04:58:54 +00:00
Rui Ueyama b4dca7f065 Select new undefined atom rather than old one if other conditions are the same.
We can add multiple undefined atoms having the same name to the symbol table.
If such atoms are added, the symbol table compares their canBeNull attributes,
and select one having a stronger constraint. If their canBeNulls are the same,
the choice is arbitrary. Currently it choose the existing one.

This patch changes the preference, so that the symbol table choose the new one
if the new atom has a greater canBeNull or a fallback atom. This shouldn't
change the behavior except the case described below.

A new undefined atom may have a new fallback atom attribute. By choosing the new
atom, we can update the fallback atom during Core Linking. PE/COFF actually need
that. For example, _lseek is an alias for __lseek on Windows. One of an object
file in OLDNAMES.LIB has an undefined atom for _lseek with the fallback to
__lseek. When the linker tries to resolve _read, it supposed to read the file
from OLDNAMES.LIB and use the new fallback from the file. Currently LLD cannot
handle such case because duplicate undefined atoms with the same attributes are
ignored.

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

llvm-svn: 194777
2013-11-15 03:12:24 +00:00
Rui Ueyama 014192dbda Fix include guards.
llvm-svn: 194776
2013-11-15 03:09:26 +00:00
Rui Ueyama 1c6fd20427 [PECOFF] Add tests for r194757.
llvm-svn: 194768
2013-11-15 02:31:47 +00:00
Rui Ueyama e60d6e1b07 [PECOFF] Add /stub option.
llvm-svn: 194757
2013-11-15 00:18:41 +00:00
Rui Ueyama 5fe806e7a4 Move DOS stub data to PECOFFLinkingContext for /stub option.
llvm-svn: 194754
2013-11-14 23:54:24 +00:00
Rui Ueyama 9c082cd8dd Don't use getFileOrStdin() at where we don't want to read from stdin.
llvm-svn: 194746
2013-11-14 23:21:25 +00:00
Rui Ueyama 7eaa44c0bc Test: Move input redirections at the end of the line.
Writing arguments after the redirection of input ("< somefile") seems a bit
strange. Changes the order.

llvm-svn: 194727
2013-11-14 20:52:28 +00:00
Rui Ueyama 73ca00ca72 Test for r194671.
llvm-svn: 194723
2013-11-14 19:18:54 +00:00
Rui Ueyama fef5d42ef3 Fix trailing whitespace and indentation.
llvm-svn: 194722
2013-11-14 19:18:52 +00:00
Rui Ueyama 83ad675dd3 Use makeArrayRef(). No functionality change.
llvm-svn: 194721
2013-11-14 18:57:34 +00:00
Rui Ueyama aa85517303 Fix indentation and delete trailing whitespace.
llvm-svn: 194677
2013-11-14 06:58:32 +00:00
Rui Ueyama 519b9e357f Use makeArrayRef() to make ArrayRef from C array.
llvm-svn: 194675
2013-11-14 06:52:35 +00:00
Rui Ueyama 9310e01ea9 Terminate if there are un-mergeable duplicate atoms.
llvm-svn: 194671
2013-11-14 06:39:31 +00:00
Rui Ueyama 657ec494fa [PECOFF] Make the import library file magic more accurate.
llvm-svn: 194668
2013-11-14 06:15:18 +00:00
Rui Ueyama 404e97c3a2 Avoid parsing large YAML file.
YAML files tend to be very large compared to binary formats because of ASCII
format inefficiency. And the YAML reader consumes an excessively large amount
of memory when parsing a large file. It's very slow too.

For example, I observed that 6MB executable became 120MB YAML file, and the
YAML reader consumed more than 1.5GB memory to load it. The YAML reader even
caused OOM error on 32 bit, causing the entire process to fail.

This patch sets the limit on the YAML file size the linker will try to load in
the RoundTripYAML test as a safeguard.

llvm-svn: 194666
2013-11-14 05:57:54 +00:00
Michael J. Spencer 7a2080793e Whitespace.
llvm-svn: 194643
2013-11-14 00:52:05 +00:00
Michael J. Spencer db52824dfa [PECOFF] Add missing dependency.
This dependency needs to be cleaned up at some point. .directve handling needs the link.exe option parser.

llvm-svn: 194642
2013-11-14 00:51:51 +00:00
Michael J. Spencer bb0919968b Move InputGraph from Driver to Core. LinkingContext depends on it.
llvm-svn: 194641
2013-11-14 00:51:33 +00:00
Rui Ueyama 0acd8243e3 Remove default label from fully covered switch.
llvm-svn: 194624
2013-11-13 23:33:49 +00:00
Rui Ueyama bcccb5db2e Show error message if two atoms are not mergeable.
llvm-svn: 194620
2013-11-13 23:23:38 +00:00
Rui Ueyama f347e7533f Fix indentation, use early return.
llvm-svn: 194619
2013-11-13 23:22:00 +00:00
Rui Ueyama cc10b5b07e [PECOFF] Make ReaderCOFF more robust against planned identity_magic() changes.
No functionality change.

llvm-svn: 194560
2013-11-13 07:04:33 +00:00
Rui Ueyama 6ac5dc379b Re-submit r194551: Use empty() instead of size() == 0.
llvm-svn: 194556
2013-11-13 05:19:47 +00:00
Rui Ueyama e20474d38c Revert "Use empty() instead of size() == 0."
This reverts commit r194551 because it broke the buildbot.

llvm-svn: 194552
2013-11-13 03:30:29 +00:00
Rui Ueyama 2235bff2b9 Use empty() instead of size() == 0.
llvm-svn: 194551
2013-11-13 03:09:20 +00:00
Rui Ueyama 12f390856c Fix misleading indentation.
llvm-svn: 194550
2013-11-13 03:00:48 +00:00
Rui Ueyama e653f1d12c [PECOFF] Fix use-after-return.
llvm-svn: 194545
2013-11-13 02:21:51 +00:00
Rui Ueyama 3314f56ca8 [PECOFF] Do not print error if length of .drectve is 0.
llvm-svn: 194539
2013-11-13 01:19:08 +00:00
Rui Ueyama 3f902b2788 [MachO] Simplify conditionals. No functionality change.
llvm-svn: 194492
2013-11-12 17:46:55 +00:00
Alp Toker c544d5b7e8 Get lld building with MSVC2013
llvm-svn: 194481
2013-11-12 15:14:33 +00:00
Rui Ueyama 5c2ed5f154 Delete unused constructor.
llvm-svn: 194364
2013-11-11 05:03:31 +00:00
Shankar Easwaran 29ffee7af9 [cleanup] remove readFile and replace with getBuffer.
no functionality change.

llvm-svn: 194360
2013-11-11 02:13:30 +00:00
Shankar Easwaran ba470fa875 [InputGraph] remove unused functions.
llvm-svn: 194359
2013-11-11 01:03:49 +00:00
Rui Ueyama 78d1acb3af [ELF] Un-break undef-from-main-dso.test on MSVC 2012.
The result of sizeof(SymbolTable<ELFT>::SymbolEntry) in DynamicSymbolTable
<ELFT>::write() was different from the same expression in RelocationTable
<ELFT>::write(), although the same template parameters were passed. They were
40 and 32, respectively. As a result, the same vector was treated as a
vector of 40 byte values in some places and a vector of 32 values in other
places. That caused an weird issue, resulting in collapse of the rela.dyn
section.

I suspect that this is a padding size calculation bug in MSVC 2012, but I
may be wrong. Reordering the fields to eliminate padding seems to fix the
issue.

llvm-svn: 194349
2013-11-10 07:48:33 +00:00
Rui Ueyama 980c6d518e Remove empty namespace.
llvm-svn: 194322
2013-11-09 05:57:20 +00:00
Nick Kledzik 00a15d9428 [mach-o] Use LEB128 stuff from llvm/Support. No functionality change.
llvm-svn: 194305
2013-11-09 01:00:51 +00:00
Nick Kledzik 29f749eef8 [mach-o] reduce duplicate source code by using a templated method. No functionality change.
llvm-svn: 194299
2013-11-09 00:07:28 +00:00
Nick Kledzik 1b30228994 [mach-o] revert gunk added to test cases to debug build bot failures
llvm-svn: 194292
2013-11-08 23:18:51 +00:00
Nick Kledzik 705cbc1733 [mach-o] fix uninitialized variable
llvm-svn: 194290
2013-11-08 23:00:26 +00:00
Nick Kledzik 5eb9bfc863 [mach-o] add debugging to help explain one build bot failure
llvm-svn: 194280
2013-11-08 21:43:28 +00:00
Michael J. Spencer b8ab9f52ca Add explictly exported atoms and export R_*_COPY'ed atoms.
llvm-svn: 194278
2013-11-08 21:04:20 +00:00
Nick Kledzik d0784941fe [mach-o] fix memory ownership in test case
llvm-svn: 194187
2013-11-07 02:56:53 +00:00
Nick Kledzik 3c686e3561 add debug logging to help figure out why some tests fail on some build bots
llvm-svn: 194186
2013-11-07 01:27:47 +00:00
Nick Kledzik 471c00cfcb Hopefully fix latent bug where lldCore dependency on lldYAML was not in CMake files
llvm-svn: 194177
2013-11-06 22:56:42 +00:00
Nick Kledzik f3e89cb802 [mach-o] fix EXPECT_EQ types
llvm-svn: 194173
2013-11-06 22:20:56 +00:00
Nick Kledzik 020fa7f080 [mach-o] add llvm_unreachable
llvm-svn: 194172
2013-11-06 22:18:09 +00:00
Nick Kledzik 020a49c95d [mach-o] fix DEBUG_WITH_TYPE to compile without warnings in non-debug case
llvm-svn: 194171
2013-11-06 21:57:52 +00:00
Nick Kledzik 143b5e8237 [mach-o] make unspecifiedPageZeroSize const to fix VC++ error
llvm-svn: 194169
2013-11-06 21:47:37 +00:00
Nick Kledzik e34182f396 [mach-o] binary reader and writer
This patch adds support for converting normalized mach-o to and from binary
mach-o. It also changes WriterMachO (which previously directly wrote a 
mach-o binary given a set of Atoms) to instead do it in two steps. The first 
step uses normalizedFromAtoms() to convert Atoms to normalized mach-o, and the
second step uses writeBinary() which to generate the mach-o binary file.  

llvm-svn: 194167
2013-11-06 21:36:55 +00:00
Nick Kledzik 3df8104eee rename local variable to avoid shadowing warning
llvm-svn: 194166
2013-11-06 21:30:15 +00:00
Rui Ueyama 41b99dce59 [PECOFF] Rename getSectionAlignment -> getSectionDefaultAlignment.
These fields are for /align option. Section alignment can be set per-section
basis with /section option too. In order to avoid name conflicts, rename the
existing identifiers to become more specific. No functionality change.

llvm-svn: 194160
2013-11-06 19:30:14 +00:00
Rui Ueyama 108b371373 [PECOFF] Add /section option.
/section command line option is to set/reset attributes of the Characteristics
field in the section header. You can set non-default values with this option.
You can make .data section executable with this, for example.

This patch implements the parser of the command line option. The code to use
the parsed values will be committed in a separate patch.

llvm-svn: 194133
2013-11-06 07:31:55 +00:00
Rui Ueyama 67b277c34f [PECOFF] Make /disallowlib an alias for /nodefaultlib.
I'm not sure if it is really an alias for /nodefaultlib, but I can say that
they are at least similar. Making it an alias would be better than ignoring it.

llvm-svn: 194131
2013-11-06 05:48:45 +00:00
Rui Ueyama 589276cd25 [PECOFF] Do not expose _noDefaultLibs. No functionality change.
llvm-svn: 194130
2013-11-06 05:17:00 +00:00
Rui Ueyama 249c7b335e [PECOFF] Do not add the same library to the input graph more than once.
/defaultlib options can be specified implicitly via the .drectve section, and
it's pretty common that multiple object files add the same library, such as
user32.lib, to the input. We shouldn't add the same library multiple times.

llvm-svn: 194129
2013-11-06 05:13:20 +00:00
Rui Ueyama e1c30a4e04 Undef a local macro after use.
llvm-svn: 194128
2013-11-06 04:47:19 +00:00
Rui Ueyama d213a9ed3c [PECOFF] Do not wrap the linker internal file with an archive file.
We wrapped the linker internal file with a virtual archive file, so that the
linker internal file was linked only when it's actually used. This was to avoid
__ImageBase being included to the resulting executable. __ImageBase used to
occupy four bytes when emitted to executable.

And then it turned out that the implementation of __ImageBase was wrong -- it
shouldn't have been a regular atom but an absolute atom. Absolute atoms point
to some memory location, but they don't occupy disk space themselves. So it
wouldn't increase executable size (except the symbol table.) That means that
it's OK to link the linker internal file unconditionally.

So this patch does that, removing the wrapper archive file. Doing this
simplifies the code.

llvm-svn: 194127
2013-11-06 04:30:55 +00:00
Rui Ueyama c13f43f4f9 [PECOFF] Ignore /disallowlib.
msvcrt.lib contains "/disallowlib" command line option in its .drectve section.
I couldn't spot any documentation for the option. Ignore it for now so that we
can link the library without error.

llvm-svn: 194114
2013-11-06 00:44:10 +00:00
Rui Ueyama 7e77a294dc [PECOFF] Report error if there's unknown flag in .drectve
Errors in .drectve section were silently ignored. This patch fixes the issue.

llvm-svn: 194110
2013-11-05 23:53:15 +00:00
Rui Ueyama aa1335990f Remove extraneous parentheses.
llvm-svn: 194089
2013-11-05 18:43:10 +00:00
Rui Ueyama c1800beb55 Remove unnecessary namespace qualifier.
llvm-svn: 194037
2013-11-05 01:37:40 +00:00
Rafael Espindola 75c2ae9664 Replace ErrorOr<void> with error_code.
It was never transporting any value in addition to the error_code.

llvm-svn: 194028
2013-11-05 00:09:36 +00:00
Simon Atanasyan 8ef39b53e5 [ELF] Fix typo in the expression calculates an absolute atom offset.
Patch reviewed by Shankar Easwaran.

llvm-svn: 194010
2013-11-04 19:40:02 +00:00
Rui Ueyama 5efbc6379e [PECOFF] Fix the test to run.
llvm-svn: 194003
2013-11-04 19:01:57 +00:00
Rui Ueyama f23b27a837 [PECOFF] Add a test for the resource file.
llvm-svn: 193982
2013-11-04 05:17:54 +00:00
Rui Ueyama 2c717faa19 [ELF] Allow colons in the path.
This patch should fix the test when it runs on Windows, by allowing drive
letter separator (colon) in the path. Now all LLD ELF tests passed on MSVC
2012 32-bit. Hooray!

llvm-svn: 193978
2013-11-04 04:30:37 +00:00
Rui Ueyama 1c392a5611 [ELF] Simplify SectionTable::getSymbolTableIndex. No functionality change.
MSVC 2012 raises an error in the lambda passed to vector::find_if, while it
seems valid code. Rewrote without high-order functions.

llvm-svn: 193975
2013-11-04 03:24:14 +00:00
Rui Ueyama 0a5802a260 [ELF] Add missing -target option.
llvm-svn: 193974
2013-11-04 03:08:55 +00:00
Rafael Espindola 3c4739cc11 Update test now that llvm-nm prints the correct value.
llvm-svn: 193913
2013-11-02 05:21:29 +00:00
Rui Ueyama 329211bbb7 [ELF] One more file for missing -target option.
llvm-svn: 193911
2013-11-02 03:55:51 +00:00
Rui Ueyama 2ccdfb219d [ELF] Add missing -target options.
These tests assume that the created objects are for x86_64. These tests
failed on non-x86_64 environments, such as 32 bit Windows.

llvm-svn: 193910
2013-11-02 03:50:03 +00:00
Rui Ueyama d19d0bc5d2 [MachO] Fix uninitialized field bug found on Windows.
n_desc field in MachO string table was not initialized. On Unix,
test/darwin/hello-world.objtxt did not fail because I think an nlist object
is always allocated to a fresh heap initialized with zeros. On Windows,
uninitialized fields are filled with 0xCC when compiled with /GZ. Because
of that the test was failing on Windows.

llvm-svn: 193909
2013-11-02 03:35:45 +00:00
Rui Ueyama e4aaa335dd Single-quotes to quote parentheses.
On Windows, neither "(" nor ")" are shell special characters, so -\( is passed
as-is to LLD. Because of that this test was failing on Windows.

llvm-svn: 193905
2013-11-02 02:07:37 +00:00
Rui Ueyama 9625b5435b Fix test on 32 bit.
This patch adds "-target x86_64" to the command line. Without this option,
a 32 bit object file would be created on 32 bit machine, resulting in test
failure.

llvm-svn: 193904
2013-11-02 01:55:42 +00:00
Rui Ueyama 450f422b49 [PECOFF] Remove unnecessary assertion.
Bugs that would be caught by this assertion would also be caught by
RoundTripYAMLPass test. We've enabled the pass for PECOFF, so we can remove
this.

llvm-svn: 193886
2013-11-01 21:11:43 +00:00
Rui Ueyama aa5b4dc868 Remove duplicate calls of pm.add() for RoundTrip tests.
llvm-svn: 193885
2013-11-01 21:05:42 +00:00
Rui Ueyama c74157ca30 Remove redundant std::move().
llvm-svn: 193883
2013-11-01 20:40:33 +00:00
Rui Ueyama 31e44e964d Whitespace
llvm-svn: 193882
2013-11-01 19:54:29 +00:00
Rui Ueyama c9752fa66d [PECOFF] Enable RoundTrip{YAML,Native}Pass.
llvm-svn: 193881
2013-11-01 19:52:37 +00:00
Rui Ueyama 1d1debf126 [PECOFF] Change data directory atom structure.
The data directory in the PE/COFF header consisted of list of data directory
atoms. This patch changes it -- now there's only one data directory entry that
contains former data directories. That's easier to handle in the writer as well
as to write to/read from YAML/Native files. The main purpose of this refactoring
is to enable RoundTrip tests for PE/COFF.

There's no functionality change.

llvm-svn: 193854
2013-11-01 05:51:15 +00:00
Rui Ueyama 39233f252b [PECOFF] File extension is case-insensitive on Windows.
llvm-svn: 193797
2013-10-31 20:06:48 +00:00
Rui Ueyama bad4565be0 Revert "[PECOFF] Add atoms to the PassManager file"
This reverts commit r193479.

The atoms are already added to the file, so re-adding them caused the YAML
writer to write the same atoms twice. That made the YAML reader to fail with
"duplicate atom name" error.

This is not the only error we've got for RoundTripYAMLPass for PECOFF, so we
cannot enable the test yet. More fixes will come.

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

llvm-svn: 193762
2013-10-31 16:59:49 +00:00
Rui Ueyama 7a1ac04fe2 Use StringRef::startswith_lower().
llvm-svn: 193712
2013-10-30 20:33:51 +00:00
Michael J. Spencer 5fbce5bd56 [ELF] Implement minimal support for .eh_frame_hdr.
llvm-svn: 193662
2013-10-30 00:02:04 +00:00
Rui Ueyama 5c8d4dd73f [PECOFF] Suppress startup message of background processes.
llvm-svn: 193646
2013-10-29 19:52:44 +00:00
Shankar Easwaran b1ffd99b6a [FileToMutable] Garbage collect unused private member
llvm-svn: 193588
2013-10-29 05:33:52 +00:00
Shankar Easwaran 51bfb820cc [test] Fix a test failure, this test is only applicable in debug mode
llvm-svn: 193586
2013-10-29 05:26:49 +00:00
Shankar Easwaran 2bc24928d3 [PassManager] add ReaderWriter{Native,YAML} to the Driver.
Enable this for the following flavors

a) core
b) gnu
c) darwin

Its disabled for the flavor PECOFF. Convenient markers are added with FIXME
comments in the Driver that would be removed and code removed from each flavor.

llvm-svn: 193585
2013-10-29 05:12:14 +00:00
Rui Ueyama 3aca58f135 Fix spelling.
llvm-svn: 193584
2013-10-29 04:54:50 +00:00
Rui Ueyama 90173df289 [PECOFF] Fix __ImageBase symbol.
__ImageBase is an absolute symbol whose address is the same as the image base
address. What we did before this patch was to create __ImageBase symbol as a
symbol whose *contents* (not location) is the image base address, which is
clearly wrong.

llvm-svn: 193565
2013-10-29 00:33:34 +00:00
Rui Ueyama 6ecc4383fb Fix comment.
llvm-svn: 193557
2013-10-28 23:34:41 +00:00
Rui Ueyama 446cc3cc58 [PECOFF] Set section name for BSS atoms.
This change has no effect now, but will be needed to emit BSS atoms
to .bss section.

llvm-svn: 193556
2013-10-28 23:26:33 +00:00
Nick Kledzik 58ea44993b [MachO] pointer align linker generated (non)lazy pointers
llvm-svn: 193551
2013-10-28 22:48:33 +00:00
Chandler Carruth 9204c8319d Rather than rendering an argument to a std::string (which is primarily
intended for debugging and diagnostic output), just inspect the spelling
to check for specific prefixes in drectve section flags.

In addition to being significantly cheaper and not relying on
a debugging interface, this also avoids creating a temporary string and
binding it to StringRef variable. We then went on to access it after the
memory had been deallocated.

This bug too was caught by ASan. I love ASan so much. =]

llvm-svn: 193487
2013-10-27 00:10:43 +00:00
Chandler Carruth 50e5b3298c Use equals_lower() rather than creating a temporary string with lower().
More important than any performance concerns, the code was dropping the
temporary string on the floor after assigning it to a StringRef, and
then used the StringRef later. Caught by running the LLD tests under
ASan.

llvm-svn: 193486
2013-10-26 23:53:06 +00:00
Shankar Easwaran fe0b80b321 [ELF][test] Remove default section names for known contentTypes.
llvm-svn: 193483
2013-10-26 19:38:42 +00:00
Shankar Easwaran 6775518254 [ELF] Fix RO/RW note sections.
llvm-svn: 193482
2013-10-26 19:38:39 +00:00
Shankar Easwaran b0022c00a3 [X86_64] Fix the atom that need to be exported.
llvm-svn: 193481
2013-10-26 19:38:37 +00:00
Shankar Easwaran 5afd25dcac [X86] Add more relocation types.
llvm-svn: 193480
2013-10-26 19:38:35 +00:00
Shankar Easwaran 8ad2dee6d6 [PECOFF] Add atoms to the PassManager file
llvm-svn: 193479
2013-10-26 19:38:33 +00:00
Shankar Easwaran 53bae6fa66 [PECOFF] Add COFF relocations to encode/decode to/from YAML files
llvm-svn: 193478
2013-10-26 19:38:31 +00:00
Shankar Easwaran 3176d61332 [PECOFF] Add dataDirectoryEntry as a recognized ContentType
llvm-svn: 193477
2013-10-26 19:38:29 +00:00