Commit Graph

565 Commits

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