Commit Graph

1760 Commits

Author SHA1 Message Date
Rui Ueyama 0e57b91f9c Use short identifier.
llvm-svn: 209497
2014-05-23 03:08:05 +00:00
Rui Ueyama f713cced0e [PECOFF] Make a separate pass for /alternatename symbols.
/alternatename is a command line option to define a weak alias. You
can use it as /alternatename:foo=bar to define "foo" as a weak alias
for "bar".

Because it's a command line option, the weak alias mapping is in the
LinkingContext object, and not in a object file being read.

Previously, we looked up the mapping each time we read a new symbol
from a file, to check if there is a weak alias defined for the symbol.
That's not wrong, but had made function signature's a bit complicated --
we had to pass the mapping object to many functions. Now their
parameter lists are much cleaner.

This also has another (unrealized) benefit. parseFile() now read a
file and then add alias symbols to the file. In the first pass a
LinkingContext object is not used at all. That should make it easy
to read files from archive files speculatively, as the first pass
is free from side effect.

llvm-svn: 209486
2014-05-23 00:02:42 +00:00
Rui Ueyama ba46cdb21f Move alias symbols from ELFLinkingContext to LinkingContext.
Alias symbols are SimpleDefinedAtoms and are platform neutral. They
don't have to belong ELF. This patch is to make it available to all
platforms. No functionality change intended.

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

llvm-svn: 209475
2014-05-22 21:37:56 +00:00
Nick Kledzik 8a0bc44b71 [mach-o] Fix so that mach-o semantic errors return an error rather than assert
llvm-svn: 209469
2014-05-22 20:05:43 +00:00
Nick Kledzik d48cb047e4 [mach-o] Remove MachOFormat.hpp, everything now uses llvm/Support/MachO.h
llvm-svn: 209385
2014-05-22 01:56:40 +00:00
Nick Kledzik e39685964b [mach-o] Use lit.local.cfg to enable mach-o test cases to be run
llvm-svn: 209383
2014-05-22 01:47:17 +00:00
Nick Kledzik a0c13a2420 [mach-o] parse literal sections into atoms
llvm-svn: 209379
2014-05-22 01:42:06 +00:00
Rui Ueyama 328da5527e Simplify nullptr check.
llvm-svn: 209357
2014-05-22 00:36:36 +00:00
Rui Ueyama 8f2394d456 Fix comment.
llvm-svn: 209334
2014-05-21 23:07:16 +00:00
Rui Ueyama 339d12ff12 [PECOFF] Fix unsafe memory access.
llvm-svn: 209323
2014-05-21 21:51:11 +00:00
Rui Ueyama 9f4674c828 [PECOFF] Check for a Characteristics field of a .debug section.
llvm-svn: 209317
2014-05-21 19:44:08 +00:00
Simon Atanasyan 37fe06711f [Mips] Simplify handling of R_MIPS_LO16 / R_MIPS_HI16 relocations
against _gp_disp symbol.

llvm-svn: 209315
2014-05-21 18:23:46 +00:00
Rafael Espindola 38eed1b86d Update for llvm's r209253.
llvm-svn: 209293
2014-05-21 13:07:41 +00:00
Rui Ueyama 85a0321b15 [PECOFF] Discard .debug sections.
llvm-svn: 209274
2014-05-21 05:56:31 +00:00
Rui Ueyama 5c35c8c9ab [PECOFF] Make COFFObjectReader thread-safe.
llvm-svn: 209271
2014-05-21 04:17:05 +00:00
Rui Ueyama 9b0a69d6dc [PECOFF] Acquire mutex before accessing shared objects.
addResolvableSymbols() queues input files, and readAllSymbols() reads
from them. In practice it's currently safe because they are called from
a single thread. But it's not guaranteed.

Also, acquiring the same mutex is needed not to see inconsistent memory
contents that is allowed in the C++ memory model.

llvm-svn: 209254
2014-05-20 23:05:09 +00:00
Rui Ueyama 1255496271 [PECOFF] Do not use anonymous namespace in a header.
llvm-svn: 209243
2014-05-20 21:58:34 +00:00
Alp Toker 2e62f7220f Fix typos
llvm-svn: 209213
2014-05-20 16:17:53 +00:00
Simon Atanasyan c2ec8c5281 [Mips] Show warning if the linker cannot find a pair for a R_MIPS_HI16
relocation. In fact this case violates ABI but sometimes compilers might
produce such code.

