Commit Graph

710 Commits

Author SHA1 Message Date
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
Rui Ueyama f8455fab3f Fix unused field warning.
llvm-svn: 184651
2013-06-22 22:12:30 +00:00
Rui Ueyama 829c6e6f41 [PECOFF] Removed unnecessary namespace qualifier.
llvm-svn: 184649
2013-06-22 22:01:54 +00:00
Rui Ueyama 7b7b0b9f7d Removed unnecessary "class" keyword.
llvm-svn: 184589
2013-06-21 19:59:15 +00:00
Rui Ueyama bf402d6643 Removed unnecessary "class" keyword.
llvm-svn: 184585
2013-06-21 19:30:16 +00:00
Rui Ueyama 55fc544e65 Fix typo in include guard.
llvm-svn: 184521
2013-06-21 02:29:54 +00:00
Shankar Easwaran 89488966bd [TargetInfo] Undefined symbols move from ELFTargetInfo to TargetInfo
This change moves the functionality of undefinedSymbols that were created in
ELFTargetInfo into TargetInfo. Looks like MachO/Windows use similiar options
like in ELF for creating undefined symbols when the linker is invoked.

Address comment from Ruiu.

(No change in functionality, except moving the functionality from ELF to
TargetInfo, so that multiple architectures can use the same)

llvm-svn: 184398
2013-06-20 04:27:21 +00:00
Rui Ueyama 991f42c35f [PECOFF] Add a pass to ensure the correct ordering of grouped sections.
Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 184327
2013-06-19 17:46:57 +00:00
Shankar Easwaran 53caafebdb [ELF] add -u/--undefined option, to define undefined symbols
llvm-svn: 184266
2013-06-19 00:31:09 +00:00
Rui Ueyama 4d654dd7b8 [PECOFF] Extract atom definitions as Atoms.h so that we can use them in other files.
Extract atom definitions as Atoms.h so that we can use them in other files.
Also applied clang-format to Atoms.h.

Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 184124
2013-06-17 21:19:07 +00:00
Rui Ueyama b24241bae3 [PECOFF] Implement the reader for the import library.
This is the first patch toward full DLL support. With this patch, lld can
read .lib file for a DLL.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 184101
2013-06-17 18:43:13 +00:00
Rui Ueyama c444241e41 [Passes][GOT] Split perform() into small predicate functions for readability sake.
Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 184091
2013-06-17 17:29:46 +00:00
Rui Ueyama d95a155af6 [PECOFF] Connect defined atoms with layout before/after edges.
Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 184085
2013-06-17 16:59:54 +00:00
Shankar Easwaran f91031efcf [ELF] Add more sections to the default section map.
This change adds functionality to add more sections like .gcc_except_table,
.data.rel.local, .data.rel.ro into the default section map, so that they are
all merged into appropriate output sections.

This also makes c++ static binaries comparable to what you get with the default
linker.

Adds a test for testing the functionality.

llvm-svn: 184071
2013-06-17 02:29:36 +00:00
Rui Ueyama 8d10164326 [lld][PECOFF] Support IMAGE_REL_I386_DIR32 relocation.
With this patch, it can now resolve relocations in the same output file.
"Hello world" program does not still work because call to the DLL routine
is not supported yet.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 184063
2013-06-16 17:25:17 +00:00
Rui Ueyama c26eabe32b [lld] Move AtomLayout from ELF to Core so that it can be used by non-ELF writers.
Summary: I'm planning to use AtomLayout in WriterPECOFF.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 184062
2013-06-16 17:25:14 +00:00
Rui Ueyama e96044a370 [lld] Move AtomLayout from ELF to ReaderWriter so that it can be used by non-ELF writers.
Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 184061
2013-06-16 17:14:58 +00:00
Shankar Easwaran a97f12e00a [ELF] Add test so that _end value is set appropriately for NMAGIC/OMAGIC executables(Fix comment from espindola)
llvm-svn: 184060
2013-06-16 15:06:18 +00:00
Benjamin Kramer 2b004debde Fix typo in comment. Found by -Wdocumentation.
llvm-svn: 184058
2013-06-16 11:09:47 +00:00
Shankar Easwaran a42a473893 [ELF] add NMAGIC/OMAGIC support
llvm-svn: 184055
2013-06-16 05:06:28 +00:00
Rui Ueyama 4a4079e839 [WinLink] Support /nxcompat command line option.
llvm-svn: 184050
2013-06-16 03:07:08 +00:00
Rui Ueyama 3b0321c182 [PECOFF] Add a test for r184036.
llvm-svn: 184037
2013-06-15 05:20:05 +00:00
Rui Ueyama b95e833278 [PECOFF] Support .lib archive file.
Archive file in Windows has file extension of ".lib" but the file format is
in fact the same as Unix. It's an ar archive holding multiple .obj files.
The existing archive reader can read .lib files.

