Commit Graph

8908 Commits

Author SHA1 Message Date
Rafael Espindola eaf1d566ff Update for llvm change.
llvm-svn: 309913
2017-08-03 02:16:33 +00:00
Reid Kleckner 9dcd3e78ae [PDB] Improve rsds test to check that we fill in the file offset as well as the RVA
llvm-svn: 309902
2017-08-02 23:32:26 +00:00
Reid Kleckner 8d2cbf2e9b [PDB] Improve our PDB OMF debug directory entry
In order to get dbghelp to load our pdb, we have to fill in the
PointerToRawData field as well as the AddressOfRawData field. One is the
file offset and the other is the RVA.

llvm-svn: 309900
2017-08-02 23:19:54 +00:00
Rafael Espindola 3a8e4d98f8 Use more consistent names
Reviewing another change I noticed that we use "getSymbols" to mean
different things in different files. Depending on the file it can
return

ArrayRef<StringRef>
ArrayRef<SymbolBody*>
ArrayRef<Symbol*>
ArrayRef<Elf_Sym>

With this change it always returns an ArrayRef<SymbolBody*>. The other
functions are renamed getELFsyms() and getSymbolNames().

Note that we cannot return ArrayRef<Symbol*> instead of
ArreyRef<SymbolBody*> because local symbols have a SymbolBody but not
a Symbol.

llvm-svn: 309840
2017-08-02 17:35:18 +00:00
Petr Hosek edd6c3587c [ELF] When the code segment is the last, align it to the page boundary
When the data segment is the last segment, it is correct to leave
it unaligned. However, when the code segment is the last segment,
it should be aligned to the page boundary to avoid loading the
non-segment parts of the ELF file at the end of the file.

Differential Revision: https://reviews.llvm.org/D33630

llvm-svn: 309829
2017-08-02 16:35:00 +00:00
George Rimar b0d9fbeeeb [ELF] - Recommit r309252 "[ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all"
With fix for undefined weak symbols in executable.

Original commit message:
This is PR32112. Previously when we linked executable with 
--unresolved-symbols=ignore-all and undefined symbols, like:

_start:
callq und@PLT

we did not create relocations, though it looks in that case
we should delegate handling of such symbols to runtime linker,
hence should emit them. Patch fixes that.

Differential revision: https://reviews.llvm.org/D35724

llvm-svn: 309796
2017-08-02 07:51:08 +00:00
George Rimar 2d23da0033 [ELF] - Use multithreading for building .gdb_index.
Enables multithreaded .gdb_index building.

Differential revision: https://reviews.llvm.org/D36090

llvm-svn: 309688
2017-08-01 14:57:13 +00:00
Rui Ueyama be5f98fa33 Remove a redundant temporary variable.
llvm-svn: 309654
2017-08-01 04:18:57 +00:00
Rui Ueyama f974994e15 Binary search to find a relocation.
This change makes -gdb-index 40% faster. My test case is self-linking lld.

Differential Revision: https://reviews.llvm.org/D36079

llvm-svn: 309652
2017-08-01 04:11:03 +00:00
Zachary Turner 8d927b6bf9 [lld/pdb] Add an empty globals stream.
We don't write any actual symbols to this stream yet, but for
now we just create the stream and hook it up to the appropriate
places and give it a valid header.

Differential Revision: https://reviews.llvm.org/D35290

llvm-svn: 309608
2017-07-31 19:36:08 +00:00
Rafael Espindola aee5a8743e Never export weak undefined from executable.
Before we were doing it with --export-dynamic. That seems incorrect.
The intention of --export-dynamic is to export symbols *defined* in
the executable.

llvm-svn: 309605
2017-07-31 18:52:47 +00:00
Rafael Espindola d21ac10f6d Fix the order of section that are not on an order file.
They were being placed before sections that were listed.

llvm-svn: 309391
2017-07-28 15:36:15 +00:00
George Rimar 7b30dd1c53 [ELF] - Cleanup MapFile.cpp. NFC.
* Removed redundant templating.
* Added missing `static` keyword.

llvm-svn: 309376
2017-07-28 11:13:21 +00:00
George Rimar 60833f6e22 [ELF] - Do not crash when ALIGN/DATA_SEGMENT_ALIGN expression used with zero value.
Previously we would crash when tried to ALIGN(0).
Patch uses value 1 instead in this case, that
looks to be consistent with GNU linkers
and reasonable and simple behavior itself.

Differential revision: https://reviews.llvm.org/D35942

llvm-svn: 309372
2017-07-28 09:27:49 +00:00
Rafael Espindola 06ad7ed70c Add a test.
This would have found the error in r309252.

