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
Rui Ueyama
fd50283c3c
[PECOFF] Add /include command line option.
...
The /include command line option is equivalent to Unix --undefined
option, which forces the linker to resolve the given symbol name
as if it's an unresolved symbol in one of its input files. This feature
is used to link an additional object file or a shared library that no
input files refer to.
llvm-svn: 187084
2013-07-24 22:53:23 +00:00
Nick Kledzik
2815782831
Add lit magic so that lld unittests are run as part of lld test suite
...
llvm-svn: 187005
2013-07-23 23:42:17 +00:00
Nick Kledzik
196d7a77a3
fix typo in error string
...
llvm-svn: 186996
2013-07-23 22:17:47 +00:00
Rui Ueyama
a59c5ac16f
Avoid using C-style cast and remove unnecessary LL prefix.
...
llvm-svn: 186960
2013-07-23 17:25:25 +00:00
Rui Ueyama
fbf5763708
[PECOFF] Support -tsaware:no command line option.
...
llvm-svn: 186957
2013-07-23 17:17:19 +00:00
Rui Ueyama
6a41fca856
[PECOFF] Support -fixed command line option to disable base relocations.
...
llvm-svn: 186911
2013-07-23 01:29:50 +00:00
Rui Ueyama
d991c50273
[PECOFF] Replace magic numbers with offsetof().
...
llvm-svn: 186888
2013-07-22 23:02:08 +00:00
Rui Ueyama
5443cba6d9
Fix -Wsign-compare warnings.
...
llvm-svn: 186884
2013-07-22 22:21:39 +00:00
Rui Ueyama
6c655f237e
[PECOFF][Driver] Show error message if no input file is given.
...
llvm-svn: 186882
2013-07-22 22:17:24 +00:00
Rui Ueyama
9e69e06cae
Rename ReaderCOFF members to follow the LLD coding style.
...
llvm-svn: 186843
2013-07-22 16:56:34 +00:00
Rui Ueyama
2125da5a0f
[PECOFF] Fix use-after-free.
...
llvm-svn: 186771
2013-07-20 21:00:47 +00:00
Nick Kledzik
91a85457e9
[mach-o] factor out all cputype <-> arch conversions to one table driven location
...
llvm-svn: 186755
2013-07-20 02:08:23 +00:00
Rui Ueyama
8e6c8f850d
[PECOFF][Driver] Add -base command line option.
...
llvm-svn: 186739
2013-07-20 00:45:00 +00:00
Rui Ueyama
99f80cf4a7
[PECOFF][Driver] Process "LINK" environment variable.
...
llvm-svn: 186654
2013-07-19 05:06:20 +00:00
Rui Ueyama
64b29d616b
[PECOFF][Driver] Add -defaultlib command line option.
...
llvm-svn: 186650
2013-07-19 04:11:37 +00:00
Rui Ueyama
5a7bbce587
[PECOFF][Driver] Interpret "LIB" environment variable.
...
llvm-svn: 186648
2013-07-19 03:27:03 +00:00
Rui Ueyama
2897feb7e0
[PECOFF] Use library search path when looking for a .lib file.
...
llvm-svn: 186645
2013-07-19 02:18:25 +00:00
Rui Ueyama
9f24922bd1
[PECOFF][Driver] Add -libpath command line option.
...
The logic to search a library from the library paths will be implemented
in a different patch.
llvm-svn: 186644
2013-07-19 01:38:49 +00:00
Nick Kledzik
762ae82d57
Add -help option to Darwin Driver. Use grouping in Options table to better format help output
...
llvm-svn: 186640
2013-07-19 01:02:49 +00:00
Nick Kledzik
a20a403c1d
Check the return value from parse()
...
llvm-svn: 186630
2013-07-18 23:47:22 +00:00
Nick Kledzik
a121053471
Add support for -all_load. Enhance DarwinLdDriverTest unit test test cases to test all options parsed so far
...
llvm-svn: 186626
2013-07-18 23:13:13 +00:00
Rui Ueyama
4227022673
[PECOFF] Use replace_extension() instead of doing it myself.
...
llvm-svn: 186612
2013-07-18 21:38:44 +00:00
Rafael Espindola
c97d83dd3b
Fix the build with clang and libstdc++4.7.
...
llvm-svn: 186451
2013-07-16 20:18:13 +00:00
Rafael Espindola
63f699d2b9
Update for llvm API change.
...
llvm-svn: 186450
2013-07-16 19:44:30 +00:00
Nick Kledzik
4f44eff707
build lld unittests as part of lld-test target
...
llvm-svn: 186441
2013-07-16 18:46:48 +00:00
Nick Kledzik
2a709eaa83
Fix Driver tests to check return value of parse(), simplify subclassing, and remove unneeded instance variables
...
llvm-svn: 186440
2013-07-16 18:45:57 +00:00
Rui Ueyama
b0b1d590ab
[WinLink] Add /LargeAddressAware command line option.
...
llvm-svn: 186428
2013-07-16 17:20:38 +00:00
Rui Ueyama
cb1c8cce46
Fix broken unittest for GnuLDDriver.
...
llvm-svn: 186427
2013-07-16 17:17:01 +00:00
Rui Ueyama
8f7ddf733b
[PECOFF][Writer] Replace magic numbers with sizeof().
...
This is a follow up patch for r186336.
Reviewers: LegalizeAdulthood
CC: silvas, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1144
llvm-svn: 186384
2013-07-16 06:21:39 +00:00
Rui Ueyama
5590373024
[PECOFF][Writer] Use defined constants instead of magic numbers.
...
llvm-svn: 186382
2013-07-16 04:47:02 +00:00
Rui Ueyama
aa0307021d
[PECOFF] Add default argument to addDir32NBReloc() as the default value 0 is reasonable.
...
llvm-svn: 186368
2013-07-16 00:03:51 +00:00
Rafael Espindola
66c0a65ba1
Revert "Don't pass llvm::errs() all over the place. Diagnostics always go to stderr."
...
This reverts commit 185657. It will be used by unit tests.
llvm-svn: 186366
2013-07-15 23:55:07 +00:00
Rui Ueyama
eb1e1ace85
[PECOFF][Writer] Follow up patch for r186336.
...
- Make a const reference instead of copying an object
- Fix a comment
llvm-svn: 186355
2013-07-15 22:20:10 +00:00
Rui Ueyama
e6be3d5505
[PECOFF][Writer] s/dyn_cast/cast/ where we don't expect null return value.
...
llvm-svn: 186353
2013-07-15 22:15:32 +00:00
Rui Ueyama
49a2394095
[PECOFF][Writer] Refactoring: Move private methods below public ones.
...
llvm-svn: 186352
2013-07-15 21:35:15 +00:00
Rui Ueyama
8ac2ec4043
[PECOFF] Fix comment.
...
llvm-svn: 186346
2013-07-15 21:00:53 +00:00
Rui Ueyama
341a2b4b5d
[PECOFF][Writer] Emit .reloc section.
...
Emit .reloc section. This is the first step to support DLL creation. The
executable doesn't need .reloc section, but the DLL does.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1126
llvm-svn: 186336
2013-07-15 18:43:01 +00:00
Rui Ueyama
c8a53795ab
[PECOFF] Support linking against DLL.
...
This patch adds a new pass, IdataPass, to transform shared atom references
to real references and to construct the .idata section data. With this patch
lld can produce a working Hello World program by linking it against
kernel32.dll and user32.dll.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1096
llvm-svn: 186071
2013-07-11 08:46:21 +00:00
Rui Ueyama
a3635b7b3b
[PECOFF][Writer] Fixed a bug that an empty section is emit to the section header.
...
llvm-svn: 186066
2013-07-11 05:43:38 +00:00
Rui Ueyama
cf68e2a1b1
[PECOFF][Writer] Compute the size of a chunk each time it's added rather than all at once.
...
Contents of ".reloc" section depends on the addresses of other sections, so
the section cannot be created until all the other sections are created and get
their memory addresses (RVAs). That means that computation of section size
needs to be at least two pass.
Techynically there's no reason to compute it all at once, but instead we can
compute the address of a section as added to the output file. Doing so helps
us to create ".reloc" section.
llvm-svn: 185902
2013-07-09 04:44:18 +00:00
Rui Ueyama
d54264c007
Remove redundant #include.
...
llvm-svn: 185803
2013-07-08 09:39:22 +00:00
Rui Ueyama
d769cec6e3
[PECOFF] Use yaml2obj to avoid checking in binary files.
...
llvm-svn: 185690
2013-07-05 10:41:44 +00:00
Rafael Espindola
305ac7ebe6
Add 'not' to command lines that are expected to fail.
...
llvm-svn: 185658
2013-07-04 17:08:11 +00:00
Rafael Espindola
2530f67116
Don't pass llvm::errs() all over the place. Diagnostics always go to stderr.
...
llvm-svn: 185657
2013-07-04 17:06:04 +00:00
Rafael Espindola
611db946c2
Return 0 when processing --help. This matches gnu ld and gold.
...
llvm-svn: 185655
2013-07-04 16:50:47 +00:00
Rui Ueyama
130a6eb7fa
Try to guard a test that requires DEBUG().
...
This is a follow-up patch for r185524. Being assert enabled does not mean
that DEBUG() is enabled, so we need to check the existence of DEBUG() itself.
llvm-svn: 185619
2013-07-04 09:29:47 +00:00
Rui Ueyama
4eca75df00
[PECOFF][Writer] Fix SizeOfImage header. It should include the first unmapped page.
...
llvm-svn: 185534
2013-07-03 12:55:56 +00:00
Rui Ueyama
924922235e
Guard a test that fails on a Release build.
...
llvm-svn: 185524
2013-07-03 09:09:13 +00:00
Rui Ueyama
18c67a158b
[PECOFF][Writer] Separate AtomChunk from SectionChunk.
...
The optional data directory header contains addresses to some atoms such
as the import address table in data section. Such fields can naturally
be set by relocation if we make the optional data driectory as an atom.
Currently we assume that atoms are always in a section, so we can't create
a file header with atoms. This patch separates section chunk from atom
chunk, to allow atom-based file header.
llvm-svn: 185521
2013-07-03 08:15:00 +00:00
Rui Ueyama
6c7ac57235
Add "explicit" to ctors where appropriate.
...
llvm-svn: 185517
2013-07-03 07:32:40 +00:00
Rui Ueyama
afa4844d94
[PECOFF] Handle hint field in Hint/Name table in the import library.
...
A hint is an index of the export pointer table in a DLL, at which
PE/COFF loader starts looking for a symbol name. The import library
comes with hints and symbol pairs, and as long as hints are in sync
with the actual symbol table in DLL, the symbols will be resolved
quickly. So, we shouldn't ignore hints but propagate them to an output.
llvm-svn: 185516
2013-07-03 06:09:33 +00:00
Rui Ueyama
4b862775ea
[PECOFF][Writer] Simplifies the COFFBaseDefinedAtom ctor by defining a new class.
...
llvm-svn: 185515
2013-07-03 05:44:09 +00:00
Rui Ueyama
2fa2a727bb
Removed unused friend declaration.
...
llvm-svn: 185420
2013-07-02 11:13:43 +00:00
Rui Ueyama
9319db2ce9
[PECOFF][Writer] Set SizeOfInitializedData file header.
...
llvm-svn: 185310
2013-07-01 08:06:48 +00:00
Rui Ueyama
60c7481654
[PECOFF][Writer] Add setter methods that sets the import address table location to file header.
...
llvm-svn: 185309
2013-07-01 07:59:17 +00:00
Rui Ueyama
da513290de
[PECOFF][Writer] Do not emit the empty section as Windows loader rejects such executable.
...
llvm-svn: 185308
2013-07-01 07:32:12 +00:00
Rui Ueyama
8ebfad76bc
[PECOFF][Writer] Amend the comment about DLL linking.
...
llvm-svn: 185307
2013-07-01 07:25:30 +00:00
Rui Ueyama
39a2c197cf
[PECOFF][Writer] Fix buildbot failure on x86_64-win7.
...
llvm-svn: 185285
2013-06-30 14:14:44 +00:00
Rui Ueyama
7d4720e5cd
[PECOFF][Reader] Create a jump table for functions exported by DLL.
...
llvm-svn: 185283
2013-06-30 13:33:36 +00:00
Rui Ueyama
3628b6a7c6
Move a function into assert() so that GCC won't complain that the
...
function is not used in release build.
llvm-svn: 185248
2013-06-29 04:28:51 +00:00
Rui Ueyama
3bad6dd278
Remove extra ';'
...
llvm-svn: 185247
2013-06-29 04:28:44 +00:00
Rui Ueyama
e9dd5f98cf
[PECOFF][Writer] Fix wrong section header.
...
llvm-svn: 185205
2013-06-28 20:10:36 +00:00
Rui Ueyama
95609be563
[PECOFF][Writer] Remove duplicated code by moving it to parent class.
...
llvm-svn: 185200
2013-06-28 19:59:54 +00:00
Rui Ueyama
e5fdfdc07b
[PECOFF][Writer] Define COFFBaseDefinedAtom as the base class of COFF defined atoms.
...
In order to support linking against DLL, the linker needs to create defined
atoms for jump tables and etc. Because such atoms are not read from a file,
they lack some information such as an ordinal. With this patch, COFFDefinedAtom
is split into two classes; one is the base class of all COFF defined atoms, and
another is a concrete class for atoms read from file. More classes inheriting
COFFBaseDefinedAtom will be added for jump tables and etc.
llvm-svn: 185195
2013-06-28 19:08:57 +00:00
Rui Ueyama
0a00836bb7
Add include guard.
...
llvm-svn: 185134
2013-06-28 04:52:40 +00:00
Rui Ueyama
11ccc91f0a
[PECOFF][Writer] Support DIR32NB and REL32 relocation types.
...
llvm-svn: 185133
2013-06-28 04:40:52 +00:00
Rui Ueyama
4251055a66
[PECOFF][Writer] Fix a bug that the contents of .data and .rdata were swapped.
...
llvm-svn: 185130
2013-06-28 04:15:37 +00:00
Rui Ueyama
fed750ff3b
[PECOFF][Writer] Skip ".debug$S" section in the input object file.
...
llvm-svn: 185129
2013-06-28 04:06:49 +00:00
Rui Ueyama
d059f360a3
[PECOFF][Writer] Use a constant instead of a magic number.
...
llvm-svn: 185128
2013-06-28 03:52:41 +00:00
Rui Ueyama
1a54aad50b
[PECOFF][Writer] Templatize connectAtomsWithLayoutEdge()
...
Templatize connectAtomsWithLayoutEdge() so that it can handle other types of
defined atoms.
llvm-svn: 185125
2013-06-28 03:41:07 +00:00
Rui Ueyama
ee8b55d6a8
[PECOFF][Writer] Fix DLLCharacteristic flag in image header.
...
llvm-svn: 185102
2013-06-27 21:03:44 +00:00
Shankar Easwaran
2302bd5568
[lld] rename member variable name.
...
This renames variable name to reflect initial undefined symbols that are
defined by the linker -u option.
This doesnot change any functionality in lld, and updates code to reflect
Nick's comment.
llvm-svn: 184682
2013-06-24 03:22:51 +00:00
Rui Ueyama
7be81b2b4d
[PECOFF] Moves a utility function to Atoms.cpp to remove duplicate code.
...
llvm-svn: 184653
2013-06-22 23:14:51 +00:00