Commit Graph

1124 Commits

Author SHA1 Message Date
Rui Ueyama 139ae4c931 [PECOFF] Parse /manifest command line option.
The manifest file is an XML file that conveys some information to the loader,
such as whether the executable needs to run as Administrator or not. This patch
is to parse command line option for manifest file.

Actual XML file generation will be done in a separate patch.

llvm-svn: 193141
2013-10-22 03:49:35 +00:00
Rui Ueyama f1d0d777c9 Revert "Initialize some members where they are declared."
Because MSVC11 doesn't like this new C++11 feature. The last commit
broke the buildbot.

llvm-svn: 193127
2013-10-21 22:37:14 +00:00
Rui Ueyama 1e375f55d5 Initialize some members where they are declared. No functionality change.
llvm-svn: 193122
2013-10-21 22:25:02 +00:00
Rui Ueyama 53e77efac3 Disable layout-transitivity test on Darwin for now.
llvm-svn: 193121
2013-10-21 22:19:27 +00:00
Rui Ueyama 9b759d9fa2 Simplify WinLinkDriver. No functionality change.
llvm-svn: 193030
2013-10-19 03:34:00 +00:00
Rui Ueyama 46bf8286db Fix bug that CompareAtoms::compare is not transitive.
This patch fixes a bug in r190608. The results of a comparison function
passed to std::sort must be transitive, which is, if a < b and b < c, and if
a != b, a < c must be also true. CompareAtoms::compare did not actually
guarantee the transitivity. As a result the sort results were sometimes just
wrong.

Consider there are three atoms, X, Y, and Z, whose file ordinals are 1, 2, 3,
respectively. Z has a property "layout-after X". In this case, all the
following conditionals become true:

  X < Y because X's ordinal is less than Y's
  Y < Z because Y's ordinal is less than Z's
  Z < X because of the layout-after relationship

This is not of course transitive. The reason why this happened is because
we used follow-on relationships for comparison if two atoms falls in the same
follow-on chain, but we used each atom's properties if they did not. This patch
fixes the issue by using follow-on root atoms for comparison to get consistent
results.

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

llvm-svn: 193029
2013-10-19 03:18:18 +00:00
Rui Ueyama 1ce8a0a8ed [PECOFF] Only COMDAT symbols are allowed to be dead-stripped.
We should dead-strip atoms only if they are created for COMDAT symbols. If we
remove non-COMDAT atoms from a binary, it will no longer be guaranteed that
the binary will work correctly.

In COFF, you can manipulate the order of section contents in the resulting
binary by section name. For example, if you have four sections
.data$unique_prefix_{a,b,c,d}, it's guaranteed that the contents of A, B, C,
and D will be consecutive in the resulting .data section in that order.
Thus, you can access B's and C's contents by incrementing a pointer pointing
to A until it reached to D. That's why we cannot dead-strip B or C even if
no one is directly referencing to them.

Some object files in the standard library actually use that technique.

llvm-svn: 193017
2013-10-18 23:54:55 +00:00
Rui Ueyama f47fa51c69 Fill the atom gap with INT 3 instead of NOP.
INT 3 (machine code 0xCC) will raise an interrupt when executed. That is better
for filling the gap than NOP because we want to stop the execution immediately
when the control reached to non-code address.

llvm-svn: 192945
2013-10-18 03:23:33 +00:00
Shankar Easwaran 0879c1e601 [Native] Fix fallback atoms when writing to Native file.
There is no test as currently there is no call to the NativeWriter.

Future commits will add calls to the NativeWriter.

llvm-svn: 192944
2013-10-18 03:23:24 +00:00
Rui Ueyama 5206222faf Fix -Wunused-function warning of release build.
llvm-svn: 192943
2013-10-18 03:18:54 +00:00
Rui Ueyama 4050b20b04 Fix a layout pass debug message.
llvm-svn: 192942
2013-10-18 03:18:52 +00:00
Rui Ueyama 6a607b6a3b Improve debug message of the layout pass.
Instead of showing multiple lines of debug messages, show only one message
by CompareAtoms::operator(). Here is an example.

Before:
  Sorting _main .text
  Sorting by sectionPos(2,2)
  Sorting by override
  Sorting _main .text
  Sorting by sectionPos(2,2)
  Sorting by override

After:
  Layout: '_main' > '.text' (override (1, 0))
  Layout: '_main' > '.text' (override (1, 0))

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

llvm-svn: 192941
2013-10-18 02:56:31 +00:00
Shankar Easwaran b6c825a5cf [ELF] Set ordinals properly to all atoms.
llvm-svn: 192939
2013-10-18 02:12:17 +00:00
Rui Ueyama cf671439be Fill gap in .text with NOP.
llvm-svn: 192930
2013-10-17 22:45:16 +00:00
Rui Ueyama f3630fe4be Make undefines check into an assertion.
Dead-strip root symbols can be undefined atoms, but should not really be
nonexistent, because dead-strip root symbols should be added to initial
undefined atoms at startup. Whenever you look up its name in the symbol
table, some type of atom will always exist.

llvm-svn: 192831
2013-10-16 19:21:50 +00:00
Rui Ueyama fbca0337b5 Run CVTRES.EXE on resource files.
llvm-svn: 192830
2013-10-16 19:21:45 +00:00
Rui Ueyama c726c1962d Fix a bug that the empty string could be added to dead strip root.
llvm-svn: 192772
2013-10-16 05:06:52 +00:00
Rui Ueyama 2847831771 Propagate deadStripOptimize()'s failure to the caller.
We want to make the program to exit with non-zero exit code if there's an error
during dead stripping.

llvm-svn: 192771
2013-10-16 05:03:39 +00:00
Nick Kledzik 2453a3d956 Bug 17569: add namespaces to work with gcc-4.7
llvm-svn: 192627
2013-10-14 21:24:48 +00:00
Shankar Easwaran 2595e71849 [cleanup] Remove single-statement if blocks
llvm-svn: 192614
2013-10-14 19:58:12 +00:00
Rui Ueyama a1490d616f Prune unused local variable.
llvm-svn: 192509
2013-10-11 22:02:58 +00:00
Shankar Easwaran 11202deb4a [ELF] Add alias options for start-group/end-group options.
There are aliases for --start-group/--end-group options represented
by -( and -) respectively in the command line.

This change adds and improves the test for the alias options to be
tested.

Looks like users use this option widely than explicitly using
--start-group/--end-group.

llvm-svn: 192470
2013-10-11 17:59:47 +00:00
Rui Ueyama 8e5c2788f6 Simplify unique_ptr instantiation. No functionality change.
llvm-svn: 192427
2013-10-11 07:42:08 +00:00
Rui Ueyama 2ad117db97 Propagate Resolver::resolveUndefines()'s failure to caller.
llvm-svn: 192424
2013-10-11 06:26:16 +00:00
Rui Ueyama f1e266846d Remove excessive allowRemainingUndefines() check.
allowRemainingUndefines() is already checked in Resolver::resolve(), so we
don't need to check it again after returning from it. It's actually not only
superfluous but buggy because a failure of resolve() does not always mean that
there is a remaining undefines.

llvm-svn: 192423
2013-10-11 06:16:35 +00:00
Rui Ueyama ee366042e9 Return true from Resolver::resolve() on success.
llvm-svn: 192422
2013-10-11 06:16:33 +00:00
Rui Ueyama ced511b7c1 Replace a recursive tail call with an infinite loop.
This eliminates _elements's size check from the loop.

