Commit Graph

927 Commits

Author SHA1 Message Date
Simon Atanasyan 16c425e985 [Mips] Mark class by 'final' keyword.
llvm-svn: 203401
2014-03-09 13:05:03 +00:00
Simon Atanasyan 8801c45110 [Mips] Remove redundant 'mips' prefix from names of MipsTargetHandler
and MipsDynamicSymbolTable classes fields.

llvm-svn: 203400
2014-03-09 13:04:56 +00:00
Simon Atanasyan 4881a93b73 [Mips] Remove redundant call to the unique_ptr::get() method followed
by the returned pointer dereferencing.

llvm-svn: 203399
2014-03-09 13:04:50 +00:00
Simon Atanasyan f08deab395 [Mips] Remove unused class field.
llvm-svn: 203398
2014-03-09 13:04:45 +00:00
Rui Ueyama 0b87794f2b Remove extra space.
llvm-svn: 203331
2014-03-08 01:45:39 +00:00
Michael J. Spencer 95a90099fa [docs] Add missing features for the x86-64 ELF backend.
llvm-svn: 203313
2014-03-07 23:54:27 +00:00
Rui Ueyama c79dd2f80a [PECOFF] Support a new type of weak symbol.
Summary:
COMDAT_SELECT_SAME_SIZE is a COMDAT type that I presume exist only in COFF.
The semantics of the type is that linker should merge such COMDAT sections if
their sizes are the same. Otherwise it's an error.

Reviewers: Bigcheese, shankarke, kledzik

CC: llvm-commits

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

llvm-svn: 203308
2014-03-07 23:05:10 +00:00
Simon Atanasyan e9ba661696 [Mips] Removed extra space. Thanks to dexonsmith's eagle eye.
llvm-svn: 203201
2014-03-07 04:50:53 +00:00
Rui Ueyama 16e543bc02 Add "override" and remove "virtual" where appropriate.
For the record, I used clang-modernize to add "override" and perl to remove
"virtual".

llvm-svn: 203164
2014-03-06 21:14:04 +00:00
Simon Atanasyan 54f6f7bd77 [Mips] Replace "virtual" by "override" in member function declarations
where it is appropriate.

llvm-svn: 203102
2014-03-06 10:29:45 +00:00
Rui Ueyama d6ad741e5e Add "override" to member functions where appropriate.
llvm-svn: 202998
2014-03-05 19:50:03 +00:00
Rui Ueyama 182437e63f [PECOFF] Sort x64 exception handler table.
Just like x86 exception handler table, the table for x64 needs to be sorted
so that runtime can binary search on it. Unlike x86, the table entry for x64
has multiple fields, and they need to be sorted according to its BeginAddress
field. This patch also fixes a bug in relocations.

llvm-svn: 202874
2014-03-04 18:39:12 +00:00
Ahmed Charles d779459f21 [C++11] Add #include's for OwningPtr.
Allows removing #include's in LLVM while switching to std::unique_ptr.

llvm-svn: 202679
2014-03-03 07:20:05 +00:00
Benjamin Kramer 3445d9edad [C++11] Work around an incompatibility between llvm::tie and std::tie.
llvm-svn: 202645
2014-03-02 13:45:18 +00:00
Chandler Carruth 5de228b287 [C++11] Replace LLVM_OVERRIDE with just "override" now that we're all
using MSVC 2012 or newer.

llvm-svn: 202627
2014-03-02 09:39:44 +00:00
Chandler Carruth 6eface7c9d [C++11] Switch from LLVM_FINAL to just "final" now that all of LLVM is
requiring MSVC 2012 or newer.

llvm-svn: 202626
2014-03-02 09:35:33 +00:00
Rui Ueyama 5522e81f12 [PECOFF] Sort SEH table entries according to its value.
It looks like the contents of the table need to be sorted according to its
value, so that the runtime can find the entry by binary search. I'm not 100%
sure if we really have to do that, but at least I can say it's safe to do
because the contents of .sxdata is just a list of exception handlers' RVAs.

llvm-svn: 202550
2014-02-28 22:17:53 +00:00
Rui Ueyama b85f31c7a2 [PECOFF] Set "Exception Table" field in PE32+ header.
llvm-svn: 202527
2014-02-28 18:25:09 +00:00
Shankar Easwaran 8353f965c4 [Hexagon] Rename the header file.
This is to accomodate future changes for newer revisions of the DSP.

