Commit Graph

156 Commits

Author SHA1 Message Date
Rui Ueyama b24241bae3 [PECOFF] Implement the reader for the import library.
This is the first patch toward full DLL support. With this patch, lld can
read .lib file for a DLL.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D987

llvm-svn: 184101
2013-06-17 18:43:13 +00:00
Shankar Easwaran f91031efcf [ELF] Add more sections to the default section map.
This change adds functionality to add more sections like .gcc_except_table,
.data.rel.local, .data.rel.ro into the default section map, so that they are
all merged into appropriate output sections.

This also makes c++ static binaries comparable to what you get with the default
linker.

Adds a test for testing the functionality.

llvm-svn: 184071
2013-06-17 02:29:36 +00:00
Rui Ueyama 8d10164326 [lld][PECOFF] Support IMAGE_REL_I386_DIR32 relocation.
With this patch, it can now resolve relocations in the same output file.
"Hello world" program does not still work because call to the DLL routine
is not supported yet.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D985

llvm-svn: 184063
2013-06-16 17:25:17 +00:00
Shankar Easwaran a97f12e00a [ELF] Add test so that _end value is set appropriately for NMAGIC/OMAGIC executables(Fix comment from espindola)
llvm-svn: 184060
2013-06-16 15:06:18 +00:00
Shankar Easwaran a42a473893 [ELF] add NMAGIC/OMAGIC support
llvm-svn: 184055
2013-06-16 05:06:28 +00:00
Rui Ueyama 3b0321c182 [PECOFF] Add a test for r184036.
llvm-svn: 184037
2013-06-15 05:20:05 +00:00
Rui Ueyama b95e833278 [PECOFF] Support .lib archive file.
Archive file in Windows has file extension of ".lib" but the file format is
in fact the same as Unix. It's an ar archive holding multiple .obj files.
The existing archive reader can read .lib files.

llvm-svn: 184036
2013-06-15 05:15:41 +00:00
Rui Ueyama 779a714766 [PECOFF] Handle scope of absolute atom correctly.
llvm-svn: 184035
2013-06-15 05:04:07 +00:00
Rui Ueyama ef2c5413a9 [lld][PECOFF] Read relocation entries.
Summary:
COFFReference class is defined to represent relocation information for
COFFDefinedAtom, as ELFReference for ELFDefinedAtom. ReaderCOFF can now
read relocation entries and create COFFReferences accordingly.

I need to make WriterPECOFF to handle the relocation references created by
the reader, but this patch is already big, so I think it's probably better
to get it reviewed now.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D976

llvm-svn: 183964
2013-06-14 02:30:34 +00:00
Rui Ueyama 2e3c4025ae [PECOFF] Rename basic.test -> trivial.test.
Because the test does not actually cover basic features.

llvm-svn: 183870
2013-06-12 22:19:05 +00:00
Rui Ueyama 0e17c37c57 [PECOFF] Test for r183705.
llvm-svn: 183853
2013-06-12 19:13:27 +00:00
Shankar Easwaran ec36f9a734 [test] fix test as the atom name is available only in DEBUG mode
llvm-svn: 183819
2013-06-12 00:46:37 +00:00
Shankar Easwaran 08470c4b6b [ELF][X86_64] Create GOT entries for external TLS symbols properly without Segfaults.
llvm-svn: 183817
2013-06-12 00:32:39 +00:00
Shankar Easwaran d5ff08ca5f [ELF] TBSS section has to be special cased so that it doesnot occupy memory space
llvm-svn: 183815
2013-06-12 00:32:32 +00:00
Rui Ueyama e3ee514aa7 [ELF] Refactor File.h.
- Split createAtom() in lib/ReaderWriter/ELF/File.h into small methods.
 - Added comments to code in other methods.

No functionality changes.

Reviewers: shankarke

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D921

llvm-svn: 183696
2013-06-10 21:32:44 +00:00
Rafael Espindola a0af48fc93 Fix handling of files without a symbol table.
This fixes a recent regression (r183338). Stripped elf files (like installed
crtn.o for example), are not required to have a symbol table. Handle that
correctly.

llvm-svn: 183573
2013-06-07 21:08:19 +00:00
Rui Ueyama a6b71cabb3 [LayoutPass] Add a method to check the followon graph structure.
Found that having a method to check the strucutre of the followon graph makes
it easy to debug file readers. The method checks if there's no wrong edge in
followOnNexts and followOnRoots. It is called only when debuggging is enabled
for LayoutPass.

