Commit Graph

4004 Commits

Author SHA1 Message Date
Rafael Espindola 5a5fdf7f73 Fix typo.
Thanks to Sean Silva for noticing.

llvm-svn: 248488
2015-09-24 12:58:44 +00:00
Rafael Espindola cdfecffd80 Add support for relocating R_X86_64_GOTPCREL.
llvm-svn: 248425
2015-09-23 20:08:25 +00:00
Rafael Espindola c2d211994d Create the .bss section early so that we don't have to set it after the fact.
llvm-svn: 248412
2015-09-23 18:25:05 +00:00
Michael J. Spencer 2812aa82d0 [elf2] Pass BSSSec to the relocation handling code differently. Don't store it in the symbol.
llvm-svn: 248393
2015-09-23 16:57:31 +00:00
Davide Italiano aab93b59d4 [ELF2] - added ignored command line options for compatibility.
Patch by George Grimar.

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

llvm-svn: 248389
2015-09-23 15:46:44 +00:00
Rafael Espindola 6173f848b9 Print more information about undefined symbols.
llvm-svn: 248382
2015-09-23 14:37:01 +00:00
Rafael Espindola 8e5560d894 Don't complain about symbols showing up in multible shared libraries.
llvm-svn: 248381
2015-09-23 14:23:59 +00:00
Rafael Espindola 1a49e58181 Print more information about duplicated symbols.
llvm-svn: 248380
2015-09-23 14:10:24 +00:00
Davide Italiano a89d178a4f [ELF2] Add ASCII representation of the string table to test.
Requested by: rafael

llvm-svn: 248361
2015-09-23 01:56:26 +00:00
Davide Italiano e44456b1b9 [ELF2] Constify getStrTabSec().
llvm-svn: 248360
2015-09-23 01:50:53 +00:00
Rafael Espindola 1ab429bf49 Fix a last minuted edit that should not have been committed.
Sorry about that.

llvm-svn: 248349
2015-09-22 23:42:55 +00:00
Rafael Espindola 05a3dd2cba Implement --export-dynamic.
llvm-svn: 248347
2015-09-22 23:38:23 +00:00
Rafael Espindola 7f07442bb6 Move the last remaining hard coded relocations to Target.
Unfortunately the i386 and x86_64 relocation have the same numerical value
and it is a probably a bit much to add got support for another architecture
just to test this.

llvm-svn: 248326
2015-09-22 21:35:51 +00:00
Rafael Espindola 1d6063e804 Stub out ARM and PPC targets so that we can use a switch to create them.
llvm-svn: 248324
2015-09-22 21:24:52 +00:00
Rafael Espindola 3efa4e982e Add a token ppc64 reloc just to have a test showing that we handle BE.
llvm-svn: 248321
2015-09-22 21:12:55 +00:00
Rafael Espindola c40108858d Move relocation processing to Target.
I will add a couple of ppc64 relocs in the next patches.

llvm-svn: 248319
2015-09-22 20:54:08 +00:00
Rafael Espindola 8c21fad1e8 Fix a merge problem.
r248289 got lots when I moved code to Target.cpp. Sorry about that.

llvm-svn: 248317
2015-09-22 20:06:19 +00:00
Rafael Espindola 01205f79a4 Start adding target abstractions.
This is just enough to get PLT working on 32 bit x86.

The idea behind using a virtual interface is that it should be easy to
convert any of the functions to template parameters if any turns out to be
performance critical.

llvm-svn: 248308
2015-09-22 18:19:46 +00:00
Rafael Espindola 50534c2b6f Fix the creation of Elf_Rel sections.
We were always incrementing the output buffer pointer by sizeof(Elf_Rela).

llvm-svn: 248303
2015-09-22 17:49:38 +00:00
Davide Italiano 25423d42bd [MachO] Use llvm-readobj in lieu of macho-dump.
The latter will be removed from the tree anytime soon.

llvm-svn: 248300
2015-09-22 17:31:01 +00:00
Rafael Espindola 454ca1c245 Use a signed value for Delta.
This fixes got.s on 32 bit windows.

Patch by Igor Kudrin!

llvm-svn: 248289
2015-09-22 17:08:25 +00:00
Rafael Espindola 503fe9408d Expose ELFFileBase::getEMachine. NFC.
I will use it in a followup patch.

llvm-svn: 248287
2015-09-22 16:53:55 +00:00
Rafael Espindola a794fd44a1 Add support for R_386_PC32.
llvm-svn: 248275
2015-09-22 13:47:45 +00:00
Rafael Espindola 21585757e6 Handle implicit addends in Elf_Rel.
llvm-svn: 248272
2015-09-22 13:35:00 +00:00
Rafael Espindola ec50eebefd Remove unnecessary parenthesis.
llvm-svn: 248270
2015-09-22 13:30:26 +00:00
Denis Protivensky 67d01489b8 [ELF2] Fix gcc build
Remove explicit qualification in template instantiation.

llvm-svn: 248249
2015-09-22 08:14:46 +00:00
Rafael Espindola 7167585c94 Remove the Chunk terminology from ELF.
llvm-svn: 248229
2015-09-22 00:16:19 +00:00
Rafael Espindola 9d06ab6ded Rename Chunks.(h|cpp) to InputSection.(h|cpp). NFC.
llvm-svn: 248226
2015-09-22 00:01:39 +00:00
Rui Ueyama 9640173e16 COFF: Add /nosymtab command line option.
This is an LLD extension to MSVC link.exe command line. MSVC linker
does not write symbol tables for executables. We do unless no /debug
option is given.