No change in functionality.

llvm-svn: 202350
2014-02-27 06:28:49 +00:00
Rui Ueyama 1710fe7de9 [PECOFF] Add a test for /SAFESEH:NO for non-x86 machine type.
llvm-svn: 202322
2014-02-27 00:05:43 +00:00
Simon Atanasyan 930ea1892f [Mips] Remove non-ASCII symbol from the comment.
llvm-svn: 202290
2014-02-26 19:23:52 +00:00
Simon Atanasyan 46ff3ce2bd [Mips] Split reloc26 function into two parts - for processing local and
external relocations.

llvm-svn: 202289
2014-02-26 19:17:20 +00:00
Simon Atanasyan 2043ee167c [Mips] Use a correct number of bits when apply result of calculated relocation.
llvm-svn: 202288
2014-02-26 19:17:14 +00:00
Simon Atanasyan a444eae5ce [Mips] Exit from the class method as soon as possible.
llvm-svn: 202287
2014-02-26 19:17:07 +00:00
Rui Ueyama 2e09d93f74 [PECOFF] Emit Load Configuration and SEH Table for x86.
If all input files are compatible with Structured Exception Handling, linker
is supposed to create an exectuable with a table for SEH handlers. The table
consists of exception handlers entry point addresses.

The basic idea of SEH in x86 Microsoft ABI is to list all valid entry points
of exception handlers in an read-only memory, so that an attacker cannot
override the addresses in it. In x86 ABI, data for exception handling is mostly
on stack, so it's volnerable to stack overflow attack. In order to protect
against it, Windows runtime uses the table to check a return address, to
ensure that the address is really an valid entry point for an exception handler.

Compiler emits a list of exception handler functions to .sxdata section. It
also emits a marker symbol "@feat.00" to indicate that the object is compatible
with SEH. SEH is a relatively new feature for COFF, and mixing SEH-compatible
and SEH-incompatible objects will result in an invalid executable, so is the
marker.

If all input files are compatible with SEH, LLD emits a SEH table. SEH table
needs to be pointed by Load Configuration strucutre, so when emitting a SEH
table LLD emits it too. The address of a Load Configuration will be stored to
the file header.

llvm-svn: 202248
2014-02-26 08:27:59 +00:00
NAKAMURA Takumi 955d27a4ce [CMake] Use target_link_libraries(INTERFACE|PRIVATE) on CMake-2.8.12 to increase opportunity for parallel build.
target_link_libraries(INTERFACE) doesn't bring inter-target dependencies in add_library,
although final targets have dependencies to whole dependent libraries.
It makes most libraries can be built in parallel.

target_link_libraries(PRIVATE) is used to shaared library.
Each dependent library is linked to the target.so, and its user will not see its grandchildren.
For example,

  - libclang.so has sufficient libclang*.a(s).
  - c-index-test requires just only libclang.so.

FIXME: lld is tweaked minimally. Adding INTERFACE in each library would be better thing.
llvm-svn: 202241
2014-02-26 06:53:16 +00:00
NAKAMURA Takumi 9f4ee24ac6 lldReaderWriter: move LLVM_LINK_COMPONENTS. It seems Subdirectories don't depend on LLVMObject.
Please give LLVMObject explicitly in each subdirectory if any of subdirectories required it.

llvm-svn: 202236
2014-02-26 06:28:09 +00:00
Rui Ueyama aaf2816d59 [PECOFF] Add a utility function to add DIR32 relocation.
llvm-svn: 202217
2014-02-26 02:38:40 +00:00
Rui Ueyama f9be75f538 [PECOFF] Fix DLLCharacteristics field.
IMAGE_DLL_CHARACTERISTICS_NO_SEH flag should be set only when SEH is disabled.

llvm-svn: 202215
2014-02-26 02:31:53 +00:00
Shankar Easwaran a328344367 [LinkerScript] parse OUTPUT_FORMAT : treat quotedStrings as identifier
llvm-svn: 202166
2014-02-25 17:02:54 +00:00
Rui Ueyama d08472f6c3 [COFF] Refactor .drectve section handling. No functionality change.
llvm-svn: 202113
2014-02-25 05:37:47 +00:00
Shankar Easwaran 2ea5148eff [LinkerScript] OUTPUT_FORMAT: Parse Quoted Strings
llvm-svn: 202111
2014-02-25 05:17:24 +00:00
Shankar Easwaran 822ea4f9a3 [LinkerScript] parse OUTPUT_ARCH.
llvm-svn: 202100
2014-02-25 01:55:13 +00:00
Nico Rieck b9d84f4d14 [lld] Include reference kind in cycle detector debug output
This restores the debug output to how it was before r197727 broke it. This
went undetected because the corresponding test was never run due to broken
feature detection.

