Commit Graph

660 Commits

Author SHA1 Message Date
Rui Ueyama 0ca149fce9 Rename TargetInfo -> LinkingContext.
Also change some local variable names: "ti" -> "context" and
"_targetInfo" -> "_context".

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

llvm-svn: 187823
2013-08-06 22:31:59 +00:00
Rui Ueyama 05f1ae987b Remove unused using's.
llvm-svn: 187690
2013-08-02 23:22:46 +00:00
Rui Ueyama 707754f3e8 [PECOFF] Move more code from Atoms.h to ReaderCOFF.cpp.
llvm-svn: 187688
2013-08-02 22:58:22 +00:00
Rui Ueyama 35947af012 [PECOFF] Remove special treatment of "--" option.
Thanks to Hans' patch (r187675), OptTable now handles "--", so we don't
need this code in LLD.

llvm-svn: 187683
2013-08-02 22:34:12 +00:00
Rui Ueyama f6e90afbf4 [PECOFF] Remove COFFDefinedFileAtom::originalOffset().
The aim of this patch is to reduce the dependency from COFFDefinedAtom
to COFF structs defined in llvm/Object/COFF.h. Currently many attributes
of the atom are computed in the atom. That provide a simple interface but
does not work well in some cases.

There are some cases that the same type atom is created from different
parts of a COFF file. One example is the BSS atom, which can be created
from the defined symbol in the .bss section or from the undefined symbol.
Computing attributes from different sources in the atom complicates the
code. We should compute it outside the atom.

In the next patch, I'll move more code from Atoms.h to ReaderCOFF.cpp.

llvm-svn: 187681
2013-08-02 22:27:15 +00:00
Rui Ueyama 4ecc59afce [PECOFF] Handle .drectve section.
Summary:
The .drectve section contains linker command line options, and the linker is
expected to interpret them as if they were given via the command line. In this
patch, the command line parser in the driver is called from the object file
reader to parse the string.

I think this patch is important, because this is the first step towards mutable
TargetInfo. We had a discussion about that on llvm-commits mailing list before.
I haven't removed "const" from the function signature yet. Instead, I just use
cast to remove "const". This is a temporary aid for an experiment. If we don't
see any issue with this mutable TargetInfo appraoch, I'll change the function
signature, and rename the class LinkerContext from TargetInfo.

Reviewers: kledzik

CC: llvm-commits

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

llvm-svn: 187677
2013-08-02 21:26:14 +00:00
Rui Ueyama f29065d0c6 [PECOFF] Return an error_code instead of calling report_fatal_error().
For an invalid input we should not call report_fatal_error(), because
when LLD is used as a library, we don't want to kill the whole app
because of a malformed input.

llvm-svn: 187673
2013-08-02 21:10:17 +00:00
Rui Ueyama 53f4660680 Use report_fatal_error() instead of llvm_unreachable() to show broken input file error.
llvm-svn: 187670
2013-08-02 20:45:25 +00:00
Rui Ueyama 8e091352c9 [PECOFF] Remove an assertion that's too heavy.
llvm-svn: 187665
2013-08-02 19:10:29 +00:00
Rui Ueyama 8a14aa1bd9 [PECOFF] Relocations now take into account the address which is stored at the relocation site
Patch by Ron Ofir.

llvm-svn: 187664
2013-08-02 18:40:50 +00:00
Rui Ueyama 8344be8407 [PECOFF] A symbol with symbol with section number 0 and non-zero value represents a BSS atom.
llvm-svn: 187645
2013-08-02 05:25:31 +00:00
Rui Ueyama 740e402b8b [PECOFF] Simplify COFFBSSAtom.
A instance of the class always represents a BSS atom, so we don't need
to look at the symbol or the section to retrieve its attributes.

llvm-svn: 187643
2013-08-02 05:04:06 +00:00
Hans Wennborg 03cd107364 Remove the SUPPORT_ALIASARGS define
It is not needed after LLVM r187546.

llvm-svn: 187551
2013-08-01 00:12:38 +00:00
Rui Ueyama 527abc9b09 Use StringRef::equals_lower(). No functionality change.
llvm-svn: 187548
2013-07-31 23:53:58 +00:00
Rui Ueyama 395958ea6f [PECOFF][Driver] Prefer "/" over "-" as the indicator of the option.
This patch does not change the behavior of LLD, but changes the output of the
help text. We want to show the help text with Windows style indicator rather
than Unix style indicator.