llvm-svn: 184036
2013-06-15 05:15:41 +00:00
Rui Ueyama 779a714766 [PECOFF] Handle scope of absolute atom correctly.
llvm-svn: 184035
2013-06-15 05:04:07 +00:00
Rui Ueyama 642c1a2968 [PECOFF] Fix build error on Win64.
llvm-svn: 183965
2013-06-14 02:43:30 +00:00
Rui Ueyama ef2c5413a9 [lld][PECOFF] Read relocation entries.
Summary:
COFFReference class is defined to represent relocation information for
COFFDefinedAtom, as ELFReference for ELFDefinedAtom. ReaderCOFF can now
read relocation entries and create COFFReferences accordingly.

I need to make WriterPECOFF to handle the relocation references created by
the reader, but this patch is already big, so I think it's probably better
to get it reviewed now.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183964
2013-06-14 02:30:34 +00:00
Rui Ueyama 78a617f4c1 [PECOFF] Make readSymbolTable a const function.
llvm-svn: 183887
2013-06-13 05:23:47 +00:00
Rui Ueyama 8338716e8d [ARM] Remove isThumb() as it's not used and it's not in the right place.
Architecture specific code should reside in architecture specific directory
not in Atom. Looks like there are no efforts being made at this moment to
support ARM, so let's remove it for now.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183877
2013-06-13 00:26:16 +00:00
Rui Ueyama cc14c02f7f [PECOFF] Define constants for page size and disk sector size.
llvm-svn: 183876
2013-06-12 23:45:32 +00:00
Rui Ueyama 2e3c4025ae [PECOFF] Rename basic.test -> trivial.test.
Because the test does not actually cover basic features.

llvm-svn: 183870
2013-06-12 22:19:05 +00:00
Rui Ueyama 0e17c37c57 [PECOFF] Test for r183705.
llvm-svn: 183853
2013-06-12 19:13:27 +00:00
Rui Ueyama 969e70265a [ELF] Remove unused parameter from ELFReference c'tor.
Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 183850
2013-06-12 18:21:36 +00:00
Shankar Easwaran ec36f9a734 [test] fix test as the atom name is available only in DEBUG mode
llvm-svn: 183819
2013-06-12 00:46:37 +00:00
Shankar Easwaran 08470c4b6b [ELF][X86_64] Create GOT entries for external TLS symbols properly without Segfaults.
llvm-svn: 183817
2013-06-12 00:32:39 +00:00
Shankar Easwaran 79dbc5b5d1 [ELF] NMAGIC support : Find the BSS section to setup the virtual address of _end.
llvm-svn: 183816
2013-06-12 00:32:35 +00:00
Shankar Easwaran d5ff08ca5f [ELF] TBSS section has to be special cased so that it doesnot occupy memory space
llvm-svn: 183815
2013-06-12 00:32:32 +00:00
Rui Ueyama 9f56df8e43 [Darwin][Driver] Add unit tests.
llvm-svn: 183806
2013-06-11 23:07:43 +00:00
Rafael Espindola 70d0c820ef Include Path.h instead of PathV2.h.
I am about to move PathV2.h to Path.h.

