Commit Graph

3670 Commits

Author SHA1 Message Date
Rui Ueyama 685c41cd39 COFF: Simplify Writer interface by hiding Writer class.
llvm-svn: 244175
2015-08-05 23:43:53 +00:00
Rafael Espindola 1c2f64d1a6 Add a big endian testcase.
llvm-svn: 244173
2015-08-05 23:40:20 +00:00
Rui Ueyama afff74e228 ELF2: Simplify Writer interface.
We are using Writer more like a function instead of a class.
This patch makes it a function to simplify the interface.
All details of Writer class is now hidden from other parts of the linker.

llvm-svn: 244169
2015-08-05 23:24:46 +00:00
Rafael Espindola 4280a96468 Handle writeImportLibrary failing.
We were printing an error but exiting with 0.

Not sure how to test this. We could add a no-winlib feature,
but that is probably not worth it.

llvm-svn: 244109
2015-08-05 20:03:57 +00:00
Rafael Espindola ccd3adc60b lit fixes for lld.
It was not using LLVM_LIT_TOOLS_DIR and at least on my VM never finding lib.exe.

With this all the COFF tests show up as supported and pass.

llvm-svn: 244107
2015-08-05 19:55:17 +00:00
Rui Ueyama 67fcd1a0c7 COFF: Fix bad #includes.
Writer.h is intended to be included only by Writer.cpp and Driver.cpp.
Use of the header in other files are bad.

llvm-svn: 244106
2015-08-05 19:51:28 +00:00
Rui Ueyama ba7c041f21 COFF: ARM: Implepment BLX23T relocation and fix Branch20T.
I fed the same test to MSVC linker and got the same output,
so I believe this implementation is correct.

llvm-svn: 244102
2015-08-05 19:40:07 +00:00
Rafael Espindola 4b7c2fc64e Add bare minimum to get a working i386 linux program.
llvm-svn: 244050
2015-08-05 15:08:40 +00:00
Rafael Espindola e7a00e326a For now we only have on Chunk type. Simplify.
The others we have in sight are
* common symbols.
* entries in SHF_MERGE sections.

They will have a substantially different treatment. It is not clear if it is
worth it putting them all in a single list just to dispatch based on the kind on
the other side.

I hope to implement common symbols soon, and then we will be in a position
to have a concrete discussion. For now this is simpler for the the implemented
features.

llvm-svn: 244042
2015-08-05 13:55:34 +00:00
Rafael Espindola e3335d8a66 Delete dead code.
llvm-svn: 244040
2015-08-05 13:26:54 +00:00
Rafael Espindola d39c8cd087 Rename asm tests to .s. NFC.
llvm-svn: 244037
2015-08-05 12:14:51 +00:00
Rafael Espindola 3c9cb4b3d3 lld elf2: Diagnose trying to mix incompatible files.
This is also a step in instantiating the writer with the correct template
argument.

llvm-svn: 244035
2015-08-05 12:03:34 +00:00
Rafael Espindola 87ee8dcb64 Use ELFOSABI_NONE. This matches both bfd ld and gold.
llvm-svn: 244033
2015-08-05 11:55:52 +00:00
Rafael Espindola aefd5c1617 Create ObjectFile with the correct endian and word size.
The writer is still hard coded to 64 bits le, but with this we can test for
invalid ELF files.

llvm-svn: 243993
2015-08-04 15:45:54 +00:00
Rafael Espindola e0a5c09a5c Use make_unique. NFC.
llvm-svn: 243988
2015-08-04 15:06:36 +00:00
Rafael Espindola 2ffdd4d0e5 The SymbolTable doesn't need to be a template.
It was already using just code that is common to all object files.

llvm-svn: 243985
2015-08-04 14:29:01 +00:00
Rafael Espindola 602592a048 Remove a silly return.
llvm-svn: 243983
2015-08-04 14:08:11 +00:00
Rafael Espindola 30318518a5 This function never returns null, don't check it.
llvm-svn: 243982
2015-08-04 14:00:56 +00:00
Rafael Espindola b89951457d Remove SymbolTable::getChunks.
When we were using a std::sort over all the chunks we needed to put them in a
single storage.