llvm-svn: 192418
2013-10-11 04:20:29 +00:00
Rui Ueyama a4770543f1 Remove an unused variable added in r192415.
llvm-svn: 192416
2013-10-11 03:51:19 +00:00
Rui Ueyama d542b9e53a Use switch instead of if, and handle all enum values.
This patch also handles errors other than no_more_files error. They were silently
ignored.

llvm-svn: 192415
2013-10-11 03:48:06 +00:00
Shankar Easwaran 80c33aa3d7 Fix return after llvm_unreachable
llvm-svn: 192414
2013-10-11 03:41:24 +00:00
Shankar Easwaran bcf36560fd [ELF] Fix Atoms in the same file had overlapping ordinals.
This also reverts the LayoutPass to use std::sort as all files
have an ordinal now.

llvm-svn: 192409
2013-10-11 01:50:04 +00:00
Rui Ueyama b916e84672 Fix typo
llvm-svn: 192401
2013-10-10 22:29:48 +00:00
Shankar Easwaran 26594caec4 [ELF] Initial design to handle Linker scripts for ELF.
llvm-svn: 192369
2013-10-10 17:27:49 +00:00
Shankar Easwaran 5d859e05f2 [test] Ignore failure for now for Darwin.
This is only a step to clean the buildbot.

llvm-svn: 192368
2013-10-10 17:12:50 +00:00
Shankar Easwaran c5ed819b02 [ELF] Return error from invalid linker script parse.
llvm-svn: 192360
2013-10-10 16:59:53 +00:00
Rui Ueyama 9f3a77a9f4 [PECOFF] Add files appear in .drectve to input graph
-- so that command line options to specify new input files, such as
/defaultlib:foo, is handled properly. Such options were ignored before
this patch.

llvm-svn: 192342
2013-10-10 05:39:43 +00:00
Rui Ueyama 85cc66d85e Do not process .objtxt file twice.
A file with .objtxt extension is parsed in readFile(), but because we did not
propagate that information to the calling side, calling side would try to parse
it again. This patch will fix the issue by adding an extra parameter to
readFile().

llvm-svn: 192311
2013-10-09 18:14:23 +00:00
Shankar Easwaran 95d4e61411 [ELF] Change MaxAlignment to 2.
llvm-svn: 192310
2013-10-09 18:12:31 +00:00
Shankar Easwaran 49408ece47 [Layout] Dont set ordinals to Files by default.
This change removes code in various places which was setting the File Ordinals.
This is because the file ordinals are assigned by the way files are resolved.

There was no other way than making the getNextFileAndOrdinal be set const and
change the _nextOrdinal to mutable.

There are so many places in code, that you would need to cleanup to make
LinkingContext non-const!

llvm-svn: 192280
2013-10-09 07:32:47 +00:00
Shankar Easwaran 30c4d11395 [cleanup] remove unused private variable
llvm-svn: 192278
2013-10-09 05:37:01 +00:00
Shankar Easwaran 1d3c48f1fc [Layout] Assign ordinals in Resolution order.
llvm-svn: 192277
2013-10-09 05:23:23 +00:00
Shankar Easwaran 091a18070b [test] Just use the exit code from the test for now.
Will fix this in later commits. Not sure why the regex is not passing.

llvm-svn: 192273
2013-10-09 04:30:17 +00:00
Shankar Easwaran 127d04a440 [test] Fix regex for failing test on bot
llvm-svn: 192270
2013-10-09 03:53:32 +00:00
Shankar Easwaran 03f7763d21 [inputGraph] Associate Resolve state with appropriate nodes
This associates resolveState to FileNodes. The control node derive
their resolution state from the inputElements that are contained in
it.

This makes --start-group/--end-group to work with ELF linking.

llvm-svn: 192269
2013-10-09 03:40:29 +00:00
Rui Ueyama c6015f6476 Update error classes from all lowercase to camel case.
llvm-svn: 192261
2013-10-09 00:57:22 +00:00
Rui Ueyama 1c1b443997 Move a local variable into while-loop scope.
llvm-svn: 192260
2013-10-09 00:42:57 +00:00
Rui Ueyama 74cc8e1e80 Fix flaky elf/X86_64/dynlib-search.test.
Output to llvm::err() is not guaranteed to be thread-safe, so it needs
to be guarded with a lock.

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

llvm-svn: 192250
2013-10-08 23:01:52 +00:00
Rui Ueyama f96416d750 Use size_t for array index.
llvm-svn: 192249
2013-10-08 23:01:49 +00:00
Rui Ueyama f890d3bf26 Fix #endif comment.
llvm-svn: 192230
2013-10-08 20:24:25 +00:00
Rui Ueyama 88b24ffe73 Use size_t instead of int64_t for the vector size.
llvm-svn: 192229
2013-10-08 20:24:23 +00:00
Shankar Easwaran 7f1146c494 [LinkingContext] make LinkingContext non-const
llvm-svn: 192183
2013-10-08 15:43:48 +00:00
Shankar Easwaran f876ecf5ed [Cleanup] Remove file thats not being used
llvm-svn: 192172
2013-10-08 06:05:38 +00:00
Rui Ueyama 9a13ac9a40 Move duplicate code in InputGraphs to the parent class.
llvm-svn: 192170
2013-10-08 05:52:01 +00:00
Rui Ueyama 492048bf60 Rename GnuLd's path() too.
llvm-svn: 192169
2013-10-08 05:23:03 +00:00
Rui Ueyama 53f31af7ea Rename path() -> getPath().
Differential Revision: http://llvm-reviews.chandlerc.com/D1853

llvm-svn: 192167
2013-10-08 04:57:08 +00:00
Rui Ueyama 7deb970d66 Use size_t instead of uint64_t to represent the vector length.
llvm-svn: 192165
2013-10-08 03:59:50 +00:00
Rui Ueyama a1d4c10c61 Remove an unnecessary local variable.
llvm-svn: 192164
2013-10-08 03:59:48 +00:00
Rui Ueyama 8b8e5216af Make bitmask an unsigned type.
llvm-svn: 192163
2013-10-08 03:59:45 +00:00
Rui Ueyama 7a633b4de5 Expand auto for readability.
llvm-svn: 192162
2013-10-08 03:59:42 +00:00
Nick Kledzik 369ffd1c55 fix typos
llvm-svn: 192154
2013-10-08 02:07:19 +00:00
Nick Kledzik 58070025ca fix all EXPECT_EQ(.address) tests
llvm-svn: 192153
2013-10-08 01:27:03 +00:00
Nick Kledzik 7e28e75570 fix test case failing on bot
llvm-svn: 192152
2013-10-08 01:12:35 +00:00
Rui Ueyama 094546836b Add comments. Early return.
llvm-svn: 192149
2013-10-08 00:43:53 +00:00
Rui Ueyama f8c54842d6 Convert error code structs to scoped enums.
Summary:
The original code with enum "_" is intended to emulate scoped enums.
Now we have real scoped enums, so use it.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 192148
2013-10-08 00:43:50 +00:00
Nick Kledzik 30332b19d3 Supoort mach-o encoded in yaml.
This is the first step in how I plan to get mach-o object files support into 
lld. We need to be able to test the mach-o Reader and Write on systems without 
a mach-o tools. Therefore, we want to support a textual way (YAML) to represent 
mach-o files.