Reviewers: shankarke

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D922

llvm-svn: 183553
2013-06-07 20:18:39 +00:00
Rui Ueyama 8d6151fd29 [PECOFF][Writer] Implement the writer that can emit text section.
lld can now output a valid Windows executable with a text section that does nothing
but just returns immediately. It's not able to handle relocations, symbol tables,
data sections, etc, so it still can't do anything practical, though.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D892

llvm-svn: 183478
2013-06-07 01:31:51 +00:00
Rafael Espindola e699c60021 Now that llvm-readobj is fixed, enable this test.
llvm-svn: 183285
2013-06-05 01:38:12 +00:00
Rui Ueyama 143672c7e5 [lld][ELF] Add parser for linker script ENTRY command
This is the parser for the ENTRY command. Note that because the parsing result
is currentlyd discarded, lld can parse but just ignore the command.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D833

llvm-svn: 183141
2013-06-03 18:05:21 +00:00
Shankar Easwaran a5008e3a63 [lld][elf] Add --dynamic-linker option to the ELF linker.
Users can override the default value of the dynamic linker to be set to the
one that appears in the command line. The path can even be empty!. 

Added a test for the option.

llvm-svn: 182889
2013-05-29 22:51:01 +00:00
Rui Ueyama 9e56839a83 [lld][PECOFF] Add WinLinkDriver and PECOFFTargetInfo.
Add WinLinkDriver and connect it to the existing COFF reader. Remaining
parts are still stubs, so while it can now read a COFF file, it still
cannot link or output PE/COFF files yet.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D865

llvm-svn: 182784
2013-05-28 18:13:31 +00:00
Shankar Easwaran d8da989e78 [lld][LayoutPass] An earlier commit moved the functionality so that Atoms would
be laid out by their ordinal overrides first, there was a bug that two atoms may 
get the same override index due to which atoms were not ordered properly. This
commit fixes the problem.

Now the atoms are ordered by 

- Section Position hints
- Atom override (Using layout-after/layout-before/in-group)
- Content Permissions
- Content Type
- File Ordinal

This also fixes the problem of running c++ static executables that 
was broken by an earlier patch.

llvm-svn: 182494
2013-05-22 17:41:04 +00:00
Rui Ueyama 0e171fe3c4 [lld] Update a test file for r180209.
This binary file is created from shared.c.

llvm-svn: 182410
2013-05-21 20:05:55 +00:00
Shankar Easwaran 9af77a2cab [lld][ELF][All Archs] Addend is used by dynamic relocations
only if they are relative. This removes the FIXME when the
relocations are being emitted and checks if the relocation
is relative and only then populates the addend information.

I couldnt add a testcase for this as llvm-readobj lacks     
functionality of printing dynamic relocations.              

When the functionality is added, remove the commented lines
from elf/ifunc.test to test functionality.

llvm-svn: 182077
2013-05-17 05:10:30 +00:00
Shankar Easwaran bd525a3f63 [lld][ELF] set ordinals for mergeAtoms and fix testcase
llvm-svn: 181622
2013-05-10 18:52:29 +00:00
Shankar Easwaran 3c5d2c8a24 [lld][LayoutPass] This commit fixes a problem in the
Layoutpass by ordering atoms if they appear in the override
list first and then looking at the way of ordering atoms in
the default way.

The fix also fixes issues with the sizes of the sections,
that appear in the output properly too.

The commit also adds a testcase(orderatoms-by-override.test)
to test it and fixes all the other relevant testcases.

llvm-svn: 181605
2013-05-10 16:44:02 +00:00
Rui Ueyama eb6b6e4857 [lld] Fix broken test. -layout-pass option does not exist.
Also shuffle the atoms so that it can verify the layout pass
actually changed the layout.

llvm-svn: 181573
2013-05-10 00:50:33 +00:00
Shankar Easwaran 6e1f5b7d1a [lld][ELF] reduce the number of symbols emitted in the symbol table
llvm-svn: 180872
2013-05-01 19:36:38 +00:00
Michael J. Spencer 9d70cef481 [Core] Allow weak symbols in shared library when linking.
Patch by Rui Ueyama.