llvm-svn: 202079
2014-02-24 21:14:37 +00:00
Rafael Espindola f27f9fa136 Update for LLVM api change.
llvm-svn: 202054
2014-02-24 18:20:36 +00:00
Rafael Espindola 27810169cb Don't assume that F_None is the default. It is about to change.
llvm-svn: 202039
2014-02-24 15:06:34 +00:00
Nico Rieck aa675e9379 [PECOFF] Fix uninitialized variable
llvm-svn: 201970
2014-02-23 10:40:15 +00:00
Rui Ueyama a5dc335574 [PECOFF] Implement /SAFESEH option.
LLD now prints an error message if /SAFESEH option is specified and one or
more input files are not compatible with SEH.

llvm-svn: 201900
2014-02-21 22:50:27 +00:00
Shankar Easwaran 9578442fe9 [ELF] Dont generate PHDR when creating dynamic libraries.
llvm-svn: 201741
2014-02-19 23:46:13 +00:00
Shankar Easwaran babba413f5 [ELF] Fix alignment for dynamic relocation sections.
The sections .rela/.rel.(*) have a alignment of 2 in the final image created by
the linker. This needs to be properly set to the right alignment depending on
the architecture(32/64bits).

llvm-svn: 201740
2014-02-19 23:46:08 +00:00
Simon Atanasyan 06f8ea4c07 [Mips] Simplify the code. Replace redundant 'switch' operator by the single 'if' one.
llvm-svn: 201131
2014-02-11 06:36:16 +00:00
Simon Atanasyan bf987c2dae [Mips] Handle R_MIPS_COPY relocation.
llvm-svn: 201129
2014-02-11 05:34:02 +00:00
Rafael Espindola 20d93679c7 Update for llvm api change.
llvm-svn: 201109
2014-02-10 20:24:27 +00:00
Nick Kledzik cdf2c8be58 [mach-o] use new way to copy StringRefs
llvm-svn: 200956
2014-02-06 23:48:52 +00:00
Simon Atanasyan 0743a72caa Accept and handle absolute symbols with empty name.
llvm-svn: 200911
2014-02-06 07:35:16 +00:00
Simon Atanasyan b828ebb5dd [Mips] In case of executable file linking MIPS ABI requires to add even
undefined symbols to '.dynsym' if these symbols have corresponding entries
in a global part of GOT.

llvm-svn: 200716
2014-02-03 20:10:40 +00:00
Simon Atanasyan 0912fe06dc [Mips] Unify #include guard names.
llvm-svn: 200715
2014-02-03 20:10:30 +00:00
Shankar Easwaran 6e0e1bc859 [ELF] change LayoutBefore Reference to InGroup Reference
This makes it a lot easier for Section Group design.

llvm-svn: 200675
2014-02-03 04:01:14 +00:00
Joey Gouly cf466800b7 [MachO] Add undefined atoms.
llvm-svn: 200649
2014-02-02 19:34:55 +00:00
Simon Atanasyan e6f6f06c91 [ELF] Customize dynamic table tag used for .got.plt section referencing.
The patch reviewed by Shankar Easwaran and Rui Ueyama.

llvm-svn: 200630
2014-02-02 12:19:29 +00:00
Rafael Espindola 8c13e51764 Update for llvm api change.
llvm-svn: 200575
2014-01-31 21:13:59 +00:00
Rui Ueyama 14876abb3d [PECOFF] Set the correct PE header field value.
The charcateristics field should not have IMAGE_FILE_32BIT_MACHINE bit but have
IMAGE_FILE_LARGE_ADDRESS_AWARE bit for PE32+.

llvm-svn: 200518
2014-01-31 05:43:12 +00:00
Rui Ueyama ebc13c47f2 [PECOFF] Do not emit a section if it's empty.
The PE32+ loader does not seem to like an executable with an empty section, so
we should not emit a section if it's empty.