llvm-svn: 183796
2013-06-11 22:17:04 +00:00
Rui Ueyama dd76f067f7 [PECOFF][Writer] Structure of pe32_header was changed.
Change for http://llvm-reviews.chandlerc.com/D952

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183789
2013-06-11 21:39:58 +00:00
Rafael Espindola 2fa59a9330 Convert another use of sys::identifyFileType.
No functionality change.

llvm-svn: 183762
2013-06-11 18:12:28 +00:00
Rafael Espindola c1b32686fe Factor duplicated yamlReader creation.
The yaml reader is not specific to any file format. This patch moves
it to TargetInfo and makes validate a non virtual interface so that it
can be constructed from a single location.

The same method will be used to create a reader for llvm bitcode
files.

llvm-svn: 183740
2013-06-11 12:36:05 +00:00
Rui Ueyama daadcc59ad [WinLink] Add -force command line option to allow undefined symbols.
llvm-svn: 183724
2013-06-11 04:52:14 +00:00
Rui Ueyama fe36b40019 [PECOFF] Refactoring: Split FileCOFF c'tor. No functionality change.
Split FileCOFF's constructor into mainly two private methods.
One method is responsible to iterate over symbol tables, and other
method is to atomize defined atoms. This is for readability and
no changes in functionality.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183708
2013-06-10 22:57:49 +00:00
Rui Ueyama 787ee4e099 [PECOFF][Writer] Set required OS version numbers.
llvm-svn: 183705
2013-06-10 22:25:41 +00:00
Rui Ueyama b07cebffb2 [PECOFF] Add comments for symbols.
llvm-svn: 183700
2013-06-10 22:09:21 +00:00
Rui Ueyama e3ee514aa7 [ELF] Refactor File.h.
- Split createAtom() in lib/ReaderWriter/ELF/File.h into small methods.
 - Added comments to code in other methods.

No functionality changes.

Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 183696
2013-06-10 21:32:44 +00:00
Rafael Espindola 808dfba985 Use the StringRef version of identifyFileType.
llvm-svn: 183670
2013-06-10 15:36:21 +00:00
Rafael Espindola 4cdc6c14ed Use early returns.
No functionality change.

llvm-svn: 183659
2013-06-10 14:27:58 +00:00
Rui Ueyama 9dd08d912d [PECOFF][Driver] Add -heap command line option.
llvm-svn: 183622
2013-06-08 22:59:10 +00:00
Rui Ueyama eb0cc96e4b [PECOFF][Driver] Add -stack command line option.
llvm-svn: 183604
2013-06-08 03:59:00 +00:00
Rui Ueyama 7b5592bc0b [WinLink] Fix use-after-return.
llvm-svn: 183603
2013-06-08 03:39:35 +00:00
Rafael Espindola a0af48fc93 Fix handling of files without a symbol table.
This fixes a recent regression (r183338). Stripped elf files (like installed
crtn.o for example), are not required to have a symbol table. Handle that
correctly.

llvm-svn: 183573
2013-06-07 21:08:19 +00:00
Rui Ueyama a6b71cabb3 [LayoutPass] Add a method to check the followon graph structure.
Found that having a method to check the strucutre of the followon graph makes
it easy to debug file readers. The method checks if there's no wrong edge in
followOnNexts and followOnRoots. It is called only when debuggging is enabled
for LayoutPass.

Reviewers: shankarke

CC: llvm-commits

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