MachONormalizedFile.h defines an in-memory abstraction of the content of mach-o  
files. The in-memory data structures are always native endianess and always
use 64-bit sizes. That internal data structure can then be converted to or
from three different formats: 1) yaml (text) encoded mach-o, 2) binary mach-o
files, 3) lld Atoms.

This patch defines the internal model and uses YAML I/O to implement the 
conversion to and from the model to yaml. The next patch will implement
the conversion from normalized to binary mach-o.

This patch includes unit tests to validate the yaml conversion APIs.

llvm-svn: 192147
2013-10-08 00:43:34 +00:00
Rui Ueyama 4c4d572795 Rename lld:*_error::_ -> lld:*_error::ErrorCode.
Summary: Rename lld:*_error::_ -> lld:*_error::ErrorCode.

Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 192138
2013-10-07 21:58:51 +00:00
Shankar Easwaran bafdf7be83 [lld][Darwin] Fix unused field warning.
This field would eventually be used.

llvm-svn: 192084
2013-10-07 03:18:33 +00:00
Shankar Easwaran 18318e32a9 [lld][inputgraph] Fix build failure on Darwin/Windows
llvm-svn: 192083
2013-10-07 03:06:04 +00:00
Shankar Easwaran d8ce00360d [lld] Add FileArchive
Fix adding a missed file in the previous commit.

llvm-svn: 192082
2013-10-07 02:55:42 +00:00
Shankar Easwaran a96f3a3da4 [lld][InputGraph] Change the Resolver to use inputGraph
Changes :-

a) Functionality in InputGraph to insert Input elements at any position
b) Functionality in the Resolver to use nextFile
c) Move the functionality of assigning file ordinals to InputGraph
d) Changes all inputs to MemoryBuffers
e) Remove LinkerInput, InputFiles, ReaderArchive

llvm-svn: 192081
2013-10-07 02:47:09 +00:00
Michael J. Spencer d419dbcc48 [ELF] Fix uninitalized value.
llvm-svn: 191924
2013-10-03 19:25:34 +00:00
Michael J. Spencer cf80ed03bc [Core] Fix unstable sort for unordered atoms.
llvm-svn: 191867
2013-10-03 01:26:48 +00:00
Michael J. Spencer c80f88a94e [Core] Fix heap overflow in LayoutPass.
Found this with asan. Code assumes that find doesn't return end, thus if
both atoms didn't have followon roots it would still compare their positions.

llvm-svn: 191865
2013-10-02 23:21:07 +00:00
Nick Kledzik 0932c004a9 [mach-o] Add support for -mllvm to darwin driver
llvm-svn: 191594
2013-09-28 00:29:33 +00:00
Rui Ueyama e9d2396c88 Add a comment to ReaderCOFF::parseFile.
llvm-svn: 191583
2013-09-27 22:55:25 +00:00
Nick Kledzik 473933b89f [mach-o] switch to use llvm::MachO:: constants
Stop using some locally defined mach-o constants.

llvm-svn: 191581
2013-09-27 22:50:00 +00:00
Rui Ueyama 053d9313f2 Re-submit [PECOFF] Add a test for the import table.
llvm-svn: 191580
2013-09-27 22:48:06 +00:00
Michael J. Spencer 102f82a74e [ELF] Handle copy relocations for PC32.
This will eventually need to be refactored to better handle COPY relocations,
as other relocations can also generate them. I'm not yet sure the exact
circumstances in which they are needed yet.

llvm-svn: 191567
2013-09-27 21:30:27 +00:00
Michael J. Spencer 3b36473007 [ELF] Mark STT_GNU_IFUNC symbols as code.
llvm-svn: 191566
2013-09-27 21:30:04 +00:00
Rui Ueyama a7ec3898d6 Revert "[PECOFF] Add a test for the import table."
This reverts r191469 because the original patch this one depends on (r191472)
was reverted.

llvm-svn: 191479
2013-09-27 01:26:53 +00:00
Rui Ueyama 9eb1432a99 [PECOFF] Add a test for the import table.
llvm-svn: 191475
2013-09-27 00:56:37 +00:00
Rui Ueyama 3c6ee599a2 [PECOFF] Enable input file logging if /debug is given.
llvm-svn: 191469
2013-09-26 22:46:04 +00:00
Michael J. Spencer 32a3f9ee29 [ELF] Add COPY relocations.
llvm-svn: 191467
2013-09-26 22:09:16 +00:00
Michael J. Spencer 4355bb9d22 [Core] Add type and size to SharedLibraryAtom.
llvm-svn: 191466
2013-09-26 22:08:43 +00:00
Michael J. Spencer 4d628347b1 [ELF] Fix use after free.
llvm-svn: 191403
2013-09-25 22:12:14 +00:00
Rui Ueyama 8db1eddc07 Make Driver::link and LinkingContext::validate return true on success.
This patch inverts the return value of these functions, so that they return
"true" on success and "false" on failure. The meaning of boolean return value
was mixed in LLD; for example, InputGraph::validate() returns true on success.
With this patch they'll become consistent.

CC: llvm-commits

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

llvm-svn: 191341
2013-09-24 23:26:34 +00:00
Rui Ueyama 27c88dab08 [PECOFF] Fix /? option and add a test for the flag.
llvm-svn: 191320
2013-09-24 17:59:30 +00:00
Rui Ueyama a32150c3c7 [PECOFF] Ignore /verbose and /wx (warnings as errors) options.
llvm-svn: 191317
2013-09-24 17:44:39 +00:00
Rui Ueyama 98f269f9d1 [PECOFF] Add /swaprun:{cd,net} options.
llvm-svn: 191276
2013-09-24 04:20:37 +00:00
Rui Ueyama 0e08d7757b [PECOFF] Ignore /pdbaltpath option.
/PDBALTPATH:<path> is an option to embed a different path for the PDB file to
the binary than the actual PDB file location. Because we don't support PDB
file, we'll just ignore the option for now.

llvm-svn: 191273
2013-09-24 04:04:00 +00:00
Rui Ueyama ad54b049ef Expand auto to improve code readability.
llvm-svn: 191272
2013-09-24 03:44:19 +00:00
Rui Ueyama b7297d695e [PECOFF] Use macro for the repeating pattern of the Driver code.
llvm-svn: 191271
2013-09-24 03:37:56 +00:00
Rui Ueyama a7bcad4613 [PECOFF] Remove redundant comments.
llvm-svn: 191270
2013-09-24 03:37:53 +00:00
Rui Ueyama c583d17a57 [PECOFF] Ignore /pdb option.
llvm-svn: 191269
2013-09-24 03:37:51 +00:00
Rui Ueyama 5ee413eda8 [PECOFF] Ignore /debug option.
llvm-svn: 191268
2013-09-24 03:37:47 +00:00
Rui Ueyama 12c0d773fe Try to fix test failure on buildbot.
llvm-svn: 191259
2013-09-24 00:47:31 +00:00
Rui Ueyama f062c84aac [PECOFF] Add /nodefaultlib command line option.
llvm-svn: 191254
2013-09-24 00:16:27 +00:00
Rui Ueyama 456740c740 [PECOFF] Do not allow space to separate command line option and its value.
We used to support both Windows and Unix style command line options. In Windows
style, an option and its value are separated by ":" (colon). In Unix, separator
is a space. Accepting both styles were convenient, but we can no longer allow
Unix style because I found that can be ambiguous.