llvm-svn: 187544
2013-07-31 23:23:25 +00:00
Hans Wennborg 88b7aad3e1 Option parsing tables: pick up AliasArgs from the OPTION macro.
This depends on LLVM r187537.

The SUPPORT_ALIASARGS macro will be removed once all option parsing
clients have been updated.

llvm-svn: 187541
2013-07-31 23:17:41 +00:00
Rui Ueyama 44a6ed8d4e [PECOFF][Driver] Rewrite the tablegen def file using multiclass to remove duplicates.
llvm-svn: 187539
2013-07-31 23:12:06 +00:00
Rui Ueyama 3adc09e9fc Revert "[PECOFF][Driver] Remove quotes from command line arguments."
This reverts commit r187390 because we should not handle argv's quotes ourselves.

In Windows, unlike Unix, quotes are not processed by the shell. Instead the C
startup routine parses it as described in
http://msdn.microsoft.com/en-us/library/a1y7w461.aspx and pass the results to
main(). So, at the time when the control reaches main(), quotes that should be
removed has already been removed.

We still need to handle quotes in the response file and in .drectve section
ourselves. That will be addressed in different patches.

llvm-svn: 187534
2013-07-31 22:13:15 +00:00
Rui Ueyama 3361fa49f5 [PECOFF] Add a comment about .bss section.
llvm-svn: 187505
2013-07-31 17:45:48 +00:00
Rui Ueyama 87b9703ec4 [PECOFF] Add a comment on the idata section fragments.
llvm-svn: 187484
2013-07-31 05:10:20 +00:00
Rui Ueyama a0016db818 Fix comment.
llvm-svn: 187461
2013-07-30 23:20:10 +00:00
Rui Ueyama dcf09476ff [PECOFF] Emit BSS section.
llvm-svn: 187460
2013-07-30 22:56:46 +00:00
Rui Ueyama 7ae6ffd3d2 [PECOFF] Split COFFDefinedAtom to add COFFBSSAtom class.
The BSS atom is similar to the regular defined atom, but it's different
in the sense that it does not have contents. Until now we assumed all the
defined atoms have its contents. That did not fit well to the BSS atom.

llvm-svn: 187453
2013-07-30 21:54:10 +00:00
Rui Ueyama 85cd10ffa0 [PECOFF][Driver] Remove quotes from command line arguments.
The command line option in .drectve section may be quoted by double
quotes, and if that's the case we have to remove them.

llvm-svn: 187390
2013-07-29 23:32:22 +00:00
Rui Ueyama b469aeb164 [PECOFF] Process Import Name/Type field in the import library.
This patch removes hacky mangle() function, which strips all decorations
uncondtitionally. LLD now interprets Import Name/Type field in the import
library properly as described in the Microsoft PE/COFF Spec.

llvm-svn: 187388
2013-07-29 22:55:39 +00:00
Rui Ueyama 7ac447fdfc [PECOFF] Replace the magic number with sizeof().
llvm-svn: 187382
2013-07-29 21:54:43 +00:00
Rui Ueyama 5b274f3414 Fix test failure introduced in r187271 by enabling pipefail.
llvm-svn: 187381
2013-07-29 21:50:33 +00:00
Rui Ueyama 35f72ac818 [PECOFF] Simplicy FileCOFF ctor. No functionality change.
Member functions to read the symbol table had too many parameters to propagate
all the temporary information from one to another. By storing the information
to data members, we can simplify the function signatures and improve the
readability.

llvm-svn: 187321
2013-07-28 04:29:30 +00:00
Rui Ueyama fbfd102b9e Removed unnecessary parameter.
llvm-svn: 187317
2013-07-28 01:50:24 +00:00
Rui Ueyama c3ab5117c9 [PECOFF] Skip a section if there's no atom in the section.
Some sections, such as with IMAGE_SCN_LNK_REMOVE attribute, is skipped
in the first pass. Such sections need to be skipped in the latter passes.