llvm-svn: 183553
2013-06-07 20:18:39 +00:00
Rui Ueyama 8d6151fd29 [PECOFF][Writer] Implement the writer that can emit text section.
lld can now output a valid Windows executable with a text section that does nothing
but just returns immediately. It's not able to handle relocations, symbol tables,
data sections, etc, so it still can't do anything practical, though.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183478
2013-06-07 01:31:51 +00:00
Rui Ueyama 911d60a1e4 [Driver][Core] Handle -mllvm option.
llvm-svn: 183347
2013-06-05 23:19:18 +00:00
Rafael Espindola 0b87956542 Update for llvm's r183337.
llvm-svn: 183338
2013-06-05 20:35:36 +00:00
Rafael Espindola e699c60021 Now that llvm-readobj is fixed, enable this test.
llvm-svn: 183285
2013-06-05 01:38:12 +00:00
Rui Ueyama 143672c7e5 [lld][ELF] Add parser for linker script ENTRY command
This is the parser for the ENTRY command. Note that because the parsing result
is currentlyd discarded, lld can parse but just ignore the command.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 183141
2013-06-03 18:05:21 +00:00
Rui Ueyama feaa72a4b0 Fix typo in comment.
llvm-svn: 183050
2013-05-31 22:08:30 +00:00
Rui Ueyama 739730e299 [WinLink][Driver] Add -entry command line option.
llvm-svn: 183034
2013-05-31 19:34:29 +00:00
Rui Ueyama ce42bcc304 [WinLink][Driver] Add support for -subsystem optional OS version number.
llvm-svn: 182988
2013-05-31 06:30:10 +00:00
Rui Ueyama d752c9cc89 Fix typo in file header.
llvm-svn: 182985
2013-05-31 04:46:44 +00:00
Rui Ueyama 7eb1d49a58 [Driver] Add unit tests for GnuLdDriver.
llvm-svn: 182980
2013-05-31 02:12:34 +00:00
Michael J. Spencer 615c076fc1 Revert "[Passes] Parallelize the layout pass sort."
Inconsistent (and wrong) sort order on non-Windows.

llvm-svn: 182975
2013-05-31 00:05:49 +00:00
Rui Ueyama a21397fb01 [WinLink] Add a test for Windows-style command line options.
llvm-svn: 182971
2013-05-30 23:29:28 +00:00
Rui Ueyama 5f037590de [lld][WinLink] Fix use-after-return and add unit tests.
llvm-svn: 182970
2013-05-30 23:17:58 +00:00
Rui Ueyama b33e8bcef8 [WinLink][Driver] Handle file extensions and defualt output file name.
llvm-svn: 182912
2013-05-30 06:00:10 +00:00
Shankar Easwaran a5008e3a63 [lld][elf] Add --dynamic-linker option to the ELF linker.
Users can override the default value of the dynamic linker to be set to the
one that appears in the command line. The path can even be empty!. 

Added a test for the option.

llvm-svn: 182889
2013-05-29 22:51:01 +00:00
Rui Ueyama 81247063bf [WinLink] Add -subsystem and -out command line option parsing.
The code to actually consume these flags will be added soon.

llvm-svn: 182824
2013-05-29 05:07:49 +00:00
Michael J. Spencer 20cd8b6114 Parallel write.
llvm-svn: 182795
2013-05-28 19:09:56 +00:00
Michael J. Spencer 5b904eccad [Core] Add parallel_for_each.
llvm-svn: 182794
2013-05-28 19:09:39 +00:00
Michael J. Spencer 9ae1408556 [ELF] Make addressOfAtom thread safe.
The expression _atomToAddressMap[atom] may modify _atomToAddressMap.

llvm-svn: 182793
2013-05-28 19:09:25 +00:00
Michael J. Spencer 0d9d3110c7 [Passes] Parallelize the layout pass sort.
llvm-svn: 182792
2013-05-28 19:03:29 +00:00
Michael J. Spencer bd66d04f34 Instrument things.
llvm-svn: 182789
2013-05-28 18:55:39 +00:00
Michael J. Spencer 427354ee21 [ELF][Reader] Kind in this context refers to File::Kind. Qualify with Reference::Kind.
llvm-svn: 182787
2013-05-28 18:43:17 +00:00
Michael J. Spencer e5b8fe1274 [Driver] Parallelize reading initial object files.
llvm-svn: 182786
2013-05-28 18:37:39 +00:00
Rui Ueyama 9e56839a83 [lld][PECOFF] Add WinLinkDriver and PECOFFTargetInfo.
Add WinLinkDriver and connect it to the existing COFF reader. Remaining
parts are still stubs, so while it can now read a COFF file, it still
cannot link or output PE/COFF files yet.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 182784
2013-05-28 18:13:31 +00:00
Rui Ueyama 4cf437a1e9 [PECOFF] Skip section names in the symbol table because they are not atoms.
llvm-svn: 182721
2013-05-26 23:09:01 +00:00