Commit Graph

1160 Commits

Author SHA1 Message Date
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
Rui Ueyama d9e7c22ee4 [PECOFF] Driver support for /SAFESEH option.
Syntactically /SAFESEH is a boolean flag -- you can pass /SAFESEH or /SAFESEH:no.

The meaning of /SAFESEH is as follows.

 - If /SAFESEH is specified, the linker will produce an executable with SEH table.
   If any input files are not compatible with SEH, it's an error.
 - If /SAFESEH:no is specified, the linker will not emit SEH table even if all
   input files are compatible with SEH.
 - If no option is specified, the linker emits SEH table if all input files are
   compatible with SEH.

llvm-svn: 201895
2014-02-21 22:30:43 +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
Rui Ueyama c5326ca9bb [PECOFF] Add a TODO.
llvm-svn: 200599
2014-02-01 00:26:33 +00:00
Rui Ueyama 9661bcf2e1 [PECOFF] Handle /machine option before handling all the other options.
The target machine type affects the meaning of other options, in particular
how to mangle symbols. So we want to handle the option first and then parse
all the other options.

llvm-svn: 200589
2014-01-31 22:58:19 +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