Commit Graph

871 Commits

Author SHA1 Message Date
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 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 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 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 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 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