llvm-svn: 209153
2014-05-19 18:48:57 +00:00
Simon Atanasyan 9ab2cd0301 [Mips] Fix calculation of initial GOT entry value when this entry is
referenced by a local symbol.

llvm-svn: 209063
2014-05-17 04:58:26 +00:00
Nick Kledzik e09cfc5f8a [mach-o] Add support for zero-fill sections.
llvm-svn: 208928
2014-05-15 23:03:50 +00:00
Nick Kledzik 61fdef6086 [mach-o] Add support and test cases for parsing tentative definitions
llvm-svn: 208919
2014-05-15 20:59:23 +00:00
Rui Ueyama 5def41ee40 [PECOFF] Read files lazily.
ExportedSymbolRenameFile is not always used. In most cases we don't
need to read given files at all. So lazy load would help. This doesn't
change the meaining of the program.

llvm-svn: 208818
2014-05-14 22:35:47 +00:00
Rui Ueyama 50c337a47c Remove trailing whitespaces.
llvm-svn: 208815
2014-05-14 21:49:38 +00:00
Nick Kledzik dba52ad488 [mach-o] Add test case for parsing nlist -> Scope
llvm-svn: 208814
2014-05-14 21:37:14 +00:00
Nick Kledzik 0224e3475d Add -print_atoms options to DarwinLdDriver which dumps final state of all atoms in yaml
llvm-svn: 208813
2014-05-14 21:32:21 +00:00
Rui Ueyama 2a52251153 Fix regression introduced in r205566.
In r205566, I made a change to Resolver so that Resolver revisit
only archive files in --start-group and --end-group pair. That's
not correct, as it also has to revisit DSO files.

This patch is to fix the issue.

Added a test to demonstrate the fix. I confirmed that it succeeded
before r205566, failed after r205566, and is ok with this patch.

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

llvm-svn: 208797
2014-05-14 17:29:27 +00:00
Rui Ueyama b18489c8bf [PECOFF] Find symbols with @number suffix for dllexported symbols
As written in the comment in this patch, symbol names specified with
/export option is resolved in a special way; for /export:foo, linker
finds a foo@<number> symbol if such symbols exists.

On Windows, a function in stdcall calling convention is mangled with
a leading underscore and following "@" and numbers. This name
mangling is kind of automatic, so you can sometimes omit _ and @number
when specifying a symbol. /export option is that case.

Previously, if a file in an archive file foo.lib provides a symbol
_fn@8, and /export:fn is specified, LLD failed to resolve the symbol.
It only tried to find _fn, and failed to find _fn@8. With this patch,
_fn@8 will be searched on the second iteration.

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

llvm-svn: 208754
2014-05-14 06:29:32 +00:00
Rui Ueyama 551aacd6bc Add observers to Input Graph
Make it possible to add observers to an Input Graph, so that files
returned from an Input Graph can be examined before they are
passed to Resolver.

To implement some PE/COFF features we need to know all the symbols
that *can* be solved, including ones in archive files that are not
yet to be read.

Currently, Resolver only maintains a set of symbols that are
already read. It has no knowledge on symbols in skipped files in
an archive file.

There are many ways to implement that. I chose to apply the
observer pattern here because it seems most non-intrusive. We don't
want to mess up Resolver with architecture specific features.
Even in PE/COFF, the feature that needs this mechanism is minor.
So I chose not to modify Resolver, but add a hook to Input Graph.

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

llvm-svn: 208753
2014-05-14 05:31:54 +00:00
Simon Atanasyan 35687a2fd3 [ELF] Emit DT_TEXTREL dynamic table flag.
If one or more dynamic relocation might modify a read-only section,
dynamic table should contain DT_TEXTREL tag.

The patch introduces new `RelocationTable::canModifyReadonlySection()`
method. This method checks through the relocations to see if any modifies
a read-only section. The DynamicTable class calls this method and emits
the DT_TEXTREL tag if necessary.

The patch reviewed by Rui Ueyama and Shankar Easwaran.