For example, /nodefaultlib option takes an optional argument. In Windows style
it's going to be something like "/nodefaultlib:foo". There's no ambiguity what
"foo" means. However, if the option is "/nodefaultlib foo", "foo" can be
interpreted either an optional argument for "/nodefaultlib" or an input file
"foo.obj". We should just stop accepting the non-standard command line style.

llvm-svn: 191247
2013-09-23 23:51:31 +00:00
Rui Ueyama 5c59ab7f3d [PECOFF] Ignore /delay and /delayload options.
These options are to enable DLL delay loading. If enabled, DLL is loaded
at run time by a helper routine when a function in the DLL is actually called
for the first time, instead of making the Windows loader to load all DLLs at
startup time. This should shorten startup delay if an executable have many
imported symbols.

The linker needs to create a "delayed import table" and link delayimp.lib in
which helper functions are defined to support the feature.

For now, we just ignore the options, so that the linker does not complain when
it sees these options. We want to support them in the future.

llvm-svn: 191232
2013-09-23 22:41:46 +00:00
Rui Ueyama 85c821fcb2 [PECOFF] Add more tests for /machine, /base, /stack, /heap and /align.
llvm-svn: 191229
2013-09-23 21:52:01 +00:00
Rui Ueyama 1e0b586f33 [PECOFF] Add comments to unit tests and reorder them if necessary.
llvm-svn: 191228
2013-09-23 21:38:03 +00:00
Rui Ueyama c0a6d43c92 [PECOFF] Add /allowisolation command line option.
llvm-svn: 191227
2013-09-23 21:22:01 +00:00
Rui Ueyama 6907b3df70 [PECOFF] Add /allowbind command line option.
llvm-svn: 191224
2013-09-23 20:44:20 +00:00
Rui Ueyama 2721aa4065 [PECOFF] Simplify WinLinkOptions.td.
llvm-svn: 191223
2013-09-23 20:36:39 +00:00
Rui Ueyama 724d75b2c8 [PECOFF] Add one more test for r191218
llvm-svn: 191221
2013-09-23 20:24:12 +00:00
Ron Ofir b7d3e6b76b [lld][PECOFF] Fix data directory entry RVA of base relocations section
Summary:
This patch changes WriterPECOFF to actually write down the address instead of ignoring it.
Also, it changes the order of adding the BaseReloc chunk as otherwise the address wasn't set yet.

I think a better way of doing it would be to change DataDirectoryAtom to create a Reference
instead of using a number, and to change IdataPass accordingly, but I'm not sure how to do that.

Reviewers: ruiu

Reviewed By: ruiu

CC: llvm-commits

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

llvm-svn: 191220
2013-09-23 20:21:24 +00:00
Rui Ueyama 9149181ae9 [PECOFF] Add /align command line option.
llvm-svn: 191218
2013-09-23 19:52:35 +00:00
Rui Ueyama c532036aeb Whitespace and extra parentheses.
llvm-svn: 191217
2013-09-23 19:52:31 +00:00
Ron Ofir 41dcb848a7 [lld][PECOFF] Calculate SizeOfHeaders field instead of using a hard-coded value
Summary: This patch changes WritePECOFF to calculate the value of the SizeOfHeaders PE header field instead of just using 512.

Reviewers: rui314, ruiu

Reviewed By: ruiu

CC: llvm-commits, ruiu

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

llvm-svn: 191212
2013-09-23 18:08:51 +00:00
Shankar Easwaran e67ba51791 [lld][ELF] Remove invalid comment
llvm-svn: 191207
2013-09-23 16:28:23 +00:00
Shankar Easwaran 7915ff34b7 [lld][LinkingContext][ELF] Allow different output file types.
This adds an option --output-filetype that can be set to either
YAML/Native(case insensitive). The linker would create the outputs
associated with the type specified by the user.

Changes all the tests to use the new option.

llvm-svn: 191183
2013-09-23 04:24:15 +00:00
Ron Ofir 5403eaecc0 [lld][WinLink] Fix typo
llvm-svn: 191079
2013-09-20 09:13:53 +00:00
Rui Ueyama eb0434e9ae Fallback to the default stringize function to show some meaningful error message.
GNU LD driver only understood no_such_file_or_directory error and was showing
just "Unknown Error" for any other type of error. With this patch, the driver
now prints file name and error message string by default.

llvm-svn: 191070
2013-09-20 03:32:27 +00:00
Rui Ueyama 391ffdf70e Generalize errStr() function so that it can handle any type of errors.
llvm-svn: 191069
2013-09-20 03:18:58 +00:00
Rui Ueyama 508939428d [PECOFF] Ignore /incremental option.
/incremental is an option to enable incremental linking. We will eventually
want to implement the feature for better performance, but in the meantime,
we want to just ignore the option so that the linker does not output unknown
option error when it sees /incremental option.

llvm-svn: 191063
2013-09-20 00:55:37 +00:00
Rui Ueyama 9f5f635e7f Remove extraneous parentheses.
llvm-svn: 191061
2013-09-20 00:33:34 +00:00
Rui Ueyama 388fbd8f31 Handle "file not found" error in the superclass's errStr().
If a subclass does not override the member function, the superclass's method
takes care of string conversion of "file not found" error. This is a reasonable
default behavior. Subclasses are still able to override to customize error
messages.

llvm-svn: 191058
2013-09-20 00:32:40 +00:00
Rui Ueyama dc30cdb18c Fix file comments and include guard
llvm-svn: 191054
2013-09-19 23:34:20 +00:00
Rui Ueyama 91a95a590a [PECOFF] Ignore /errorReport command line option.
/errorReport is a command line option to let the linker to report internal
linker error information to Microsoft. For LLD that option doesn't make any
sense, so it just ignores the option.

llvm-svn: 191044
2013-09-19 22:19:40 +00:00
Shankar Easwaran a2f881e275 [lld][ELF][Hexagon] Cleanup unused data
Cleanup structure members that are not being used.

Also clang-format it.

llvm-svn: 191038
2013-09-19 21:27:21 +00:00
Shankar Easwaran 70fefd515a [lld][ELF] Group command line options for better usage
llvm-svn: 191033
2013-09-19 20:07:06 +00:00
Shankar Easwaran a17e5bc02a [lld][ELF] Support non alloc sections in the Writer.
This also makes it support debugging executables built with lld.

Initial patch done by Bigcheese. This is only a revised patch to
have the functionality in the Writer.

llvm-svn: 191032
2013-09-19 20:07:01 +00:00
Rui Ueyama 1bddfc1fc7 [PECOFF][Driver] Support /version command line option
llvm-svn: 190986
2013-09-19 02:37:36 +00:00
Rui Ueyama 0397239f6b [PECOFF] Fix the order of the Import Table entries.
Test is coming after submitting http://llvm-reviews.chandlerc.com/D1719.

llvm-svn: 190983
2013-09-19 01:39:53 +00:00
Rui Ueyama ccd21fe418 [PECOFF] Fix base relocation block alignment
Base relocation block should be aligned on a 32-bit boundary. While the PECOFF
spec mentions only aligning the blocks, and not padding them, link.exe seems
to add an extra IMAGE_REL_I386_ABSOLUTE entry (just a zeroed WORD) in order to
pad the blocks.