llvm-svn: 309329
2017-07-27 22:08:11 +00:00
Rafael Espindola a2df2f09f4 Avoid warnings when asserts are disabled.
llvm-svn: 309326
2017-07-27 21:42:42 +00:00
Rafael Espindola 8c022ca783 Merge OutputSectionCommand and OutputSection.
This is a bit of a hack, but it is *so* convenient.

Now that we create synthetic linker scripts when none is provided, we
always have to handle paired OutputSection and OutputsectionCommand and
keep a mapping from one to the other.

This patch simplifies things by merging them and creating what used to
be OutputSectionCommands really early.

llvm-svn: 309311
2017-07-27 19:22:43 +00:00
Reid Kleckner eacdf04fdd [PDB] Write public symbol records and the publics hash table
Summary:
MSVC link.exe records all external symbol names in the publics stream.
It provides similar functionality to an ELF .symtab.

Reviewers: zturner, ruiu

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D35871

llvm-svn: 309303
2017-07-27 18:25:59 +00:00
George Rimar 13f7dcdbc3 Revert r309252 "[ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all"
It broke bot:
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/4231

llvm-svn: 309258
2017-07-27 09:25:16 +00:00
George Rimar 8146773845 [ELD] - Sorted in ASCIIbetical order. NFC.
llvm-svn: 309254
2017-07-27 07:48:36 +00:00
George Rimar aa3541875e [ELF] - Store PhdrEntry values by pointers instead of storing by value.
That is slightly more convinent as allows to store pointer on
program header entry in a more safe way.
 
Change was used in 2 patches currently on review.

Differential revision: https://reviews.llvm.org/D35832

