Commit Graph

2603 Commits

Author SHA1 Message Date
Rui Ueyama 7675f06c01 Remove redundant "explicit".
llvm-svn: 230015
2015-02-20 14:57:04 +00:00
Jean-Daniel Dupas 7329636d1b [Mach-O] Remove redundant allocator
llvm-svn: 230007
2015-02-20 11:57:06 +00:00
Justin Bogner de525e76d7 Driver: Fix an incorrect use of llvm::None
This function returns a bool, so llvm::None doesn't make sense here.

llvm-svn: 229997
2015-02-20 08:19:43 +00:00
David Majnemer 62ac78ae3e LinkerScript: Remove leaks in the parser
LinkerScript AST nodes are never destroyed which means that their
std::vector members will never be destroyed.

Instead, allocate the operand list itself in the Parser's
BumpPtrAllocator.  This ensures that the storage will be destroyed along
with the nodes when the Parser is destroyed.

llvm-svn: 229967
2015-02-20 05:10:06 +00:00
Rui Ueyama 11f42aa285 PECOFF: Fix base relocation for ImageBase.
This is yet another edge case of base relocation for symbols. Absolute
symbols are in general not target of base relocation because absolute
atom is a way to point to a specific memory location. In r229816, I
removed entries for absolute atoms from the base relocation table
(so that they won't be fixed by the loader).

However, there was one exception -- ImageBase. ImageBase points to the
start address of the current image in memory. That needs to be fixed up
at load time. This patch is to treat the symbol in a special manner.

llvm-svn: 229961
2015-02-20 03:35:59 +00:00
Greg Fitzgerald cdaea4db26 Fix heap-buffer-overflow bugs identified by the Address Sanitizer
Differential Revision: http://reviews.llvm.org/D7733

llvm-svn: 229912
2015-02-19 20:42:23 +00:00
Jean-Daniel Dupas c31da7010b [Mach-O] Rename enum typename for consistency. NFC
Typename shouldn't mix camel case and underscore.
Thanks to Rui for the remark.

llvm-svn: 229848
2015-02-19 12:38:54 +00:00
Rui Ueyama 3966c61536 PECOFF: Fix base relocation for an absolute symbol.
Previously we wrongly emitted a base relocation entry for an absolute symbol.
That made the loader to rewrite some instruction operands with wrong values
only when a DLL is not loaded at the default address. That caused a
misterious crash of some executable.

Absolute symbols will of course never change value wherever the binary is
loaded to memory. We shouldn't emit base relocations for absolute symbols.

llvm-svn: 229816
2015-02-19 04:22:27 +00:00
Rui Ueyama 3e6490f1e8 PECOFF: use llvm-readobj to dump .reloc section
When this test was written, no llvm tool could print out contents
of base relocation section. Now llvm-readobj is able to dump it in
a text format. Use that tool to make this test readable.

llvm-svn: 229814
2015-02-19 04:02:17 +00:00
Rui Ueyama 92b5979cb5 PECOFF: Fix symbol aliases
Weak aliases defined using /alternatename command line option were getting
wrong RVAs in the final output because of wrong atom ordinal. Alias atoms
were assigned large ordinals than any other regular atoms because they were
instantiated after other atoms and just got new (larger) ordinals.

Atoms are sorted by its file and atom ordinals in the order pass. Alias
atoms were located after all other atoms in the same file.

An alias atom's ordinal needs to be smaller than its alias target but larger
than the atom appeared before the target -- so that the alias is located
between the two. Since an alias has no size, the alias target will be located
at the same location as the alias.

In this patch, I made a gap between two regular atoms so that we can put
aliases after instantiating them (without re-numbering existing atoms).

llvm-svn: 229762
2015-02-18 23:11:48 +00:00
Greg Fitzgerald 7f1c7e1bef Fix use-after-free bug identified by the Address Sanitizer
atomContent's memory is freed at the end of the stack frame,
but it is referenced by the atom pushed into _definedAtoms.

Differential Revision: http://reviews.llvm.org/D7732

llvm-svn: 229749
2015-02-18 21:54:32 +00:00
Davide Italiano 6d86bb2f8b [ELF] Demangle: don't expose raw info when getter is available.
Differential Revision:	D7693
Reviewed by:	shankarke

llvm-svn: 229635
2015-02-18 03:54:21 +00:00
Will Newton 8d62e098ef Fix AArhc64 ELF test failure on Windows
The atoms may be processed in different orders on different systems
based on allocated addresses. This is a bit unfortunate as it would
be nice to have error messages emitted in order of file contents.
However we are emitting errors inside a parallel_for_each so even if
we stabilize the order of atom processing we would need to do some
further work in order to ensure that thread scheduling doesn't perturb
the order of errors. For now switch to using CHECK-DAG instead of CHECK.

llvm-svn: 229487
2015-02-17 11:16:54 +00:00
Simon Atanasyan f83bd0341d [Mips] Replace a magic number by enumeration
No functional changes.

llvm-svn: 229453
2015-02-16 23:08:20 +00:00
Simon Atanasyan fbe1348ef4 [Mips] Read GP0 value from .MIPS.options section
llvm-svn: 229442
2015-02-16 21:52:43 +00:00
Simon Atanasyan 371e1128b3 [Mips] Show error if MIPS_REGINFO section has invalid size
llvm-svn: 229441
2015-02-16 21:52:35 +00:00
Simon Atanasyan 00400f252d [Mips] Factor out the code to search section by type and flags into the
separate functions

No functional changes.

llvm-svn: 229440
2015-02-16 21:52:27 +00:00
Aaron Ballman 4d0397382c MSVC no longer requires the explicit cast operation to obtain a function pointer from this capture-less lambda. NFC.
llvm-svn: 229426
2015-02-16 19:38:52 +00:00
Aaron Ballman d816003d2b MSVC 2013 appears to be able to compile make_ptr_range without issue, so removing that guard in the unit test.
llvm-svn: 229410
2015-02-16 18:00:11 +00:00
Aaron Ballman 80c1239f1b Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; lld edition.
llvm-svn: 229341
2015-02-15 23:10:05 +00:00
Jean-Daniel Dupas 9c222630e4 Update ARM and x86 ArchHandler to check switch completeness. NFC
Define an explicit type for arch specific reference kinds to make sure all cases are covered in switch statements.

llvm-svn: 229314
2015-02-15 15:23:48 +00:00
Jean-Daniel Dupas 1536f0641b Break some test. Revert until I got a proper fix
llvm-svn: 229249
2015-02-14 09:10:25 +00:00
Jean-Daniel Dupas 8860b8d70c Update ARM and x86 ArchHandler to match 64bits counterparts. NFC
Summary:
Define an explicit type for arch specific reference kind and use it in switch statement to make the compiler emit warnings if some case is not cover.
It will help to catch such errors when we add new mach-o reference kind.

Reviewers: shankarke, kledzik

Reviewed By: shankarke

Subscribers: shankarke, aemerson, llvm-commits

Projects: #lld

Differential Revision: http://reviews.llvm.org/D7612

llvm-svn: 229246
2015-02-14 08:34:37 +00:00
Shankar Easwaran 8911240c9e [ELF] Replace std::set with StringSet.
Wrap functionality was using a std::set to record symbols that need to be
wrapped. This changes the implementation to use a StringSet instead.

No change in functionality.

llvm-svn: 229165
2015-02-13 22:26:51 +00:00
Jean-Daniel Dupas 5716bb9faa Remove file not used anywhere.
llvm-svn: 229109
2015-02-13 14:30:22 +00:00
Jean-Daniel Dupas 48bc169f04 Using 'isa' instead of 'dyn_cast'
llvm-svn: 229107
2015-02-13 14:28:18 +00:00
Will Newton 6b3f59b6a9 ELF/AArch64: Add support for checking for ABS32 overflow
Add support for checking overflow when applying a R_AARCH64_ABS32
relocation and add a test to ensure it behaves correctly.

llvm-svn: 229072
2015-02-13 06:22:31 +00:00
Rui Ueyama d9cb620330 Remove unused parameters.
llvm-svn: 229055
2015-02-13 04:02:55 +00:00
Rui Ueyama 8e19879f5a Remove KindArcH::PowerPC and sort enums alphabetically.
llvm-svn: 229051
2015-02-13 03:47:34 +00:00
Rui Ueyama dcd61c2d14 Remove class that really does nothing.
llvm-svn: 229030
2015-02-13 02:34:08 +00:00
Rui Ueyama acbe51a0e3 PECOFF: Fix dummy symbol table in executable.
If the name field of a symbol table entry is all zero, it's interpreted
as it's pointing to the beginning of the string table. The first four
bytes of the string table is the size field, so dumpbin dumps that number
as an ASCIZ string.

This patch fills a dummy value to name field.

llvm-svn: 228971
2015-02-12 22:46:16 +00:00
Shankar Easwaran 7d71622c8f [ELF] Insert wrap symbols into a set.
Symbols specified by --wrap was being inserted into a vector, change this to
insert into a set, so that we have unique entries.

llvm-svn: 228968
2015-02-12 22:37:27 +00:00
Rui Ueyama 3c3c7d8911 PECOFF: Don't parse files in .drectve asynchronously.
Looks like there's a race condition around here that caused LLD to crash
on Windows. Currently we are parsing libraries specified by .drectve section
asynchronously, and something is wrong in that process. Disable the feature
for now to make buildbots happy.

llvm-svn: 228955
2015-02-12 20:33:40 +00:00
Shankar Easwaran 5c094b8751 [ELF][Cleanup] Remove unused function
We can add this function when we really have a need.

llvm-svn: 228907
2015-02-12 05:29:50 +00:00
Shankar Easwaran 2df0c3efd6 [ELF] Support --wrap option
Use a wrapper function for symbol. Any undefined reference to symbol will be
resolved to "__wrap_symbol". Any undefined reference to "__real_symbol" will be
resolved to symbol.

This can be used to provide a wrapper for a system function. The wrapper
function should be called "__wrap_symbol". If it wishes to call the system
function, it should call "__real_symbol".

Here is a trivial example:

void * __wrap_malloc (size_t c)
{
  printf ("malloc called with %zu\n", c);
  return __real_malloc (c);
}

If you link other code with this file using --wrap malloc, then all calls
to "malloc" will call the function "__wrap_malloc" instead. The call to
"__real_malloc" in "__wrap_malloc" will call the real "malloc" function.

llvm-svn: 228906
2015-02-12 05:02:46 +00:00
Shankar Easwaran f7a8da3384 [ELF] Add LinkingContext to the ELFReader.
This adds the LinkingContext parameter to the ELFReader. Previously the flags in
that were needed in the Context was passed to the ELFReader, this made it very
hard to access data structures in the LinkingContext when reading an ELF file.

This change makes the ELFReader more flexible so that required parameters can be
grabbed directly from the LinkingContext.

Future patches make use of the changes.

There is no change in functionality though.

llvm-svn: 228905
2015-02-12 05:02:41 +00:00
Rui Ueyama 1a40b2062c PECOFF: make dumpbin tool happy.
The dumpbin tool in the MSVC toolchain cannot handle an executable created
by LLD if the executable contains a long section name.

In PE/COFF, a section name is stored to a section table entry. Because the
section name field in the table is only 8 byte long, a name longer than
that is stored to the string table and the offset in the string table is
stored to the section table entry instead.

In order to look up a string from the string table, tools need to handle
the symbol table, because the string table is defined as it immediately
follows the symbol table.

And seems the dumpbin doesn't like zero-length symbol table.

This patch teaches LLD how to emit a dummy symbol table. The dummy table
has one dummy entry in it.

llvm-svn: 228900
2015-02-12 02:50:05 +00:00
Rui Ueyama 30c5387983 Remove unused parameter.
llvm-svn: 228887
2015-02-11 23:22:34 +00:00
Denis Protivensky d6fe5b3005 [ELF][ARM] Fix veneer symbol names in Release build
The fix is for r228680.
This makes tests also work.

llvm-svn: 228837
2015-02-11 15:02:43 +00:00
Rui Ueyama 123ad4cde7 GNU: Rename parseZOption because it actually parses only -z max-page-size.
llvm-svn: 228753
2015-02-10 21:40:51 +00:00
Rui Ueyama ea6c8e9c1f Unittest: Do s/_context/_ctx/g.
llvm-svn: 228750
2015-02-10 21:28:52 +00:00
Rui Ueyama 2050b61451 GNU: Add --no-export-dynamic command line option.
llvm-svn: 228749
2015-02-10 21:27:31 +00:00
Rui Ueyama c008539736 Driver: move non-positional parameters out of switch. NFC.
llvm-svn: 228743
2015-02-10 20:57:43 +00:00
Rui Ueyama 4c30cb3d2f Use override rather than virtual.
llvm-svn: 228723
2015-02-10 18:59:37 +00:00
Rui Ueyama 375c5e2353 GNU: Use StringRef::empty instead of a boolean flag.
This local variable name did not follow the style guide,
and it is not actually needed.

llvm-svn: 228722
2015-02-10 18:55:39 +00:00
Rui Ueyama d003ab3207 Driver: use hasArg instead of getLastArg if return value is not used.
llvm-svn: 228717
2015-02-10 18:34:46 +00:00
Denis Protivensky e35908b18f [ELF][ARM] Add veneer generation to branch instructions
When calling ARM code from Thumb and vice versa,
a veneer that switches instruction set should be generated.
Added veneer generation for ARM_JUMP24 ARM_THM_JUMP24 instructions.

Differential Revision: http://reviews.llvm.org/D7502

llvm-svn: 228680
2015-02-10 09:31:42 +00:00
Rui Ueyama 7960d04f13 Driver: Replace switch cases with ifs.
We used to do like this instead of putting all command line processing
code within one gigantic switch statement. It is converted to a switch
in r188958, which introduced InputGraph.

In this patch I roll that change back. Now all "break"s are removed,
and the nesting is one level shallow.

llvm-svn: 228646
2015-02-10 01:10:23 +00:00
Rui Ueyama 55240af6a3 Remove trailing space.
llvm-svn: 228643
2015-02-10 01:06:14 +00:00
Davide Italiano 1fd20ff599 [ELF] Implement --strip-all/-s
Differential Revision:	D7489
Reviewed by:	shankarke

llvm-svn: 228533
2015-02-08 19:42:15 +00:00