Patch by Ron Ofir.

llvm-svn: 190951
2013-09-18 18:36:39 +00:00
Rui Ueyama 0742ce9cf7 [PECOFF] Make helper functions private.
llvm-svn: 190949
2013-09-18 18:15:18 +00:00
Shankar Easwaran 1b0256c379 [lld][YAML] RefNameResolver : add only if name/refname is not empty
llvm-svn: 190903
2013-09-17 23:38:04 +00:00
Shankar Easwaran 063b75013f [lld][ELF] Assign sectionChoice properly to ELF atoms
This sets the sectionChoice property for DefinedAtoms. The output section name
is derived by the property of the atom. This also decreases native file size.

Adds a test.

llvm-svn: 190840
2013-09-17 02:56:22 +00:00
Rui Ueyama e0e28d059b [PECOFF] Take into account all sections when setting size fields in the PE header
This patch changes lld to go through all sections while calculating the size
for SizeOfCode, SizeOfInitializedData and SizeOfUninitializedData fields in the
PE header, instead of using only a small set of hard-coded sections.

This only really changes SizeOfInitializedData which didn't include .reloc
section before this patch.

Patch by Ron Ofir.

llvm-svn: 190799
2013-09-16 17:39:26 +00:00
Rui Ueyama d5e4f637ef [PECOFF] Add DISCARDABLE characteristic to .reloc section
This patch sets the IMAGE_SCN_MEM_DISCARDABLE characteristic to the base
relocations section in order to match MS PECOFF specification.

Patch by Ron Ofir.

llvm-svn: 190798
2013-09-16 17:35:13 +00:00
Rui Ueyama 3ee2bf6a62 [PECOFF] Use a dummy file as an "input file" for Idata atoms.
llvm-svn: 190772
2013-09-15 22:33:15 +00:00
Joerg Sonnenberger 97fc3834b8 Output soname.
llvm-svn: 190758
2013-09-14 19:53:51 +00:00
Joerg Sonnenberger 9e5676c5c8 If .bss doesn't exist, set _end/end based on .data.
llvm-svn: 190753
2013-09-14 13:59:49 +00:00
Joerg Sonnenberger 4263d8b35d Add _end symbol for dynamic libraries. At least brk/sbrk in libc on
NetBSD need it.

llvm-svn: 190752
2013-09-14 13:45:29 +00:00
Rui Ueyama ec9bb694bd Revert "[PECOFF] Allocate storage for .drective in the reader ..."
This reverts r189881 because that patch caused dangling StringRefs.

llvm-svn: 190725
2013-09-13 21:14:18 +00:00
Rui Ueyama a8ce9529c3 [PECOFF] Fix alignment bug.
There was a bug that if a section has an alignment requirement and there are
multiple symbols at offset 0 in the section, only the last atom at offset 0
would be aligned properly. That bug would move only the last symbol to an
alignment boundary, leaving other symbols unaligned, although they should be at
the same location. That caused a mysterious SEGV error of the resultant
executable.

With this patch, we manage all symbols at the same location properly, rather
than keeping the last one.

llvm-svn: 190724
2013-09-13 21:11:00 +00:00
Rui Ueyama 1ea9b97707 [PECOFF] Fix atom default alignment.
Alignment(1) does not mean that the atom should be aligned on a 1 byte
boundary but on a 2^1 boundary. So, atoms without any specific alignment
requirements should have Alignment(0).

llvm-svn: 190723
2013-09-13 20:53:11 +00:00
Joerg Sonnenberger 3c6b056186 Add test case for the not-yet implemented copy relocations.
llvm-svn: 190714
2013-09-13 18:32:34 +00:00
Shankar Easwaran 2a92c18ba3 [lld][ELF] Handle multiple weak symbols
This handles multiple weak symbols which appear back to back. This fix is needed
which otherwise will lead to symbols getting initialized to arbitrary values.

There was a constructor/destructor test that really triggered this to be fixed
on X86_64.

Adds a test.

llvm-svn: 190658
2013-09-13 04:25:44 +00:00
Rui Ueyama 6f32549623 [PECOFF] Handle weak external symbols.
Used the fallback mechanism to implement COFF weak external symbols.

llvm-svn: 190633
2013-09-12 21:42:52 +00:00
Shankar Easwaran 4ff19b3c87 [lld][LinkingContext] Fix doxygen comment
llvm-svn: 190629
2013-09-12 20:00:15 +00:00
Rui Ueyama 55b3cc5054 Do not prepend "_" to external symbols if non-i386.
llvm-svn: 190628
2013-09-12 19:52:59 +00:00
Rui Ueyama 98896ed1b5 [PECOFF] Add a field for machine type to PECOFFLinkingContext.
So that we can determine what the target architecture is. Adding this
field does not mean that we are going to support non-i386 architectures
soon; there are many things to do to support them, and I'm focusing on
i386 now. But this is the first step toward multi architecture support.

llvm-svn: 190627
2013-09-12 19:46:53 +00:00
Rui Ueyama e5416ec2d2 Add a fallback mechanism for undefined atom.
In COFF, an undefined symbol can have up to one alternative name. If a symbol
is resolved by its regular name, then it's linked normally. If a symbol is not
found in any input files, all references to the regular name are resolved using
the alternative name. If the alternative name is not found, it's a link error.
This mechanism is called "weak externals".

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

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

llvm-svn: 190625
2013-09-12 19:14:05 +00:00
Shankar Easwaran 2206d5ad7d [lld][tests] Fix buildbot failure on darwin
llvm-svn: 190619
2013-09-12 18:10:20 +00:00
Shankar Easwaran d6d1b52937 [lld][LayoutPass] change comments to reflect the sort order
llvm-svn: 190612
2013-09-12 15:59:34 +00:00
Shankar Easwaran 2734d79d94 [lld][ELF] Fix vaddr of the first section
The first section in the output was not aligned to the alignment of the section.

llvm-svn: 190610
2013-09-12 15:43:17 +00:00
Shankar Easwaran df2dd193ee [lld][ELF] Fix the readonly section order.
This associates rodata and sections which just have the SHF_ALLOC flag
to be set to typeConstant.

llvm-svn: 190609
2013-09-12 15:43:13 +00:00
Shankar Easwaran f1b341c80e [lld][LayoutPass] Order the atoms that are in the same chain
We need to order atoms that exist in the same chain. This is to make sure that
the command line order is preserved when we emit the atoms to the output file.

Credits: BigCheese for finding the bug.

Adds a test which otherwise would fail.

llvm-svn: 190608
2013-09-12 15:43:09 +00:00
Rui Ueyama 81d0d29639 Remove hard-coded leading underscore from entry symbol.
llvm-svn: 190586
2013-09-12 05:09:01 +00:00
Rui Ueyama 1e6af15388 Do not hard code the leading underscore.
Mangling scheme varies on platform, and prepending an underscore is valid only
on 32-bit x86. Added a method to mangle name to PECOFFLinkingContext and use
it to avoid hard coding mangled names.

