Commit Graph

2556 Commits

Author SHA1 Message Date
Rui Ueyama 7960d04f13 Driver: Replace switch cases with ifs.
We used to do like this instead of putting all command line processing
code within one gigantic switch statement. It is converted to a switch
in r188958, which introduced InputGraph.

In this patch I roll that change back. Now all "break"s are removed,
and the nesting is one level shallow.

llvm-svn: 228646
2015-02-10 01:10:23 +00:00
Rui Ueyama 55240af6a3 Remove trailing space.
llvm-svn: 228643
2015-02-10 01:06:14 +00:00
Davide Italiano 1fd20ff599 [ELF] Implement --strip-all/-s
Differential Revision:	D7489
Reviewed by:	shankarke

llvm-svn: 228533
2015-02-08 19:42:15 +00:00
Rui Ueyama 669d9486f9 Remove unused parameter.
llvm-svn: 228476
2015-02-07 00:54:46 +00:00
Rui Ueyama f54e4fd3c6 PECOFF: Move error check for invalid command line combination to validateImpl.
llvm-svn: 228461
2015-02-06 23:09:13 +00:00
Rui Ueyama 92634be399 Use make_unique.
llvm-svn: 228453
2015-02-06 22:44:16 +00:00
Rui Ueyama a209f0d892 Remove unused #include.
llvm-svn: 228450
2015-02-06 22:34:29 +00:00
Rui Ueyama 3d68e41d2d ELF: Split OrderPass::compareInitFini for readability. NFC.
llvm-svn: 228449
2015-02-06 22:32:09 +00:00
Shankar Easwaran d050c50522 [Revert] [ELF] Determine default search directories from Context
It looks like the Driver manages search path for each Target lld would support
on the Gnu flavor.

llvm-svn: 228440
2015-02-06 21:23:50 +00:00
Shankar Easwaran 6aa03e230c Revert "[Core] Update ContentPermissions"
This reverts commit r228381.

The MachO writer uses the permissions as bit masks.

llvm-svn: 228401
2015-02-06 14:55:40 +00:00
Shankar Easwaran fa9eec2e6b [Core] Update ContentPermissions
The values are already arranged in ascending order, and all tests still pass.

Removing the values as its confusing when new enumerations need to be added.

llvm-svn: 228381
2015-02-06 05:29:49 +00:00
Shankar Easwaran c65bd69690 [ELF][TODO] Update TODO.
llvm-svn: 228380
2015-02-06 05:29:48 +00:00
Shankar Easwaran 2ba4f5d9e3 [Cleanup] Remove member functions added to support nostdlib
No change in functionality.

llvm-svn: 228379
2015-02-06 05:01:38 +00:00
Shankar Easwaran c8299e1f15 [ELF] Remove stray semicolon
llvm-svn: 228378
2015-02-06 04:50:22 +00:00
Shankar Easwaran 8825dbdd85 [ELF] Speedup creating program headers.
After the total number of program headers are determined, virtual addresses
and file offsets need not be reassigned for sections whose virtual addresses and
fileoffsets remained the same.

This doesnot change any functionality.

llvm-svn: 228377
2015-02-06 04:15:04 +00:00
Shankar Easwaran 8f1b2d0930 [Core] Remove roundTripPass() function.
Use the environment variable "LLD_RUN_ROUNDTRIP_TEST" in the test that you want
to disable, as

RUN: env LLD_RUN_ROUNDTRIP_TEST= <run>

This was a patch that I made, but I find this a better way to accomplish what we
want to do.

llvm-svn: 228376
2015-02-06 04:15:02 +00:00
Shankar Easwaran e315edd747 [ELF] Fix -nostdlib option.
Only search library directories explicitly specified
on the command line. Library directories specified in linker
scripts (including linker scripts specified on the command
line) are ignored.

llvm-svn: 228375
2015-02-06 04:15:00 +00:00
Rui Ueyama f038a52542 Add methods to get archive file name from member file.
Previously we only have File::path() to get the path name of a file.
If a file was a member of an archive file, path() returns a concatenated
string of the file name in the archive and the archive file name.
If we wanted to get a file name or an archive file name, we had to
parse that string. That's of course not good.

This patch adds new member functions, archivePath and memberPath, to File.

http://reviews.llvm.org/D7447

llvm-svn: 228352
2015-02-05 22:51:36 +00:00
Rui Ueyama 540842ccf5 Cleanup. NFC.
Make customOrder pareamter mandatory because the argument is
always passed.

llvm-svn: 228342
2015-02-05 20:08:04 +00:00
Rui Ueyama 0076215b88 MachO: Move LayoutPass to MachO directory.
The real user of the LayoutPass is now only Mach-O, so move that
pass out of the common directory to Mach-O directory.