llvm-svn: 187281
2013-07-27 00:37:50 +00:00
Rui Ueyama 3939101d6f [PATCH] [PECOFF] Fill size field of IMAGE_DATA_DIRECTORY
Patch by Ron Ofir.

llvm-svn: 187262
2013-07-26 22:33:28 +00:00
Rui Ueyama 28084dc6cd [PECOFF][Driver] Add ".lib" extension to the path given with /defaultlib.
llvm-svn: 187259
2013-07-26 22:22:26 +00:00
Rui Ueyama 3e0bbb4b02 [PECOFF][Driver] Add a library file even if it does not exist.
Missing files will be reported as errors in the later pass, so this patch
does not change the behavior of the LLD linker, but it helps writing unit
tests for the driver.

llvm-svn: 187256
2013-07-26 22:17:08 +00:00
Rui Ueyama 9dcbf8b3f6 [PECOFF][Driver] Fix a bug that -mllvm does not take any arguments.
llvm-svn: 187243
2013-07-26 20:54:36 +00:00
Rui Ueyama d5b49de621 [PECOFF] Don't set IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE if "-fixed" is provided
Based on Ron Ofir's patch.

llvm-svn: 187221
2013-07-26 17:30:39 +00:00
Rui Ueyama 9c3ece328f [PECOFF] Replace magic number with llvm::COFF::DataDirectoryIndex value
Patch by Ron Ofir.

llvm-svn: 187220
2013-07-26 17:30:36 +00:00
Rui Ueyama 2b59074ac8 [PECOFF] Fixed a bug which caused DataDirectoryChunk to write to a wrong offset in the file buffer
Patch by Ron Ofir.

llvm-svn: 187219
2013-07-26 17:30:33 +00:00
Rui Ueyama f84d3d6187 Remove trailing whitespace.
llvm-svn: 187216
2013-07-26 17:08:12 +00:00
Rui Ueyama 0e786d3a38 Make local variables to start with a lowercase character for consistency with the LLD coding style.
llvm-svn: 187215
2013-07-26 17:03:03 +00:00
Rui Ueyama 9f9a2be24c [PECOFF] Simplicy object allocation code. No functionality change.
llvm-svn: 187214
2013-07-26 17:03:00 +00:00
Rui Ueyama b37fba7c54 [PECOFF] Ignore sections with IMAGE_SCN_LNK_REMOVE attribute.
llvm-svn: 187211
2013-07-26 16:59:38 +00:00
Rui Ueyama afe731b796 [PECOFF] Create an atom for a symbol whose storage type is IMAGE_SYM_CLASS_LABEL.
llvm-svn: 187177
2013-07-26 01:18:27 +00:00
Reid Kleckner f33c0e3a5f Use env in a pecoff test so it passes with the lit shell test runner
llvm-svn: 187170
2013-07-25 23:20:21 +00:00
Reid Kleckner 818104899e Add yaml2obj to check-lld deps, since the PECOFF tests need it
llvm-svn: 187165
2013-07-25 23:05:13 +00:00
Rui Ueyama dc6983ca13 [PECOFF][Driver] Add /nologo command line option.
llvm-svn: 187162
2013-07-25 22:46:49 +00:00
Rui Ueyama 50e67c7371 [PECOFF][Driver] Split WinLinkDriver::parse for readability.
llvm-svn: 187161
2013-07-25 22:33:08 +00:00
Rui Ueyama de25a69531 [PECOFF][Driver] Allow multiple /include options.
llvm-svn: 187100
2013-07-25 02:57:39 +00:00
Rui Ueyama 1e3e8752a8 [PECOFF] Add /failifmismatch option.
llvm-svn: 187095
2013-07-25 01:23:50 +00:00
Rui Ueyama 869950e9e0 [PECOFF][Driver] Simplify option definitions.
It's still not as simple as it should be because of the many duplicated
lines, but it's at least better than before.

llvm-svn: 187091
2013-07-25 00:32:19 +00:00
Rui Ueyama d1d116aa89 [PECOFF] Use Windows style options instead of Unix style as primary options.
LLD still accepts both Unix and Windows style options when it's run as
link.exe. This patch does not change functionality.

llvm-svn: 187086
2013-07-24 23:18:02 +00:00