llvm-svn: 190585
2013-09-12 04:42:31 +00:00
Rui Ueyama 2ff9d70ac4 Run clang-format.
llvm-svn: 190554
2013-09-11 22:21:42 +00:00
Nick Kledzik 2e0fb1ef5b Allow darwin driver to use -help when no input files are specified.
Patch by Joe Ranieri

llvm-svn: 190453
2013-09-10 23:57:41 +00:00
Nick Kledzik e773e327d3 Support darwin linker options:
-current_version, -compatibility_version, and -install_name.

Patch by Joe Ranieri

llvm-svn: 190452
2013-09-10 23:55:14 +00:00
Nick Kledzik e850d9dedd Remove PackedVersion from MachOLinkingContext and replace with uint32_t
and a parsePackedVersion() utility.

Patch by Joe Ranieri

llvm-svn: 190451
2013-09-10 23:46:57 +00:00
Rui Ueyama 5c532370d5 Use llvm::sys::Process::GetEnv() instead of ::getenv().
Process::GetEnv() uses GetEnvironmentVariableW, which is a Windows API
to get an environment variable and is preferable over getenv().

llvm-svn: 190431
2013-09-10 20:33:21 +00:00
Rui Ueyama fff7f8a4ed Rename GnuLDInputGraph.h -> GnuLdInputGraph.h for consistency with other files.
llvm-svn: 190332
2013-09-09 19:30:23 +00:00
Rui Ueyama 67de33b075 Use _isWholeArchive to silence -Wunused-private-field warning.
llvm-svn: 190329
2013-09-09 19:21:06 +00:00
Joerg Sonnenberger ecd1d9bc1d Handle _DYNAMIC correctly in the x86_64 backend.
llvm-svn: 190302
2013-09-09 12:19:28 +00:00
Joerg Sonnenberger 23f8d43e5c Recognize -Bstatic as alias for -static, clang uses it.
llvm-svn: 190301
2013-09-09 11:48:43 +00:00
Joerg Sonnenberger bd25241e0e Drop the context forceLoadAllArchives() support. Rename the isForceLoad
attribute in LinkerInput to isWholeArchive and use that for deciding
whether library archives should be expanded. Implement the -all_load
option of the Darwin linker using this flag and drop the support for it
in GNU mode.

llvm-svn: 190275
2013-09-08 13:30:14 +00:00
Joerg Sonnenberger a82566b86e Update documentation.
llvm-svn: 190255
2013-09-07 18:01:39 +00:00
Joerg Sonnenberger 0310e734c3 Run clang-format.
llvm-svn: 190254
2013-09-07 17:56:23 +00:00
Joerg Sonnenberger 5e235de9d3 Change the parseFile argument from MemoryBuffer pointer to LinkerInput
reference. Move readFile logic into FileNode::createLinkerInput.

llvm-svn: 190253
2013-09-07 17:55:28 +00:00
Rui Ueyama 0826dd23c6 [PECOFF] Don't add RVAs to base relocations table.
Patch by Ron Ofir.

llvm-svn: 190210
2013-09-06 22:09:02 +00:00
Rui Ueyama 97086a5a4f [PECOFF] Fix section alignment bug in ReaderCOFF.
Patch by Ron Ofir.

llvm-svn: 190198
2013-09-06 20:08:57 +00:00
Rui Ueyama 02c46bdb75 [PECOFF] Add /machine command line option.
llvm-svn: 190121
2013-09-06 04:17:07 +00:00
Rui Ueyama 030fe96ff3 [PECOFF] Align section contents as specified by the object file's section header.
llvm-svn: 190120
2013-09-06 04:06:58 +00:00
Rui Ueyama 822cb2e44b Remove extraneous parentheses.
llvm-svn: 190119
2013-09-06 03:16:28 +00:00
Rui Ueyama 01951de462 Return early to simplify.
llvm-svn: 190117
2013-09-06 01:48:19 +00:00
Rui Ueyama f48b8fc06d Remove unused identifiers.
llvm-svn: 190095
2013-09-05 20:21:24 +00:00
Shankar Easwaran fc09df0fe9 [lld][cleanup] remove unused ReaderFunc to avoid confusion.
llvm-svn: 190031
2013-09-05 04:27:17 +00:00
Shankar Easwaran 176e7fd05f [lld][ELF] Change the order of the writable note section
Writable note sections if they exist should not appear before text
they belong in the data segment

llvm-svn: 190024
2013-09-05 01:50:21 +00:00
Shankar Easwaran 8c705690ab [lld][ELF] Differentiate between Note sections(RW/RO)
It looks like there is a possibility of seeing RO/RW note sections
and we would need to create an appropriate RO/RW segment associated
with them.

Adds a test too.

llvm-svn: 189907
2013-09-04 02:42:02 +00:00
Rui Ueyama 959aebf873 [PECOFF] Ignore options starting with -?
The compiler is allowed to add a linker option starting with -?<name> to
.drectve section. If the linker can interpret -<name>, it's processed as if
there's no question mark there. If not, such option is silently ignored.

This is a COFF's feature to allow the compiler to emit new linker options
while keeping compatibility with older linkers.

llvm-svn: 189897
2013-09-04 00:51:51 +00:00
Shankar Easwaran b85f1857a1 [lld][ELF] Emit note sections
Emit note sections if the input contains a note section.

Also emit a note segment.

llvm-svn: 189896
2013-09-04 00:51:42 +00:00
Rui Ueyama 8ccf6da056 Rename *Options.td -> <flavor>Options.td.
Before this patch, name of driver implementation is not consistent with its
option table file. Specifically, LDOptions has a different prefix than
GnuLdDriver.

This patch renames option files, so that the option files have the same prefix
as the corresponding driver files.

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

llvm-svn: 189895
2013-09-04 00:24:35 +00:00
Shankar Easwaran 2eaa47a008 [lld][Driver] remove return after llvm_unreachable
llvm-svn: 189891
2013-09-04 00:05:46 +00:00
Joerg Sonnenberger 37f50b7ccc Start a TODO list for the ELF backend.
llvm-svn: 189890
2013-09-04 00:00:48 +00:00
Shankar Easwaran 3df170b84e [lld][Driver] The driver was creating linker inputs twice
Also add a llvm_unreachable call so that the linker will trip on unhandled
inputElement types.

llvm-svn: 189887
2013-09-03 23:52:05 +00:00
Joerg Sonnenberger 33a6d3aaed Recognize -rpath-link option and add arguments to ELFLinkingContext.
llvm-svn: 189883
2013-09-03 23:28:51 +00:00
Rui Ueyama 225f090bdb [PECOFF] Allocate storage for .drective in the reader to avoid multiple calls of allocateString()
llvm-svn: 189881
2013-09-03 23:14:30 +00:00
Rui Ueyama 530488c92a [PECOFF] Verify parameter in validateImpl() not in the driver.
llvm-svn: 189877
2013-09-03 22:57:00 +00:00
Shankar Easwaran d3b3d71a3a [lld] Remove bitfield for boolean members
llvm-svn: 189876
2013-09-03 22:55:45 +00:00
Shankar Easwaran c16b5e76fc [lld][ELF][X86_64] Test alignment for init_array/fini_array sections
llvm-svn: 189875
2013-09-03 22:46:54 +00:00
Shankar Easwaran 84c643fcc3 [lld][ELF][X86_64] Fix alignment of init_array/fini_array sections
llvm-svn: 189874
2013-09-03 22:44:46 +00:00
Shankar Easwaran 2b9d1025d6 [lld][ELF] Change the InitFini atom type from Stub to Data
llvm-svn: 189873
2013-09-03 22:44:44 +00:00
Shankar Easwaran fce7952b79 [lld][ELF][Hexagon] add Init/Fini option for hexagon
This adds init/fini support for Hexagon.

