Commit Graph

5760 Commits

Author SHA1 Message Date
Rui Ueyama 3578d334fb Make test/ELF/reproduces.s test to work on Windows.
Previously, the test didn't work on Windows because it tried to
concatenate two (possibly) absolute paths. If two paths are absolute
paths that have drive letters, then the result would become something
like C:\foo\D:\bar. That's not a valid path. I changed the test to
use relative paths.

llvm-svn: 267588
2016-04-26 19:04:35 +00:00
Peter Collingbourne dbcf5b99d0 Remove unnecessary function type directives for ifuncs.
llvm-svn: 267569
2016-04-26 16:50:02 +00:00
Rafael Espindola 1b65ad1725 Don't gc symbols that have to go in the dynamic symbol table.
We were only doing it for .so and --export-dynamic, but those are not
the only ways a symbol ends up in the dynamic symbol table.

Problem diagnostic and earlier patch version by Peter Collingbourne.

llvm-svn: 267568
2016-04-26 16:26:45 +00:00
Peter Collingbourne 5dd550a3ff ELF: Treat IFunc definitions in DSOs as functions.
Differential Revision: http://reviews.llvm.org/D19517

llvm-svn: 267566
2016-04-26 16:22:51 +00:00
Davide Italiano 366290bb26 [ELF] Avoid polluting source directory with temp files.
llvm-svn: 267565
2016-04-26 16:21:59 +00:00
Rafael Espindola 0baa73f317 Handle --as-needed with symbols, not relocations.
This matches the behavior of both gold and bfd.

llvm-svn: 267558
2016-04-26 13:56:26 +00:00
Rafael Espindola 9e32e4fe86 Store the binding in the Symbol.
This remove a fixme, cleans up the weak undef interaction with archives and
lets us keep weak undefs still weak if they resolve to shared.

llvm-svn: 267555
2016-04-26 13:50:46 +00:00
Davide Italiano e53e6e9f37 [ELF] Simplify. Pointed out by Rui Ueyama.
llvm-svn: 267523
2016-04-26 05:51:37 +00:00
Davide Italiano 957d084811 [Tests] Run reproduces.s only on UNIX until I investigate a windows failure.
llvm-svn: 267505
2016-04-26 00:56:19 +00:00
Davide Italiano 034f58a9bd [ELF] Introduce --reproduce flag.
--reproduce dumps the object files in a directory chosen
(preserving the file system layout) and the linker invocation
so that people can create an archive and upload for debugging.

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

llvm-svn: 267497
2016-04-26 00:22:24 +00:00
Simon Atanasyan 1ef1bf87dc [ELF][MIPS] Move MIPS GOT header generation to the GotSection
MIPS is the only target requires GOT header. We already have MIPS
specific code in the `GotSection` class, so move MIPS GOT header
generation there and delete redundant stuff like `GotHeaderEntriesNum`
field and `writeGotHeader` method.

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

llvm-svn: 267460
2016-04-25 20:25:05 +00:00
Rafael Espindola 926bff8c3e Add support for R_X86_64_PC64.
llvm-svn: 267409
2016-04-25 14:05:44 +00:00
Rafael Espindola d79073dc2a Simplify. NFC.
llvm-svn: 267396
2016-04-25 12:32:19 +00:00
Rafael Espindola a6c4d2f197 Delete needsCopyRelImpl. It is redundant with getRelExpr.
llvm-svn: 267394
2016-04-25 12:05:56 +00:00
Simon Atanasyan c245d84213 [ELF] Delete extra line. NFC
llvm-svn: 267391
2016-04-25 10:18:48 +00:00
George Rimar ab9390664f [ELF] - Implemented comparsion operators for linkerscript.
Patch adds support of <,>,!=,==,>=,<= operators.

Differential revision: http://reviews.llvm.org/D19419