Now that we just iterate over them and use a map to find the output section,
we can avoid allocating the temporary storage.

llvm-svn: 243980
2015-08-04 13:39:30 +00:00
Simon Atanasyan 7a400d9af4 [Mips] Implement definition of the DT_MIPS_RLD_MAP_REL dynamic tag
llvm-svn: 243835
2015-08-01 14:53:49 +00:00
Rui Ueyama 18edc83b6c COFF: Fix error message. Space was missing.
llvm-svn: 243794
2015-07-31 21:51:25 +00:00
David Majnemer bf1e5c0ee9 COFF: Reenable the lld test disabled in r243758.
llvm-svn: 243762
2015-07-31 17:41:11 +00:00
Reid Kleckner 60dde1fbda Disable objdump disassembly test after r243755
Right now PE image section addresses are RVAs and symbol addresses are
VAs.  We should probably fix this by changing section addresses to match
symbol addresses. Fixing this might take a few hours, so temporarily
disable the objdump part of this test.

llvm-svn: 243758
2015-07-31 16:41:23 +00:00
Reid Kleckner 981576daf7 Add some help strings for /dll and /debug so they show up in /?
llvm-svn: 243757
2015-07-31 16:40:38 +00:00
Peter Collingbourne e7107ec03b COFF: When resolving _load_config_used, add it as a GC root.
This fixes the cases where the symbol is defined in a comdat or by bitcode.

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

llvm-svn: 243735
2015-07-31 05:33:34 +00:00
Rui Ueyama 7b276e2fb4 COFF: Move code for Identical COMDAT Folding to ICF.cpp.
llvm-svn: 243701
2015-07-30 22:57:21 +00:00
Rui Ueyama f69ecc1212 COFF: Handle all COMDAT sections as non-GC root.
I don't remember why I thought that only functions are subject
of garbage collection, but the comment here said so, which is
not correct. Moreover, the code just below the comment does not
do what the comment says -- it handles non-COMDAT, non-function
sections as GC root. As a result, it just handles non-COMDAT
sections as GC root.

This patch cleans that up by removing SectionChunk::isRoot and
use isCOMDAT instead.

llvm-svn: 243700
2015-07-30 22:48:45 +00:00
Rui Ueyama 7ed10b84cc Remove trailing whitespace.
llvm-svn: 243683
2015-07-30 20:47:17 +00:00
David Majnemer 13ac40ea6e COFF: Sort output sections which start with .debug to the end of the file
We want to convince the NT loader not to map these sections into memory.
A good first step is to move them to the end of the executable.

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

llvm-svn: 243680
2015-07-30 20:26:55 +00:00
Simon Atanasyan 98a857140b [Mips] Implement definition of DT_MIPS_RLD_MAP dynamic tag, .rld_map section, and __RLD_MAP symbol
llvm-svn: 243626
2015-07-30 07:45:55 +00:00
Rui Ueyama e0d68e381b Remove unused #includes.
llvm-svn: 243588
2015-07-29 22:53:29 +00:00
Rui Ueyama 966acb2e2f COFF: Suppress "Duplicate entry" warning of lib.exe
We create a module-definition file and give that to lib.exe to
create an import library file. A module-definition has to be
syntactically and semantically correct, of course.

There was a case that we created a module-definition file that
lib.exe would complain for duplicate entries. If a user gives
an unmangled and mangled name for the same symbol, we would end
up having two duplicate lines for the mangled name in a module-
definition file.

This patch fixes that issue by uniquefying entries by mangled
symbol name.

llvm-svn: 243587
2015-07-29 22:38:27 +00:00
Michael J. Spencer 44fc1c0a73 [ELF2] Templatize addChunk and handle section flags.
llvm-svn: 243579
2015-07-29 22:14:50 +00:00
Rui Ueyama 4323831732 COFF: Fix command line option spelling.
llvm-svn: 243573
2015-07-29 21:01:15 +00:00
Rui Ueyama 1e4dd36824 Remove astyle-options.
We have our own code formatting tool, clang-format.
I believe no one is using "astyle" to format the code.