llvm-svn: 189872
2013-09-03 22:44:42 +00:00
Shankar Easwaran 2f5d64062b [lld] handle the case of errors from createLinkerInput
This changes the interface of createLinkerInput to use ErrorOr, so that
errors from the linker can be captured.

Also adds a convenience function for error strings to be returned from
file nodes.

llvm-svn: 189871
2013-09-03 22:44:37 +00:00
Rui Ueyama b4170b17d4 [PECOFF] Fix fixme by making PECOFFLinkingContext non-const.
llvm-svn: 189865
2013-09-03 22:33:56 +00:00
Joerg Sonnenberger a82839593c Finish -rpath implementation to actually create the DT_RPATH entries.
llvm-svn: 189847
2013-09-03 20:45:09 +00:00
Joerg Sonnenberger 840d3daf01 Add support for --sysroot.
llvm-svn: 189826
2013-09-03 16:29:02 +00:00
Joerg Sonnenberger 7d5aed5ce5 A weak reference to a symbol that is only weakly referenced in
dependencies should remain weak, not get promoted to undef or dropped.

llvm-svn: 189793
2013-09-03 12:06:33 +00:00
Rui Ueyama 0e70a16419 Do not add entry symbol to the dead strip list. Partially revert r189776.
llvm-svn: 189778
2013-09-03 03:34:33 +00:00
Rui Ueyama 8cdbf525a9 Cosmetic changes
Differential Revision: http://llvm-reviews.chandlerc.com/D1577

llvm-svn: 189777
2013-09-03 01:25:21 +00:00
Rui Ueyama 504962f714 Partially revert r189718 to add entry symbol to dead strip root.
Also added a test to verify that entry symbol is not stripped even if
dead stripping is enabled.

llvm-svn: 189776
2013-09-03 01:00:01 +00:00
Rui Ueyama 4313451ba4 Resolver: Do not use assert() to notify user input error.
llvm-svn: 189775
2013-09-03 00:50:22 +00:00
Rui Ueyama 900a501bdd Add llc to check-lld deps. We use the command in lit.cfg.
llvm-svn: 189774
2013-09-02 23:26:00 +00:00
Joerg Sonnenberger 37b08114bd Typo.
llvm-svn: 189771
2013-09-02 19:36:15 +00:00
Joerg Sonnenberger 2bbc79039d Recognize -Bshareable as alias for -shared.
llvm-svn: 189752
2013-09-02 09:34:35 +00:00
Joerg Sonnenberger 354a2f30d4 ReaderWriter depends on Passes.
llvm-svn: 189751
2013-09-02 09:33:06 +00:00
Shankar Easwaran df4f12bb65 [lld][test] organize test directory. No change in functionality
* Renames few tests which had extension objtxt to test
* created core directory that contains all the core tests

llvm-svn: 189720
2013-08-31 05:59:52 +00:00
Shankar Easwaran 2e4424b431 [lld][ELF] Add Init/Fini support
This creates .init_array/.fini_array section for X86_64 ELF
targets and executes init/fini functions specified by the
-init/-fini options respectively.

llvm-svn: 189719
2013-08-31 05:27:44 +00:00
Shankar Easwaran d26c8e3463 [lld][LinkingContext] Atoms created from command line options should be available in YAML
This adds an API to the LinkingContext for flavors to add Internal files
containing atoms that need to appear in the YAML output as well, when -emit-yaml
switch is used.

Flavors can add more internal files for other options that are needed.

llvm-svn: 189718
2013-08-31 05:27:38 +00:00
Rui Ueyama 981892ab71 Fix build breakage
llvm-svn: 189714
2013-08-31 01:36:36 +00:00
Rui Ueyama e45f37d238 Remove #include, for we don't need the definitions of these classes.
llvm-svn: 189713
2013-08-31 01:28:45 +00:00
Rui Ueyama 51991fed70 Remove dead code.
llvm-svn: 189708
2013-08-30 23:53:06 +00:00
Rui Ueyama 5b41201066 [PECOFF] Add /force:unresolved command line option as a synonym of /force.
llvm-svn: 189614
2013-08-29 21:46:47 +00:00
Rui Ueyama d4b9d068f0 [PECOFF] Fix bug that section grouping may lay out atoms in a wrong order.
We added layout edges to the head atoms in grouped sections. That was wrong,
because the head atom needs to be followed by the other atoms in the *same*
section, not by the other section contents. With this patch, layout edges are
added from tail atom, which is the last atom in a section, to head atom.

llvm-svn: 189573
2013-08-29 07:46:23 +00:00
Rui Ueyama 79e8215f96 [PECOFF] Fix bug that atom size was sometimes wrong.
Because of a bug, the last atom of each section contained a garbage at the
end of its data. In most cases the garbage is harmless but it could have cause
SEGV.

llvm-svn: 189572
2013-08-29 07:34:58 +00:00
Rui Ueyama 5a383d10ac [PECOFF] Add helper functions for debugging
llvm-svn: 189570
2013-08-29 07:17:47 +00:00
Rui Ueyama 67283bc22f [PECOFF] Do not create undefined atom for common symbol.
We were creating undefined atoms for common symbols by mistake. That did not
lead to a link failure, for undefined atoms would be resolved by common symbols
in the same file, but that's a waste of resource.

llvm-svn: 189534
2013-08-28 23:16:04 +00:00
Rui Ueyama 184a4b83d8 [PECOFF] Do not scan the symbol table twice but instead cache aux symbols.
We scanned the symbol table twice; first to gather all regular symbols, and
second to process aux symbols. That's a bit inefficient and complicated. We
can instead cache aux symbols in the first pass, to eliminate the need of the
second pass.

llvm-svn: 189525
2013-08-28 22:27:05 +00:00
Rui Ueyama 9d52a94cd1 [PECOFF] Make command line options case insensitive to match link.exe's behavior.
llvm-svn: 189505
2013-08-28 20:27:41 +00:00
Rui Ueyama c4d793f2ad Remove an option starting an uppercase character so that the test does not depends on sort order.
llvm-svn: 189423
2013-08-28 00:01:57 +00:00
Rui Ueyama b5292e6295 Modify test to adopt r189416.
r189416 changed the order of command line options shown in help message,
so the test needs adjusting.