llvm-svn: 309253
2017-07-27 07:46:50 +00:00
George Rimar 678188d48b [ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all
This is PR32112. Previously when we linked executable with 
--unresolved-symbols=ignore-all and undefined symbols, like:

_start:
callq und@PLT

we did not create relocations, though it looks in that case
we should delegate handling of such symbols to runtime linker,
hence should emit them. Patch fixes that.

Differential revision: https://reviews.llvm.org/D35724

llvm-svn: 309252
2017-07-27 07:31:31 +00:00
Rui Ueyama acd632d338 Add {Obj,Import,Bitcode}File::Instances to COFF input files.
We did the same thing for ELF in r309152, and I want to maintain
COFF and ELF as close as possible.

llvm-svn: 309239
2017-07-27 00:45:26 +00:00
Rafael Espindola be28c2e4a5 Add --gc-sections to a test.
This shows that the logic in --gc-sections is a bit more precise than
what can be easily done in LTO.

llvm-svn: 309234
2017-07-26 23:47:24 +00:00
Rafael Espindola 4b075bb218 Make __start_sec __end_sec handling more precise.
With this we only ask LTO to keep a C named section if there is a
__start_ or __end symbol.

This is not as strict as lld's --gc-sections, but is as good as we can
get without having a far more detailed ir summary.

llvm-svn: 309232
2017-07-26 23:39:10 +00:00
Nico Weber 268f89d540 lld: /manifestuac:no shouldn't disable /manifestdependency:
Matches link.exe
https://reviews.llvm.org/D35872

llvm-svn: 309231
2017-07-26 23:38:10 +00:00
Rui Ueyama e1b48e099c Rename ObjectFile ObjFile for COFF as well.
llvm-svn: 309228
2017-07-26 23:05:24 +00:00
Rafael Espindola 6c4f5b41a3 Fix the name of the section end symbol.
It is __stop_<sec>, not __end_<sec>.

llvm-svn: 309225
2017-07-26 22:52:53 +00:00
Rui Ueyama 709fb2bb10 Rename ObjectFile -> ObjFile.
Rename it because it was too easy to conflict with llvm::object::ObjectFile
which broke buildbots several times.

llvm-svn: 309199
2017-07-26 22:13:32 +00:00
Meador Inge b0e6229742 [ELF, LinkerScript] Memory region name parsing fix
This patch fixes a small issue with respect to how memory region names
are parsed on output section descriptions.  For example, consider:

  .text : { *(.text) } > rom

That can also be written like:

  .text : { *(.text) } >rom

The latter form is accepted by GNU LD and is fairly common.

Differential Revision: https://reviews.llvm.org/D35920

llvm-svn: 309191
2017-07-26 21:51:09 +00:00
Rui Ueyama 3e96f1167c Attempt to fix buildbots.
llvm-svn: 309188
2017-07-26 21:37:11 +00:00
Rui Ueyama 23f64d229b Remove unnecessary namespace specifier.
I believe this compiles fine on all platforms, even on Windows.

llvm-svn: 309182
2017-07-26 21:24:01 +00:00
Martin Storsjo 38608c0975 [COFF, ARM64] Handle ADRP immediate offsets in relocations
Also handle overflow correctly in LDR/STR relocations. Even if the
offset range of a 8 byte LDR instruction is 15 bit (even if the immediate
itself is 12 bit) due to a 3 bit shift, only include up to 12 bits of offset
after doing the relocation, by limiting the range of the immediate by the
number of shifted bits.

Differential Revision: https://reviews.llvm.org/D35792

llvm-svn: 309175
2017-07-26 20:51:47 +00:00
Rafael Espindola aaa8e433ad Try to fix the windows build.
llvm-svn: 309162
2017-07-26 19:57:40 +00:00
Rafael Espindola b4b485370c Try to fix the windows build.
llvm-svn: 309161
2017-07-26 19:39:40 +00:00
Rafael Espindola bf991405de Try to fix the windows build.
llvm-svn: 309160
2017-07-26 19:37:58 +00:00
Rafael Espindola a5e8dd35b0 Simplify. NFC.
llvm-svn: 309153
2017-07-26 18:47:49 +00:00
Rafael Espindola 244ef98161 Detemplate SymbolTable.
NFC, just makes it easier to access from non templated code.

llvm-svn: 309152
2017-07-26 18:42:48 +00:00
George Rimar d5948f3a9a [ELF] - Ignore --warn-once option.
Was discussed in D35797 thread.

llvm-svn: 309096
2017-07-26 10:25:49 +00:00
George Rimar 84941ef158 [ELF] - Change way how we handle --noinhibit-exec
Previously we handled this option implicitly, only
for infering unresolved symbols handling policy.

ld man says: "--noinhibit-exec Retain the executable
output file whenever it is still usable",
and we may want to handle other cases too.

Differential revision: https://reviews.llvm.org/D35793

llvm-svn: 309091
2017-07-26 09:46:59 +00:00
George Rimar 6977ec6899 [ELF] - Print options aliases in --help
This is PR30422,
previously LLD did not render all option aliases in --help.
With this patch it will.

Differential revision: https://reviews.llvm.org/D35477

llvm-svn: 309089
2017-07-26 09:21:10 +00:00
Rui Ueyama 8109789a33 Simplify ignored options.
Since the flag is ignored anyway, it doesn't matter whether
it is an alias or not.

llvm-svn: 309055
2017-07-25 23:32:05 +00:00
Rafael Espindola cb83c8c85f Simplify. NFC.
llvm-svn: 309053
2017-07-25 23:23:40 +00:00
Rafael Espindola d4fbe4fe82 Reduce templating. NFC.
llvm-svn: 309051
2017-07-25 23:15:35 +00:00
Rafael Espindola affe7209c0 LTO: Handle sections with valid C names.
These can be referenced with __start_/__stop_ symbols. I will try to make
this more precise in a followup patch.

llvm-svn: 309048
2017-07-25 22:51:05 +00:00
Martin Storsjo 82eaf6cb50 [COFF] Add support for delay loading DLLs on ARM
Differential Revision: https://reviews.llvm.org/D35768

llvm-svn: 309017
2017-07-25 20:00:37 +00:00
Nico Weber 578363ac08 Attempt to fix lld tests on Windows after 308998.
The test used /manifestinput: without /manifest:embed, which isn't actually
supported.  Just remove this part of the test for now; if it's important to
check this the llvm-readobj part should be extended to check this.

llvm-svn: 309002
2017-07-25 18:39:38 +00:00
Nico Weber a7a2c44e70 lld: only write .manifest files if /manifest is passed, PR33925
Also emit an error if /manifestinput: is used without /manifest:embed.
Increases compatibility with link.exe

https://reviews.llvm.org/D35842

llvm-svn: 308998
2017-07-25 18:08:03 +00:00
George Rimar 4c351c6540 [ELF] - Fix init_fini_priority.s test.
Previously .init_array/.fini_array sections
were not unique and we had 3 .init_array sections +
3 .fini_array input sections passed to linker,
instead of 5 + 5.

Differential revision: https://reviews.llvm.org/D35552

llvm-svn: 308958
2017-07-25 09:26:35 +00:00
George Rimar f694d33f4c [ELF] - Fix calculation of memory region offset.
This is PR33714.

Previously for each input section offset of memory region
was incremented on a size of output section.

That resulted in a wrong error message saying about
overflow. Patch fixes that.

Differential revision: https://reviews.llvm.org/D35803

llvm-svn: 308955
2017-07-25 08:29:29 +00:00