llvm-svn: 200514
2014-01-31 05:15:42 +00:00
Rui Ueyama 8851d45cbf Replace magic numbers with enums.
llvm-svn: 200512
2014-01-31 04:57:03 +00:00
Rui Ueyama ea7e9306c1 [PECOFF] Default image base address for PE32+ is 0x140000000, not 0x400000.
llvm-svn: 200511
2014-01-31 04:49:13 +00:00
Simon Atanasyan bc286a4dbc [ELF] Make private all DynamicTable class fields which are not used in
the descendant classes.

llvm-svn: 200467
2014-01-30 14:20:22 +00:00
Rafael Espindola 8fe1f37c55 Update for llvm api change.
llvm-svn: 200443
2014-01-30 02:49:58 +00:00
Shankar Easwaran b6a6bdab20 [ELF][Hexagon] typeZeroFillQuick is not associated with bss section.
We need to increase the memory and the filesize when we add a typeZeroFillQuick
atom.

llvm-svn: 200369
2014-01-29 04:04:27 +00:00
Simon Atanasyan 7aa9061ead [Mips] Declare MipsDynamicTable class in a separate header file.
llvm-svn: 200328
2014-01-28 18:52:41 +00:00
Rui Ueyama 4aaba3e220 [PECOFF] Replace magic numbers with sizeof.
llvm-svn: 200278
2014-01-28 01:55:37 +00:00
Rui Ueyama 22291d2cbf [PECOFF] Implement some relocations for x86-64.
llvm-svn: 200240
2014-01-27 19:23:12 +00:00
Rui Ueyama b73d28525a [PECOFF] Implement relocations for x86-64.
llvm-svn: 200185
2014-01-27 03:53:30 +00:00
Rui Ueyama 7d1bf45047 [PECOFF] Fix PE/COFF optional header size for PE32+.
The optional header for PE32+ is a bit larger than PE32 because some of
its fields are extended to 8 bytes.

llvm-svn: 200184
2014-01-27 03:53:26 +00:00
Rui Ueyama f1a2d55e2b [PECOFF] Set a proper architecture type to references.
Relocations for x64 object files should have reference type of
KindArch::x86_64.

llvm-svn: 200183
2014-01-27 03:53:23 +00:00
Shankar Easwaran 3d8de47f76 Fix trailing whitespace.
llvm-svn: 200182
2014-01-27 03:09:26 +00:00
Shankar Easwaran a64ba010f0 [ELF] Fix comments.
The comments in the files that described the file name as part of each file
header ran over 80 columns, which clang-format split over multiple lines.

This commit fixes to make them appear properly.

llvm-svn: 200181
2014-01-27 02:55:08 +00:00
Shankar Easwaran b11964707c [ELF] Make changes to all the targets supported currently
X86_64,X86,PPC,Hexagon,Mips

No change in functionality.

llvm-svn: 200177
2014-01-27 01:21:02 +00:00
Shankar Easwaran af7fbd8cf4 [ELF] Create Target specific Writers.
llvm-svn: 200176
2014-01-27 01:20:53 +00:00
Shankar Easwaran e7b831ad35 [ELF] Add Target specific Readers.
No change in functionality.

llvm-svn: 200175
2014-01-27 01:02:03 +00:00
Shankar Easwaran d7de108cde [ELF] Separate ELFReader classes for subclassing
llvm-svn: 200173
2014-01-27 00:45:57 +00:00
Shankar Easwaran f755ca1685 [ELF] Unify interfaces between DynamicFile/ELFFile.
llvm-svn: 200172
2014-01-27 00:40:49 +00:00
Shankar Easwaran f3db51d06f [ELF] Separate implementation from the class declaration.
ELFFile would be a class that rest of the targets would derive from.
To keep the implementation clean, separate the implementation from
rest of the Header file.

llvm-svn: 200168
2014-01-26 23:57:20 +00:00
Shankar Easwaran 9691b01905 [ELF] Rename File.h to ELFFile.h to avoid confusion.
No change in functionality.