llvm-svn: 267382
2016-04-25 08:14:41 +00:00
George Rimar 1a4f89ab0a [ELF] - Removed dead declarations. NFC.
llvm-svn: 267381
2016-04-25 08:08:54 +00:00
Peter Collingbourne eb4d823184 Add a note to the test explaining why it doesn't match gold's behaviour.
llvm-svn: 267371
2016-04-25 00:19:47 +00:00
Davide Italiano bfccefd514 [ELF] Reinstate 'else' which was previously removed.
It turns out it's actually needed.

llvm-svn: 267358
2016-04-24 18:23:21 +00:00
Davide Italiano 7d32a4d27f [ELF] Simplify. Remove unneeded else. NFC.
llvm-svn: 267333
2016-04-24 07:19:32 +00:00
Simon Atanasyan 9cf3bf659c [ELF][MIPS] Add test case to check creation of GOT entries for weak symbols. NFC
llvm-svn: 267327
2016-04-24 05:08:43 +00:00
Peter Collingbourne dbe4187d11 ELF: Simplify preemption logic. Do not include weak undefined symbols in non-DSOs.
Add a test for -Bsymbolic + undefined symbols.

llvm-svn: 267323
2016-04-24 04:29:59 +00:00
Peter Collingbourne 7fa5970e69 Test what I intended to test.
llvm-svn: 267316
2016-04-24 02:42:34 +00:00
Peter Collingbourne 6d01a35ef6 ELF: Forbid undefined symbols with non-default visibility in DSOs.
llvm-svn: 267315
2016-04-24 02:31:04 +00:00
Peter Collingbourne d869a040ee ELF: Always include undefined DSO symbols in the symbol table.
Fixes check-llvm when bootstrapping.

Also remove mostly dead and most likely incorrect logic regarding preemption
of weak undefined symbols.

llvm-svn: 267314
2016-04-24 02:31:02 +00:00
Davide Italiano ae153ec4b4 [ELF] Use llvm-mc rather than checking in a file.
Now that the support for the 'new' relocations is available.

llvm-svn: 267310
2016-04-24 01:56:02 +00:00
Rui Ueyama 55274e3fcb Add a file comment about the Ulrich's document and don't repeat it in other comments.
llvm-svn: 267261
2016-04-23 01:10:15 +00:00
Rui Ueyama 209f6cb055 Add more comment.
llvm-svn: 267260
2016-04-23 01:10:13 +00:00
Rui Ueyama 4255475139 Add comments.
llvm-svn: 267259
2016-04-23 00:26:32 +00:00
Rui Ueyama 9c1112d09a Use ScriptParserBase features to parse linker script expressions.
Previously, we have re-implemented utility functions such as `expect`
or `next` in LinkerScript.cpp. This patch reuses the existing
implementation that is in ScriptParser.cpp.

llvm-svn: 267255
2016-04-23 00:04:03 +00:00
Rui Ueyama 4a46539c24 Devirtualize ScriptParserBase. NFC.
ScriptParserBase class is a container of collection of various methods
to parse linker script-ish text. It had a virtual method `run` to run
the parser. But we don't have to enforce its descendents to implement
that. It's up to them.

This patch removes pure virtual function `run`.

llvm-svn: 267246
2016-04-22 22:59:24 +00:00
Rui Ueyama e12fd0fc2c Fix link failure.
llvm-svn: 267245
2016-04-22 22:59:22 +00:00
Rafael Espindola 0b9531c8e6 Bring r267164 back with a fix.
The fix is to handle local symbols referring to SHF_MERGE sections.

Original message:

GC entries of SHF_MERGE sections.

It is a fairly direct extension of the gc algorithm. For merge sections
instead of remembering just a live bit, we remember which offsets
were used.

This reduces the .rodata sections in chromium from 9648861 to 9477472
bytes.

llvm-svn: 267233
2016-04-22 22:09:35 +00:00
Rui Ueyama 1e9e615f92 LTO: Merge -lto-no-discard-value-names with -save-temps.
This patch is to remove -lto-no-discard-value-names flag and
instead to use -save-temps as we discussed in the post-commit
review thread for r267020.

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