llvm-svn: 189417
2013-08-27 23:48:49 +00:00
Rui Ueyama a372a9b503 Use do-while instead of a magic number. No functionality change.
llvm-svn: 189413
2013-08-27 23:10:26 +00:00
Rui Ueyama 488d41e6ef [PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Differential Revision: http://llvm-reviews.chandlerc.com/D1527

llvm-svn: 189318
2013-08-27 05:15:20 +00:00
Rui Ueyama 8a5cbadff9 Fix use of temporary strings.
llvm-svn: 189310
2013-08-27 04:27:18 +00:00
Rui Ueyama bc839fcd3e [PECOFF] Enable dead-stripping by default to match link.exe behavior.
llvm-svn: 189308
2013-08-27 03:38:18 +00:00
Rui Ueyama 4c3184f3c0 Treat entry point symbol as an undefined atom.
With this patch the entry symbol is treated as an undefined symbol, to force
the resolver to resolve the entry symbol.

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

llvm-svn: 189307
2013-08-27 03:18:11 +00:00
Rui Ueyama 352e7308c0 Rename ti -> ctx.
This should have been done in r187823 when I renamed LinkingContext
from TargetInfo. I missed a few files.

llvm-svn: 189298
2013-08-27 00:04:42 +00:00
Rui Ueyama c7ef7a8dd7 [PECOFF] Add Support for entry point symbol name
Patch by Jesús Serrano García.

llvm-svn: 189267
2013-08-26 19:55:09 +00:00
Shankar Easwaran f1947537a0 [lld][ELF] Cleanup ELF writing, No change in functionality
The cleanup includes :-

* Rename ambiguous Header class to ELFHeader
* Convert Chunk contentype and kind to be a enumerated class
* Remove functions that are not being used, avoids future confusion

llvm-svn: 189209
2013-08-26 03:16:13 +00:00
Shankar Easwaran da7ceb9b58 [lld][ELF] Indent the td file to < 80 columns
llvm-svn: 189207
2013-08-26 01:56:27 +00:00
Shankar Easwaran 0f2a45cac5 [lld][ELF][Cleanup] Create multiclass for variations in options usage
llvm-svn: 189197
2013-08-25 18:05:15 +00:00
Shankar Easwaran be81dd757e [lld][ELF] process fini_array sections
This change processes fini_array section in addition to processing
init_array sections. This also makes functions registered at compile
time for initialization and finalization to be run during execution

llvm-svn: 189196
2013-08-25 18:05:12 +00:00
Saleem Abdulrasool 1089265a1d [PECOFF] support additional subsystem identifiers
This completes the subsystem name parsing to support the identifiers that the
Microsoft link.exe linker supports.  "windows" and "console" are left as the
first items as they are the expected common paths.

Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
llvm-svn: 189181
2013-08-24 20:14:54 +00:00
Rui Ueyama 72165ec8c3 Separates /fixed (no .reloc section) and /dynamicbase (enable ASLR)
in order to match link.exe's behaviour.

Patch by Ron Ofir.

llvm-svn: 189159
2013-08-24 00:39:10 +00:00
Hans Wennborg 2391fddfc7 CMake: Support the LLVM_INSTALL_TOOLCHAIN_ONLY flag
llvm-svn: 189157
2013-08-24 00:24:15 +00:00
Rui Ueyama d07c6f06eb Fixes an additional temporary string use.
Patch by Ron Ofir.

llvm-svn: 189151
2013-08-23 22:06:29 +00:00
Tim Northover 274a023d70 Check for "asserts" rather than "debug" on test
The debug flag being checked for seems to be controlled by whether the
build is asserts/non-asserts rather than debug/non-debug. Mostly these
correlate, but not necessarily.

As far as I can tell with various combinations of debug/assetions this
change makes no difference on autotools builds, but fixes a check-all
failure with CMake.

llvm-svn: 189147
2013-08-23 21:10:37 +00:00
Shankar Easwaran f9fe6250ff [lld][ELF] Dont ignore zero sized sections.
There may be relocations that may be pointing to the section
even if the section sizes are 0. We shouldnot ignore them
for that regard.

llvm-svn: 189139
2013-08-23 20:03:35 +00:00
Shankar Easwaran 78457803bc [lld][ELF][Cleanup] Section associated with the relocation traversed
There is no change in functionality, this uses the defined way to access
the relocation section that belongs to a particular section.

llvm-svn: 189138
2013-08-23 20:03:31 +00:00
Shankar Easwaran d9e0a49357 [lld][ELF] Rename typeTLV content type for ELF
typeTLV content type is used by Darwin to represent thread local
storage. A new contentType has to be made to represent ELF
thread local storage data. These have been set to

- typeThreadZeroFill (represents TBSS storage)
- typeThreadData     (represents TDATA storage)

llvm-svn: 189137
2013-08-23 20:03:28 +00:00
Shankar Easwaran d17ba4bd4d [lld] handle typeZeroFill atoms in ELF/Native/YAML
BSS atoms dont take any file space in the Input file. They are associated
with a contentType(typeZeroFill). Similiar zero fill types also exist which
have the same meaning in terms of occupying file space in the Input.

These atoms have to be handled seperately when writing to the
lld's intermediate file or the lld test infrastructure.

Also adds a test.

llvm-svn: 189136
2013-08-23 20:03:21 +00:00
Hans Wennborg 306db8f3fa CMake: Don't look for llvm-tblgen when building outside LLVM tree
Previously, the CMake build would look for llvm-tblgen to determine
if a directory is an LLVM build or install directory. Since we don't
want to include llvm-tblgen in the install, look for llvm-config instead,
and use that to find llvm-tblgen.

(This is the lld equivalent of Clang r189127.)

llvm-svn: 189128
2013-08-23 18:18:13 +00:00
Shankar Easwaran 89732e1362 [lld][PECOFF] Fix one more reference to a temporary string
llvm-svn: 189035
2013-08-22 17:59:03 +00:00
Shankar Easwaran c48b9594b6 [lld][PECOFF] Fix use of temporary strings
llvm-svn: 189025
2013-08-22 15:37:09 +00:00
Shankar Easwaran ea68a5d636 [lld][unittests] Change assert to llvm_unreachable
llvm-svn: 189023
2013-08-22 15:23:54 +00:00
Shankar Easwaran 1d76b115a3 [lld][test] fix -Wreturn-type error
llvm-svn: 188988
2013-08-22 05:44:08 +00:00
Shankar Easwaran 5677e433d6 fix build failures on platforms that use -Wunused-private-variable for builds
llvm-svn: 188983
2013-08-22 04:24:57 +00:00
Shankar Easwaran b8b42658ea [lld][Driver] Fix the unit test for lld gnu flavor
llvm-svn: 188982
2013-08-22 03:18:01 +00:00
Shankar Easwaran c1ea4572ba [lld][Hexagon] Enable Hexagon sdata sorting test
llvm-svn: 188981
2013-08-22 03:02:17 +00:00
Shankar Easwaran 88d0d44635 [lld] Fix unused private fields for fixing build failure on darwin
llvm-svn: 188978
2013-08-22 01:49:16 +00:00
Shankar Easwaran b4fae7c3d0 remove trailing whitespace
llvm-svn: 188965
2013-08-22 00:08:25 +00:00
Shankar Easwaran 2032609327 [lld][Darwin] fixing an accidentally removed change
llvm-svn: 188963
2013-08-21 23:31:58 +00:00
Shankar Easwaran c4dba32d19 [lld] Fix win7 failure on adding InputGraph functionality
llvm-svn: 188961
2013-08-21 23:13:22 +00:00
Shankar Easwaran e44104b001 add InputGraph functionality
llvm-svn: 188958
2013-08-21 22:57:10 +00:00
Hans Wennborg 04632f1f16 [PECOFF] Handle "--" option explicitly
This used to be handled automagically by the option parsing library,
but after LLVM r188314, we should handle it ourselves.

No functionality change, but adds a test.

llvm-svn: 188318
2013-08-13 21:44:44 +00:00