"Core" architecture were using the LayoutPass. I modified that
to use a simple OrderPass. I think no one actually have authority
what feature should be in Core and what's not, but I believe the
LayoutPass is not very suitable for Core. Before more code starts
depending on the complex pass, it's better to remove that from
Core.

I could have simplified that pass because Mach-O is the only user
of the LayoutPass. For example, the second parameter of the
LayoutPass constructor can be converted from optional to mandatory.
I didn't do that in this patch to keep it simple. I'll do in a
followup patch.

http://reviews.llvm.org/D7311

llvm-svn: 228341
2015-02-05 20:05:33 +00:00
Rui Ueyama df7d133cdf PECOFF: Fix I386_DIR32 relocation to an absolute symbol
Previously, we incorrectly added the image base address to an absolute
symbol address (that calculation doesn't make any sense) if an
IMAGE_REL_I386_DIR32 relocation is applied to an absolute symbol.

This patch fixes the issue. With this fix, we can link Bochs using LLD.
(Choosing Bochs has no special meaining -- I just picked it up as a
test program and found it didn't work.) This also fixes one of the
issues we currently have to link Chromium using LLD.

llvm-svn: 228279
2015-02-05 07:22:53 +00:00
Shankar Easwaran d67bcb5f5c [ELF] Dont discard sections in the input file.
The reader was discarding certain types of sections from the input file.

llvm-svn: 228268
2015-02-05 02:56:06 +00:00
Shankar Easwaran 50ad727051 [ELF] Dont release ownership of MemoryBuffer.
MemoryBuffer is being released too early. ELFFile owns MemoryBuffer.

llvm-svn: 228260
2015-02-05 02:00:03 +00:00
Eric Christopher ddaf4fd680 lldReaderWriter.a depends on lldCore.a so make sure
to link that in as well.

llvm-svn: 228252
2015-02-05 01:10:40 +00:00
Eric Christopher 8e4f68b141 The PPC lld backend has been removed, don't require it here.
llvm-svn: 228251
2015-02-05 01:10:10 +00:00
Rui Ueyama e032d73ec5 Add a comment to Lexer::canContinueNumber.
llvm-svn: 228201
2015-02-04 21:46:27 +00:00
Rui Ueyama 7d8ffc9cfb Early return. NFC.
llvm-svn: 228106
2015-02-04 02:01:04 +00:00
Davide Italiano 40680078e7 Style cleanup in compareByPosition().
Differential Revision:	D7394
Reported by:	ruiu
Reviewed by:	ruiu

llvm-svn: 228094
2015-02-04 00:44:52 +00:00
Rui Ueyama cb6eb82e48 Simplify large switches.
This may be a little bit inefficient than the original code
but that should be okay as this is not really in a performance
critical pass.

http://reviews.llvm.org/D7393

llvm-svn: 228077
2015-02-04 00:00:21 +00:00
Davide Italiano 836a635764 Avoid two function calls of file() when not needed.
Reported by:	ruiu

llvm-svn: 228069
2015-02-03 23:44:33 +00:00
Rui Ueyama 2a96704b33 ELF: Support INPUT linker script directive
INPUT directive is a variant of GROUP in the sense that that specifies
a list of input files. The only difference is whether the entire file
list is wrapped with a --start-group/--end-group or not.

http://reviews.llvm.org/D7390

llvm-svn: 228060
2015-02-03 23:00:19 +00:00
Rafael Auler ee95c3b5c5 Make ELFLinkingContext own LinkerScript buffers
Currently, no one owns script::Parser buffers, but yet ELFLinkingContext gets
updated with StringRef pointers to data inside Parser buffers. Since this buffer
is locally owned inside GnuLdDriver::evalLinkerScript(), as soon as this
function finishes, all pointers in ELFLinkingContext that comes from linker
scripts get invalid. The problem is that we need someone to own linker scripts
data structures and, since ELFLinkingContext transports references to linker
scripts data, we can simply make it also own all linker scripts data.

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

llvm-svn: 227975
2015-02-03 16:08:57 +00:00
Denis Protivensky b635ae8388 [lld][ARM] Add relocations to perform function calls
Added relocations to perform function calls with and without passing arguments.
ARM-only, Thumb-only and mixed mode code generations are supported.
Only simple veneers (direct instruction modification) are supported as ARM-Thumb interwork.

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

llvm-svn: 227961
2015-02-03 10:48:37 +00:00
Rui Ueyama a6d38a326a ELF: Improve linker script unit tests.
This patch is to enable to write unit tests for linker script with
less boilerplate code.

llvm-svn: 227902
2015-02-03 00:42:36 +00:00
Davide Italiano 104949df73 [ELF] Implement action for OUTPUT linker script command
Reviewed by:	ruiu, shankarke

llvm-svn: 227787
2015-02-02 06:28:12 +00:00
Davide Italiano 5cbde851ed [ELF] Support for parsing OUTPUT command in LinkerScript
Differential Revision:	D7326
Reviewed by:	rafaelauler, shankarke, ruiu

llvm-svn: 227786
2015-02-02 06:21:23 +00:00
Shankar Easwaran 148cd8e8e9 [ELF] Determine default search directories from Context.
Target specific LinkingContext's  determine the default search directory.

No change in functionality.

llvm-svn: 227784
2015-02-02 06:00:04 +00:00
Shankar Easwaran d6f73ac366 [test] Add test for section groups and deadstrip
This adds a test that deadstrip should preserve the section group even if there
is only one reference to a function in the group.

llvm-svn: 227711
2015-02-01 05:47:02 +00:00
Davide Italiano df1b821b59 Remove trailing whitespace introduced in r227709.
Reported by:	shankarke

llvm-svn: 227710
2015-02-01 05:27:01 +00:00
Davide Italiano cd84ed35bd [ELF] Don't compare an atom with itself in compareByPosition().
This caused some tests to fail on FreeBSD, and Mac OS X.
Some std::sort() implementations will check for strict-weak-ordering
by comparing with the same element, or will compare an element to
itself for 1-element sequence. Take care of this case. Thanks to
chandlerc for explaning that to me.

Reviewed by:	ruiu

llvm-svn: 227709
2015-02-01 05:06:45 +00:00
Davide Italiano 1ecdf4ad30 [ELF] Implement semantic action for ENTRY linker script command.
Reviewed by:	shankarke, ruiu

llvm-svn: 227708
2015-02-01 03:27:25 +00:00
Shankar Easwaran 0f011fdcdf [ELF] Set order of ctors/dtors section
llvm-svn: 227707
2015-02-01 03:21:57 +00:00
Shankar Easwaran 0a13acfa8b [ELF] got/got.plt sections are handled as typeGOT
The .got and .got.plt sections are already handled as typeGOT. There is no need
to handle these atoms whose contentType is typeData.

llvm-svn: 227706
2015-02-01 03:21:55 +00:00
Rafael Auler 8251d741f4 Implement semantic action for SEARCH_DIR linker script command
This is needed, among others by the FreeBSD kernel linker script.

Patch by Davide Italiano!

Reviewers: ruiu, rafaelauler

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

llvm-svn: 227694
2015-01-31 22:42:19 +00:00
Rui Ueyama 0f1312fe26 Make atom collections private.
These fields were made protected in r193585. The aim of that change is to
expose these fields to SimpleFileWrapper. Because SimpleFileWrapper class
was removed in r227549, we can make them private.

llvm-svn: 227672
2015-01-31 04:19:57 +00:00
Rui Ueyama 14fc2cea42 Remove dead code.
llvm-svn: 227671
2015-01-31 04:19:55 +00:00
Rui Ueyama 33ab83bc4b ELF: Don't use LayoutPass.
Previously we applied the LayoutPass to order atoms and then
apply elf::ArrayOrderPass to sort them again. The first pass is
basically supposed to sort atoms in the normal fashion (which
is to sort symbols in the same order as the input files).
The second pass sorts atoms in {init,fini}_array.<priority> by
priority.

The problem is that the LayoutPass is overkill. It analyzes
references between atoms to make a decision how to sort them.
It's slow, hard to understand, and above all, it doesn't seem
that we need its feature for ELF in the first place.

This patch remove the LayoutPass from ELF pass list. Now all
reordering is done in elf::OrderPass. That pass sorts atoms by
{init,fini}_array, and if they are not in the special section,
they are ordered as the same order as they appear in the command
line. The new code is far easier to understand, faster, and
still able to create valid executables.

Unlike the previous layout pass, elf::OrderPass doesn't count
any attributes of an atom (e.g. permissions) except its
position. It's OK because the writer takes care of them if we
have to.

This patch changes the order of final output, although that's
benign. Tests are updated.

http://reviews.llvm.org/D7278

llvm-svn: 227666
2015-01-31 02:05:01 +00:00
Davide Italiano bf2625d42b GNU LD option export-dynamic can accept single dash flag.
Differential Revision:	D7044
Reviewed by:	ruiu

llvm-svn: 227631
2015-01-30 22:56:22 +00:00
Rui Ueyama a9a6f55840 ELF: Fix a bug in -l.
If a linker script is given with -l, LLD failed to read the file.
The bug was introduced in 227341.

llvm-svn: 227610
2015-01-30 21:03:19 +00:00
Rui Ueyama b9a53f05f1 Wrap debug output with DEBUG().
llvm-svn: 227590
2015-01-30 18:20:44 +00:00