llvm-svn: 200166
2014-01-26 23:49:07 +00:00
Shankar Easwaran b888433e9c [ELF] Dont include all targets
llvm-svn: 200165
2014-01-26 23:47:18 +00:00
Rui Ueyama 56c4611340 [PECOFF] Emit PE32+ file header.
llvm-svn: 200128
2014-01-26 05:34:12 +00:00
Rui Ueyama c6ddf5654c [PECOFF] Use a shorter name for the parameter.
llvm-svn: 200107
2014-01-26 00:37:30 +00:00
Rui Ueyama 76c1b4d0fb [PECOFF] Set PE32+ magic value if 64 bit.
llvm-svn: 200106
2014-01-26 00:35:23 +00:00
Rui Ueyama 7dc69287c1 [PECOFF] Use a shorter name for the PECOFF writer member.
llvm-svn: 200052
2014-01-25 00:27:44 +00:00
Rui Ueyama 49bfd5032d [PECOFF] Accept /machine:x64 option.
This is the first patch to support PE32+ format, which is the image format
to use 64 bit address space on Windows/x86-64.

llvm-svn: 200029
2014-01-24 19:17:05 +00:00
Rui Ueyama 87e15c7585 [PECOFF] Use constant instead of magic number.
llvm-svn: 200019
2014-01-24 18:03:14 +00:00
Simon Atanasyan d8cadd6f17 [ELF] Customize a relocation table output format (rel / rela).
Add new virtual virtual function `isRelaOutputFormat` to the
`ELFLinkingContext` class. Call this function everywhere we need to
select a relocation table format.

Patch reviewed by Shankar Easwaran and Rui Ueyama.

llvm-svn: 199973
2014-01-24 05:21:21 +00:00
Rafael Espindola 6ba68f10c4 Update for llvm api change.
llvm-svn: 199777
2014-01-22 00:14:56 +00:00
Rafael Espindola 79e2d936fd Update for llvm api change.
llvm-svn: 199752
2014-01-21 16:09:55 +00:00
Simon Atanasyan 2f1d6366e7 [Mips] Emit ELF header for MIPS target. ELF flags set is mostly hardcoded.
Later we need to improve that solution and build a correct set of flags
by merging ELF flags from all input objects.

llvm-svn: 199555
2014-01-18 16:59:11 +00:00
Simon Atanasyan 0e57a77072 [Mips] Simplify calculations of relocations - replace scatterBits calls
by bitwise AND operator and remove redundant local variables.

llvm-svn: 199554
2014-01-18 16:59:00 +00:00
Simon Atanasyan 9ab3b8db84 [Mips] Allocate local GOT entry for a global symbol defined in an
executable file.

llvm-svn: 199517
2014-01-17 21:18:45 +00:00
Simon Atanasyan 362bdc125e [Mips] Implement .plt and .got.plt section creation.
llvm-svn: 199516
2014-01-17 21:18:37 +00:00
Simon Atanasyan 66338224be [Mips] Handle R_MIPS_26 relocation. Maintaining of .plt and .got.plt
sections will be implemented later.

llvm-svn: 199515
2014-01-17 21:18:26 +00:00
Simon Atanasyan 80b86a43d5 [Mips] Provide default name of MIPS-specific interpreter.
llvm-svn: 199514
2014-01-17 21:18:14 +00:00
Rafael Espindola 0de92d53a1 Update for llvm api change.
llvm-svn: 199327
2014-01-15 19:38:01 +00:00
Joey Gouly 010b37691d [MachO] Begin support for reading fat binaries.
llvm-svn: 199259
2014-01-14 22:32:38 +00:00
Simon Atanasyan 13c5ce53dc [Mips] Do not forget to initialize a class field.
llvm-svn: 199241
2014-01-14 18:20:07 +00:00
Simon Atanasyan e46e2dfe01 [Mips] Calculate gp value only once.
llvm-svn: 199240
2014-01-14 18:20:00 +00:00
Simon Atanasyan db2e1f35d8 [Mips] Create and initialize _gp symbol.
llvm-svn: 199239
2014-01-14 18:19:52 +00:00
Simon Atanasyan 6cac582de5 [Mips] Do not store a pointer to the AtomLayout related to the
_GLOBAL_OFFSET_TABLE_ symbol. We do not use this ponter anywhere after
assigning of virtual address.

llvm-svn: 199237
2014-01-14 18:19:35 +00:00
Simon Atanasyan 0b4dd91582 [Mips] Factor out constant represents gp value offset to the
MipsTargetLayout class method.

llvm-svn: 199236
2014-01-14 18:19:26 +00:00
Simon Atanasyan 663aa62863 [Mips] Set default base address for MIPS executables to 0x400000. Assign
the lowest segment address to the MIPS_BASE_ADDRESS dynamic tag.