llvm-svn: 243570
2015-07-29 20:48:02 +00:00
Rui Ueyama 46682630f4 COFF: Ignore /ThrowNew command line option.
This command line option is added since MSVC 2015. Our wild guess is
that the flag is for LTCG and we can safely ignore that.

llvm-svn: 243568
2015-07-29 20:29:15 +00:00
Rui Ueyama ff88d5a26f COFF: Add /safeseh command line option.
If /safeseh is specified, all input files must be compatible with Safe SEH.

llvm-svn: 243565
2015-07-29 20:25:40 +00:00
Rui Ueyama 8bc43a142b COFF: ARM: Fix relocations to thumb code.
Windows ARM is the thumb ARM environment, and pointers to thumb code
needs to have its LSB set. When we apply relocations, we need to
adjust the LSB if it points to an executable section.

llvm-svn: 243560
2015-07-29 19:25:00 +00:00
Rui Ueyama 56965f4b32 COFF: ARM: Fix DLL import table.
The previous test was testing -flavor link. This patch correctly
tests link2 and fixes a bug that we didn't emit import thunks.

llvm-svn: 243559
2015-07-29 19:24:58 +00:00
Rui Ueyama 308915ade2 COFF: Fix seh.test.
seh.test was testing -flavor link. This should have been testing
-flavor link2.

llvm-svn: 243557
2015-07-29 19:17:15 +00:00
Rui Ueyama eb26e1d03c COFF: Fix SECREL and SECTION relocations.
SECREL should sets the 32-bit offset of the target from the beginning
of *target's* output section. Previously, the offset from the beginning
of source's output section was used instead.

SECTION means the target section's index, and not the source section's
index. This patch fixes that issue too.

llvm-svn: 243535
2015-07-29 16:30:45 +00:00
Rui Ueyama b4731a5847 ELF2: Use DenseMap instead of std::map for a symbol table.
We use DenseMap for COFF too.

llvm-svn: 243534
2015-07-29 16:30:40 +00:00
Rui Ueyama ca577fd536 COFF: Remove unused command line option.
llvm-svn: 243533
2015-07-29 16:30:34 +00:00
Rui Ueyama 29f74c312a COFF: Set load config table entry on non-x86.
llvm-svn: 243532
2015-07-29 16:30:31 +00:00
Michael J. Spencer 5a6f5f178e [ELF2] Emit correct section types.
llvm-svn: 243509
2015-07-29 00:52:17 +00:00
Michael J. Spencer 8039dae26d [ELF2] Emit section table.
llvm-svn: 243506
2015-07-29 00:30:10 +00:00
Michael J. Spencer cdae0a4e2d [ELF2] Devirtualize SymbolBody.
llvm-svn: 243496
2015-07-28 22:58:25 +00:00
Rui Ueyama 506f6d1ae1 COFF: _tls_used is __tls_used on x86.
llvm-svn: 243495
2015-07-28 22:56:02 +00:00
Rui Ueyama 9420dee328 COFF: Fix export symbol names for x86.
I don't fully understand the rationale behind the name mangling
scheme used for the DLL export table and the import library.
Why only leading "_" is dropped for the import library while
both "_" and "@" are dropped from DLL symbol table? But this seems
to be what MSVC linker does.

llvm-svn: 243490
2015-07-28 22:34:24 +00:00
Rui Ueyama 635e85a647 COFF: Update README to mention that it now supports 32-bit x86.
The linker is now able to link not only LLVM/Clang/LLD for x86 but
even larger programs. I confirmed that it successsfully linked Chrome
for x86. Because the browser is a pretty large program, I think I can
say that the linker is now mostly feature complete. (I'm pretty sure
that there are hidden bugs somewhere, but they shouldn't be significant.)

llvm-svn: 243377
2015-07-28 03:40:58 +00:00