llvm-svn: 267230
2016-04-22 21:43:10 +00:00
Rui Ueyama b29465fe47 Remove unused #include.
llvm-svn: 267222
2016-04-22 21:17:55 +00:00
Rui Ueyama 412c802bda Move BitcodeCompiler constructor to the .cpp file. NFC.
llvm-svn: 267221
2016-04-22 21:16:18 +00:00
Rui Ueyama 5fa60985cf Inline getInteger as it's too short to be a function. NFC.
llvm-svn: 267219
2016-04-22 21:05:04 +00:00
Rui Ueyama e29a975d23 Update a comment for r267145.
llvm-svn: 267218
2016-04-22 21:02:27 +00:00
Rui Ueyama 0b3868ec6b Move uintX_t typedef to the class definition. NFC.
Now it is doable because LinkerScript is a template class.

llvm-svn: 267212
2016-04-22 20:41:07 +00:00
Peter Collingbourne 66ac1d6152 ELF: Implement basic support for --version-script.
This patch only implements support for version scripts of the form:
  { [ global: symbol1; symbol2; [...]; symbolN; ] local: *; };
No wildcards are supported, other than for the local entry. Symbol versioning
is also not supported.

It works by introducing a new Symbol flag which tracks whether a symbol
appears in the global section of a version script.

This patch also simplifies the logic in SymbolBody::isPreemptible(), and
teaches it to handle the case where symbols with default visibility in DSOs
do not appear in the dynamic symbol table because of a version script.

Fixes PR27482.

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

llvm-svn: 267208
2016-04-22 20:21:26 +00:00
Rafael Espindola e2eb5f837b Update test.
Sorry about the noise.

llvm-svn: 267207
2016-04-22 20:21:25 +00:00
Rafael Espindola 55a1d50b3a Add missing options that were required to crash.
llvm-svn: 267204
2016-04-22 20:07:59 +00:00
Rafael Espindola e7809c3a28 Add a reduction of the recent bootstrap failure.
llvm-svn: 267202
2016-04-22 20:05:16 +00:00
Rui Ueyama 630a382ba1 Reorganize LinkerDriver::link and add comments. NFC.
llvm-svn: 267201
2016-04-22 19:58:47 +00:00
Peter Collingbourne e8d466293a Update an out of date comment.
llvm-svn: 267200
2016-04-22 19:56:45 +00:00
Rui Ueyama 8bf71066c5 Inline SymbolTable::compareCommons and add comments. NFC.
llvm-svn: 267195
2016-04-22 19:34:59 +00:00
Rafael Espindola 46c039f2c0 Revert "GC entries of SHF_MERGE sections."
This reverts commit r267164.

    Revert "Trying to fix the windows build."

    This reverts commit r267168.

Debugging a bootstrap problem.

llvm-svn: 267194
2016-04-22 19:31:35 +00:00
Peter Collingbourne 3a35c4546d ELF: Scan for undefined symbols in shlibs and symbols in dynamic lists before LTO.
This ensures that these features work correctly with bitcode files.

llvm-svn: 267188
2016-04-22 18:47:52 +00:00
Peter Collingbourne 760e583e22 ELF: Implement --export-dynamic-symbol.
llvm-svn: 267184
2016-04-22 18:44:06 +00:00
Peter Collingbourne dadcc17ead ELF: Move Visibility, IsUsedInRegularObj and MustBeInDynSym flags to Symbol.
These are properties of a symbol name, rather than a particular instance
of a symbol in an object file. We can simplify the code by collecting these
properties in Symbol.

The MustBeInDynSym flag has been renamed ExportDynamic, as its semantics
have been changed to be the same as those of --dynamic-list and
--export-dynamic-symbol, which do not cause hidden symbols to be exported.

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

llvm-svn: 267183
2016-04-22 18:42:48 +00:00