llvm-svn: 199234
2014-01-14 18:19:12 +00:00
Simon Atanasyan a565c778b3 [ELF] Fix type of the DefaultLayout::segments() return value. This
method returns the DefaultLayout::_segments field. The type of this field is
a vector of Segment<ELFT>* pointers. This type cannot be implicitly casted to
the range<ChunkIter>.

llvm-svn: 199233
2014-01-14 18:19:02 +00:00
Joey Gouly d2215375a8 [MachO] Add basic support for local symbols.
llvm-svn: 199155
2014-01-13 22:28:02 +00:00
Nick Kledzik 0052bd4a34 Fix spacing
llvm-svn: 199074
2014-01-13 04:08:15 +00:00
Joey Gouly 9c826c100a Factor the symbol handling in normalizedToAtoms into a separate function.
No functionality change.

llvm-svn: 199066
2014-01-12 22:55:49 +00:00
Nick Kledzik 8293c711e7 [yaml] use BumpPtrAllocator for string copies
llvm-svn: 198987
2014-01-11 01:11:49 +00:00
Nick Kledzik 6edd722a2c [mach-o] enable mach-o and native yaml to be intermixed
The main goal of this patch is to allow "mach-o encoded as yaml" and "native
encoded as yaml" documents to be intermixed.  They are distinguished via 
yaml tags at the start of the document.  This will enable all mach-o test cases
to be written using yaml instead of checking in object files.

The Registry was extend to allow yaml tag handlers to be registered.  The
mach-o Reader adds a yaml tag handler for the tag "!mach-o". 

Additionally, this patch fixes some buffer ownership issues.  When parsing
mach-o binaries, the mach-o atoms can have pointers back into the memory 
mapped .o file.  But with yaml encoded mach-o, name and content are ephemeral, 
so a copyRefs parameter was added to cause the mach-o atoms to make their
own copy.  

llvm-svn: 198986
2014-01-11 01:07:43 +00:00
Simon Atanasyan c955a0cfd3 [Mips] Reduce the number of type-casting calls.
llvm-svn: 198855
2014-01-09 07:52:31 +00:00
Simon Atanasyan 7f82bc590d [Mips] Remove unnecessary #include pragma.
llvm-svn: 198798
2014-01-08 22:00:35 +00:00
Rafael Espindola d28918b289 Use getError instead of the error_code operator.
llvm-svn: 198797
2014-01-08 22:00:09 +00:00
Simon Atanasyan 073c2d2974 [Mips] GOT16 relocation against non-local symbol does not require a
paired LO16 relocation.

llvm-svn: 198790
2014-01-08 20:43:03 +00:00
Simon Atanasyan 05c88f9b61 [Mips] Add assert to check that we handle all paired relocations.
llvm-svn: 198789
2014-01-08 20:42:52 +00:00
Simon Atanasyan 2ab9f28977 [Mips] Factor out the code determines type of GOT entry (local/global)
into the separate function.

llvm-svn: 198788
2014-01-08 20:42:45 +00:00
Simon Atanasyan 50cf77bc2f [Mips] Do not use standard relocation identifier R_MIPS_NONE for
internal purpose. Use special LLD_R_MIPS_GLOBAL_GOT constant for that.

llvm-svn: 198787
2014-01-08 20:42:38 +00:00
Simon Atanasyan fc2e4e6a76 [Mips] Rename function to better reflect its purpose.
llvm-svn: 198786
2014-01-08 20:42:30 +00:00
Simon Atanasyan eef5351416 [Mips] Do not save GOT headers atoms into the RelocationPass class
fields.

llvm-svn: 198785
2014-01-08 20:42:23 +00:00
Simon Atanasyan 30464f0293 [Mips] Rename some classes to skip redundant mentioning of 'mips'.
llvm-svn: 198784
2014-01-08 20:42:17 +00:00
Simon Atanasyan 6e0232ce59 [Mips] Move MipsGOTPass implementation to the separate file.
llvm-svn: 198783
2014-01-08 20:42:11 +00:00
Nick Kledzik 36baa33fc1 [mach-o] properly extract atom content from subrange of section content
llvm-svn: 198728
2014-01-08 02:52:58 +00:00
Nick Kledzik 360a1434f0 Use the mach-o MH_* name for file types in yaml
llvm-svn: 198725
2014-01-08 01:38:07 +00:00
Rui Ueyama 903b14432d Remove leading underscore from parameters.
llvm-svn: 198642
2014-01-06 22:43:31 +00:00
Rui Ueyama b5531d7edb Rename parameters to fix shadow warnings.
llvm-svn: 198641
2014-01-06 22:31:01 +00:00
Rui Ueyama 54174c6f16 [PECOFF] Simplify: Replace two-value enum with bool.
llvm-svn: 198634
2014-01-06 19:55:58 +00:00
Joey Gouly 41cb030b53 [MachO] Add some missing NListTypes.
llvm-svn: 198468
2014-01-04 01:22:05 +00:00
Joey Gouly ceb16dedef [MachO] Begin to add some MachO specific File/Atoms, and add the start of
normalizedToAtoms.