llvm-svn: 208670
2014-05-13 07:37:09 +00:00
Rui Ueyama a131bdb77e Indent continuation lines
llvm-svn: 208630
2014-05-12 20:51:21 +00:00
Simon Atanasyan 20b043b24c [Mips] Update test case expectations to reflect changes in the
llvm-readobj output format.

llvm-svn: 208490
2014-05-11 08:54:30 +00:00
Rui Ueyama 629d201c97 [PECOFF] Resolve dllexported symbols.
We did not actively try to resolve dllexported symbols specified
by /export or by a module definition file. So if exported symbols
would be resolved for other reasons, like other symbols refer to
them, that was fine, but if (unreferenced) exported symbols were
in an archive file, and no one refers to that file in the archive,
they remained unresolved.

That would obviously cause the issue that dllexported symbols are
not in a resultant DLL.

In this patch, we create an undefined symbol for each dllexported
symbol, to let the core linker to resolve it.

llvm-svn: 208452
2014-05-09 22:19:49 +00:00
Rui Ueyama 457aa3bbdd [PECOFF] Fix dllexported name.
Previously the handling of exported symbol was wrong if it's
specified in a module definition file in the form of
<externalname>=<internalname>. Export the correct symbol.

llvm-svn: 208446
2014-05-09 21:37:43 +00:00
Rui Ueyama c7c47681f6 Revert "temporary commit."
This reverts accidental commit r208427.

llvm-svn: 208433
2014-05-09 16:47:20 +00:00
Rui Ueyama 1127fe4704 [PECOFF] DLL extension can be omitted in .def file.
llvm-svn: 208428
2014-05-09 16:35:26 +00:00
Rui Ueyama 4e0b17dd3c temporary commit.
llvm-svn: 208427
2014-05-09 16:35:23 +00:00
Rui Ueyama 89637c8098 [PECOFF] Split LocallyImportedSymbolFile into two classes.
I have a plan to use VirtualArchiveFile in this file in the near future.
This change should improve the readability by itself, too.

llvm-svn: 208365
2014-05-08 22:30:43 +00:00
Rui Ueyama b13cda8f3e Call normalize() in the common driver.
Previously only GNU driver calls InputGraph::normalize, but its
functionality is not and should not be limited to GNU ld. Other
driver should be able to use it.

Currently only linker scripts use the feature, so this change
won't change the existing behavior.

llvm-svn: 208266
2014-05-07 23:33:48 +00:00
Rui Ueyama 9967f49a3c Simplify InputGraph::getNextFile. No functionality change.
llvm-svn: 208256
2014-05-07 22:27:12 +00:00
Rui Ueyama d6a0604180 Trivial simplification
llvm-svn: 208145
2014-05-07 00:04:48 +00:00
Rui Ueyama 3608609339 Expand nested input elements.
Previously only the toplevel elements were expanded by expandElements().
Now we recursively call getReplacements() to expand input elements even
if they are in, say, in a group.

llvm-svn: 208144
2014-05-06 23:52:19 +00:00
Rui Ueyama 0d85dbfce0 Tests no longer uses getNextInputElement, so make it private.
llvm-svn: 208124
2014-05-06 19:32:54 +00:00
Rui Ueyama 2fa41d1817 Add a test for notifyProgress().
llvm-svn: 208123
2014-05-06 19:26:21 +00:00
Rui Ueyama aa30ccffa8 Remove unused variable.
llvm-svn: 208121
2014-05-06 19:11:39 +00:00
Rui Ueyama b51711b356 Fix copypaste error.
llvm-svn: 208120
2014-05-06 19:05:14 +00:00
Rui Ueyama b12dcb6095 s/My/Test/ as these classes are for tests.
llvm-svn: 208119
2014-05-06 19:01:56 +00:00
Rui Ueyama fd5c70d0ec Make the test even more readable.
llvm-svn: 208118
2014-05-06 18:58:24 +00:00
Rui Ueyama 48a1727e6f Simplify unit test code.
llvm-svn: 208116
2014-05-06 18:41:12 +00:00
Rui Ueyama d976941704 Remove meaningless return value in test.
llvm-svn: 208112
2014-05-06 18:27:37 +00:00