There's a situation that we want to enable debug info but don't want
to emit the symbol table. One example is when we are comparing output
file size. With this patch, you can tell the linker to not create
a symbol table by just specifying /nosymtab.

llvm-svn: 248225
2015-09-21 23:43:31 +00:00
Rafael Espindola 56f965ff5c More MSVC fixes.
llvm-svn: 248223
2015-09-21 22:48:12 +00:00
Rafael Espindola f68b707251 Trying to fix the MSVC build.
llvm-svn: 248219
2015-09-21 22:21:46 +00:00
Rafael Espindola 327b8e19b1 Remove unused includes.
llvm-svn: 248218
2015-09-21 22:14:55 +00:00
Lang Hames c803442890 [LLD][MachO] Fix a FIXME: Subtract base address from atom address when building
export trie.

llvm-svn: 248217
2015-09-21 22:06:02 +00:00
Rafael Espindola 4ea00210f2 Make InputSection able to relocate itself.
This matches the organization used in COFF.

llvm-svn: 248215
2015-09-21 22:01:00 +00:00
Rafael Espindola 5805c4f509 Move OutputSectionBase and derived classes out of Writer.cpp.
The file was getting a bit too big and OutputSection is a central enough
concept in ELF linking to justify its own file.

llvm-svn: 248214
2015-09-21 21:38:08 +00:00
Rui Ueyama 97d92736f5 COFF: Improve section hash value.
std::distance(C->Relocs.end(), C->Relocs.begin()) is the same as NumRelocs
which is already added to the hash value. What we are missing here is the
section size.

llvm-svn: 248202
2015-09-21 19:41:38 +00:00
Rui Ueyama 3cb1f5c860 COFF: Rename A.replaceWith(B) -> B.replace(A). NFC.
llvm-svn: 248197
2015-09-21 19:36:51 +00:00
Davide Italiano 8ca741d51d [ELF2] Support relocs for local symbols
Differential Revision:	 http://reviews.llvm.org/D12978

llvm-svn: 248196
2015-09-21 19:30:11 +00:00
Rui Ueyama 98a98cffb6 COFF: Do not call std::async with std::launch::async if multithreading is disabled.
llvm-svn: 248193
2015-09-21 19:12:36 +00:00
Rafael Espindola 53d5cea648 Rename SectionChunk to InputSection.
This is more consistent with OutputSection. This is also part of removing
the "Chunk" term from the ELF linker, since we just have input/output sections
and program headers.

llvm-svn: 248183
2015-09-21 17:47:00 +00:00
Rafael Espindola eb79273158 Start adding support for PLT.
For now this doesn't support lazy symbol resolution, but is enough to link
and run a program with

jmp foo@PLT

llvm-svn: 248165
2015-09-21 15:11:29 +00:00
Davide Italiano 1ab83f8d8e [ELF2] Accept -X/-x as alias for -discard-locals/-discard-all.
llvm-svn: 248134
2015-09-20 23:35:56 +00:00
Davide Italiano 5445b2de50 [ELF2] Implement support for -discard-locals.
This is not on by default, but it may make sense to change it in future.

llvm-svn: 248133
2015-09-20 21:58:12 +00:00
Rui Ueyama 5f38915624 COFF: Fix ICF regression.
This patch fixes a regression introduced by r247964. Relocations that
are referring the same symbol should be considered equal, but they
were not if they were pointing to non-section chunks.

llvm-svn: 248132
2015-09-20 20:19:12 +00:00
Rui Ueyama 997b357ac1 COFF: Run InputFile::parse() in background using std::async().
Previously, InputFile::parse() was run in batch. We construct a list
of all input files and call parse() on each file using parallel_for_each.
That means we cannot start parsing files until we get a complete list
of input files, although InputFile::parse() is safe to call from anywhere.

This patch makes it asynchronous. As soon as we add a file to the symbol
table, we now start parsing the file using std::async().

This change shortens self-hosting time (650 ms) by 28 ms. It's about 4%
improvement.

llvm-svn: 248109
2015-09-20 03:11:16 +00:00
Rui Ueyama f49712a853 COFF: Fix race condition.
NextID is updated inside parallel_for_each, so it needs mutual exclusion.

llvm-svn: 248106
2015-09-20 01:44:44 +00:00
Rui Ueyama 3cfd2bff1e Remove dead code.
llvm-svn: 248105
2015-09-20 01:19:36 +00:00
Rui Ueyama 1cce300843 COFF: Change Symbol::Body type from atomic pointer to regular pointer.
I made the field an atomic pointer in hope that we would be able to
parallelize the symbol resolver soon, but that's not going to happen
soon. This patch reverts that change for the sake of readability.

llvm-svn: 248104
2015-09-20 00:00:05 +00:00
Rui Ueyama 63bbe84b27 COFF: Make Chunk::writeTo() const. NFC.
This should improve code readability especially because this function
is called inside parallel_for_each.

llvm-svn: 248103
2015-09-19 23:28:57 +00:00
Rui Ueyama ebb0ebff4b COFF: Fix thread-safety bug.
LTOModule doesn't seem to be thread-safe, so guard that with mutex.

llvm-svn: 248102
2015-09-19 23:14:51 +00:00