llvm-svn: 180209
2013-04-24 19:00:26 +00:00
Nico Rieck bdfd4eb223 Replace elf-dump with llvm-readobj in lld tests
llvm-svn: 179364
2013-04-12 04:29:01 +00:00
Shankar Easwaran bba9fe8495 [test] missing underscore while checking for test output
llvm-svn: 179264
2013-04-11 04:20:21 +00:00
Shankar Easwaran 4cb24b38f6 [test] fix failing test, the test was not accounting for - in the path
llvm-svn: 179260
2013-04-11 04:08:11 +00:00
Shankar Easwaran eeee23e60a This adds functionality for undefined atoms from dynamic libraries to be added
to the list of undefined atoms. 

The processing of undefined atoms from dynamic libraries is controlled by
use-shlib-undefines command line option. 

This patch also adds additional command line arguments to allow/disallow
unresolved symbols from shared libraries and mimics GNU ld behavior.

llvm-svn: 179257
2013-04-11 02:56:30 +00:00
Shankar Easwaran f4a5e2f439 [ELF][test] add dynamic library search
llvm-svn: 178840
2013-04-05 04:34:57 +00:00
Shankar Easwaran 831b4a0503 [test] remove printing the file to stdout
llvm-svn: 178817
2013-04-04 23:53:46 +00:00
Nick Kledzik 563d9dc1b2 temp change to test case to debug buildbot failure
llvm-svn: 178788
2013-04-04 20:34:37 +00:00
Nick Kledzik 9a632dbe0c fix command line option to use -o
llvm-svn: 178777
2013-04-04 19:17:58 +00:00
Nick Kledzik c314b46e71 This is my Driver refactoring patch.
The major changes are:
1) LinkerOptions has been merged into TargetInfo
2) LinkerInvocation has been merged into Driver
3) Drivers no longer convert arguments into an intermediate (core) argument 
   list, but instead create a TargetInfo object and call setter methods on 
   it. This is only how in-process linking would work. That is, you can 
   programmatically set up a TargetInfo object which controls the linking.
4) Lots of tweaks to test suite to work with driver changes
5) Add the DarwinDriver
6) I heavily doxygen commented TargetInfo.h

Things to do after this patch is committed:
a) Consider renaming TargetInfo, given its new roll. 
b) Consider pulling the list of input files out of TargetInfo. This will 
   enable in-process clients to create one TargetInfo the re-use it with 
   different input file lists.
c) Work out a way for Drivers to format the warnings and error done in 
   core linking.

llvm-svn: 178776
2013-04-04 18:59:24 +00:00
Rafael Espindola 13de1566d0 Update the lld testsuite for the llvm-readobj format change.
llvm-svn: 178693
2013-04-03 20:53:45 +00:00
Shankar Easwaran 34353270a0 [ELF][Hexagon] fix few relocations and add test
llvm-svn: 178495
2013-04-01 20:20:11 +00:00
Shankar Easwaran 1d9e531856 [ELF][Hexagon] Create .got.plt entries with the appropriate alignment
llvm-svn: 178467
2013-04-01 15:14:34 +00:00
Shankar Easwaran cbe06ca340 [ELF] Set the symbol type for undefined atoms properly
llvm-svn: 178466
2013-04-01 15:12:54 +00:00
Shankar Easwaran bb9d4a5ca0 [ELF] Add dynamic hash table and get simple dynamic libraries working with Hexagon
llvm-svn: 178323
2013-03-29 00:53:25 +00:00
Shankar Easwaran 7404004a4c [ELF][Hexagon] Fixing failing test on Bots, few symbol names are available only in debug builds, dont check the symbol names
llvm-svn: 177991
2013-03-26 04:01:26 +00:00
Shankar Easwaran 499aa9e028 [ELF][Hexagon] add GOTREL/GOT relocations
llvm-svn: 177970
2013-03-26 02:20:56 +00:00
Shankar Easwaran 1af701ec6a [ELF] order rela.dyn/rela.plt properly
llvm-svn: 177969
2013-03-26 02:20:08 +00:00
Shankar Easwaran aec2165123 [ELF] fix dynamic symbol table entries and update tests
llvm-svn: 177875
2013-03-25 16:41:14 +00:00
Shankar Easwaran 71738cafe6 [ELF][Hexagon][test] check .got.plt order
llvm-svn: 177604
2013-03-20 23:39:43 +00:00
Shankar Easwaran 0fa1b3c86a [X86_64][test] check that interp section is not emitted when building dynamic libraries
llvm-svn: 177603
2013-03-20 23:34:36 +00:00