llvm-svn: 198459
2014-01-03 23:12:02 +00:00
Rui Ueyama 76bc5157c2 Use scoped enum.
llvm-svn: 198396
2014-01-03 03:29:15 +00:00
Joerg Sonnenberger 1e259e79b9 No else after return.
llvm-svn: 198339
2014-01-02 19:30:56 +00:00
Joey Gouly 0518453e2e The return value of createInternalFiles is unused, so remove it.
llvm-svn: 198266
2013-12-31 19:15:42 +00:00
Rui Ueyama 93f760468e Simplify if ... return repetition.
llvm-svn: 198108
2013-12-28 10:09:21 +00:00
Rui Ueyama ffd810525d [PECOFF] Warn only when /export options are not compatible.
Currently LLD always print a warning message if the same symbol is specified
more than once for /export option. It's a bit annoying because specifying the
same symbol with compatible options is actually safe and considered as a
normal use case. This patch makes LLD to warn only when incompatible export
options are given.

llvm-svn: 198104
2013-12-28 08:40:37 +00:00
Rui Ueyama 02dfdbcbd6 temporary commit
llvm-svn: 198103
2013-12-28 08:40:23 +00:00
Rui Ueyama ad79838aa8 [PECOFF] Use std::set to store export symbol descriptors.
Each export symbol descriptor has unique name attribute, so std::set is
better container than std::vector for it. No functionality change.

llvm-svn: 198102
2013-12-28 08:11:21 +00:00
Joey Gouly 53c99b78a8 Fix a gcc-4.8 warning, about extraneous semicolons.
llvm-svn: 198091
2013-12-28 00:46:57 +00:00
Rui Ueyama d0cce867ae [PECOFF] Parse .drectve section before reading other file contents.
Currently .drectve section contents are parsed after other sections are parsed.
That order may result in wrong results if other sections depend on command line
options in the directive section.

For example, if a weak symbol is defined using /alternatename option in the
directive section, we have to read it first and then read the text section
contents. Otherwise the weak symbol won't be defined.

This patch changes the order to fix the issue.

llvm-svn: 198071
2013-12-27 07:05:04 +00:00
Rui Ueyama ae50a9e676 [PECOFF] Skip empty .drectve sections.
There are many object files in the standard library who have empty .drective
sections. Parsing the empty string is not wrong but a waste.

llvm-svn: 198067
2013-12-27 03:34:34 +00:00
Rui Ueyama 61b851ab06 Remove duplicate methods.
llvm-svn: 198034
2013-12-26 06:35:35 +00:00
Rui Ueyama b561f9eb0d [PECOFF] Fix wrong message.
llvm-svn: 198033
2013-12-26 06:26:47 +00:00
Joey Gouly 9d263e0afe Fix some indentation issues, I saw while reading this file.
llvm-svn: 198024
2013-12-25 19:39:08 +00:00
Rui Ueyama 208915b5ea Add a newline to an error message.
llvm-svn: 198016
2013-12-25 13:48:26 +00:00
Rui Ueyama cc66ff6776 [PECOFF] Set default subsystem to the DLL header.
Subsystem field in the PE/COFF file header has no meanining for the DLL.
It looks like MSVC link.exe sets the default subsystem (Windows GUI) to
the field if no /subsystem option is specified.

llvm-svn: 198015
2013-12-25 13:34:31 +00:00
Rui Ueyama 3c849f6a06 Unbreak buildbot.
llvm-svn: 198002
2013-12-25 07:28:34 +00:00
Rui Ueyama cf4616110c [PECOFF] Use the first definition of an export if specified multiple times.
If the same symbol is specified multiple times as arguments of /export, the
first definition should be used.

llvm-svn: 197998
2013-12-25 06:46:45 +00:00
Rui Ueyama 090a7cd76d [PECOFF] Fix /export option in the .drectve section.
/EXPORT option has slightly different semantics if it appears in the .drectve
section. This patch implements it.

llvm-svn: 197970
2013-12-24 09:15:57 +00:00
Joey Gouly b275d7f8f3 Fix indentation in the MachO writer.
llvm-svn: 197925
2013-12-23 23:29:50 +00:00
Nick Kledzik 6960b07b92 [mach-o] add MachOLinkingContext::configure(type, arch, os)
It will configure resonable defaults for other settings in the 
MachOLinkingContext object based on the parameters.  

Patch by Joe Ranieri

llvm-svn: 197851
2013-12-21 01:47:17 +00:00
Nick Kledzik f30e848432 Restore vertical alignment lost by clang-format
llvm-svn: 197834
2013-12-20 20:34:19 +00:00
Rui Ueyama d4f66c7d5f [PECOFF] Create noname or data symbols as such.
If a symbol in an import library is marked as "data", the linker will not
create a jump table entry for the symbol, since jump table makes sense only
for a symbol pointing to a function.

I don't think NONAME attribute has a meaning when creating an import library.
The attribute is emitted for debugging purpose.

llvm-svn: 197803
2013-12-20 11:50:19 +00:00
Rui Ueyama d07c1be171 [PECOFF] Create the import library file.
If the linker is instructed to create a DLL, it will also create an import
library (.lib file) to describe the symbols exported by the DLL. This patch is
to create the import library file.

There is a convenient command "lib.exe" which can create an import library
from a module definition file (.def file). The command is used in this patch.

llvm-svn: 197801
2013-12-20 11:35:40 +00:00
Rui Ueyama 4af032dce7 [PECOFF] Assign default export ordinals in LinkingContext::verify().
Default ordinals were assigned in EdataPass, and the assigned values were
then discarded in the pass. No code other than EdataPass would not be able
to get all of the information about ordinals. That's not ideal since I'm
writing code to emit an Import Library file, which also needs ordinals.

This is a patch to move the code to assign default ordinals from EdataPass
to LinkingContext::verify(), so that assigned ordinals will be available
anywhere.

No functionality change.

llvm-svn: 197797
2013-12-20 10:02:59 +00:00
Rui Ueyama 170a1a892e Run clang-format on r197727.
llvm-svn: 197788
2013-12-20 07:48:29 +00:00
Nick Kledzik fc3a975d85 [lld] fix unused variable warnings
llvm-svn: 197737
2013-12-19 22:50:08 +00:00
Nick Kledzik 58089e1362 [lld] fix build when LLVM_HAS_VARIADIC_TEMPLATES is false
llvm-svn: 197734
2013-12-19 22:40:17 +00:00
Nick Kledzik e555277780 [lld] Introduce registry and Reference kind tuple
The main changes are in:
  include/lld/Core/Reference.h
  include/lld/ReaderWriter/Reader.h
Everything else is details to support the main change.

1) Registration based Readers
Previously, lld had a tangled interdependency with all the Readers.  It would
have been impossible to make a streamlined linker (say for a JIT) which
just supported one file format and one architecture (no yaml, no archives, etc).
The old model also required a LinkingContext to read an object file, which
would have made .o inspection tools awkward.

The new model is that there is a global Registry object. You programmatically 
register the Readers you want with the registry object. Whenever you need to 
read/parse a file, you ask the registry to do it, and the registry tries each 
registered reader.

For ease of use with the existing lld code base, there is one Registry
object inside the LinkingContext object. 


2) Changing kind value to be a tuple
Beside Readers, the registry also keeps track of the mapping for Reference
Kind values to and from strings.  Along with that, this patch also fixes
an ambiguity with the previous Reference::Kind values.  The problem was that
we wanted to reuse existing relocation type values as Reference::Kind values.
But then how can the YAML write know how to convert a value to a string? The
fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace
(e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and
a 16-bit value.  This tuple system allows conversion to and from strings with 
no ambiguities.

llvm-svn: 197727
2013-12-19 21:58:00 +00:00
Rui Ueyama c83e1730c5 Remove dead code.
llvm-svn: 197662
2013-12-19 08:05:34 +00:00