Commit Graph

4603 Commits

Author SHA1 Message Date
Davide Italiano 9b71ef92e7 [ELF2/AArch64] Add relocation tests to ensure we handle overflow correctly.
llvm-svn: 251646
2015-10-29 20:02:27 +00:00
Davide Italiano 3300b798ca [ELF2/AArch64] Implement R_AARCH64_PREL16 and R_AARCH64_PREL32 relocations.
llvm-svn: 251645
2015-10-29 19:55:59 +00:00
George Rimar 8b8222b04c [ELF2] merge-string.s test fixed for win32 configuration.
Differential revision: http://reviews.llvm.org/D14171

llvm-svn: 251644
2015-10-29 19:30:28 +00:00
Lang Hames 2ed3bf9527 [lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.
llvm-svn: 251637
2015-10-29 16:50:26 +00:00
Lang Hames ac416d42fc [lld][MachO] Use a std::string rather than a StringRef for the section name in
MachODefinedCustomSectionAtom.

The section names for these atoms are initialized from temporaries (e.g.
segName + "/" + sectName), so we can't use StringRef here.

llvm-svn: 251610
2015-10-29 03:57:31 +00:00
George Rimar 5268721e59 Reapply r251536
llvm-svn: 251541
2015-10-28 18:33:08 +00:00
George Rimar 9413fa26af Revert r251536 as it broke buildbot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/2104
llvm-svn: 251539
2015-10-28 18:16:24 +00:00
George Rimar 06f4e43d29 [ELF2] R_X86_64_64 plt relocation implemented.
This little patch is a final point in fix for https://llvm.org/bugs/show_bug.cgi?id=25175.

It`s make sample from issue description to work with -O0 optimization flag (with -O0 it generates R_X86_64_64 plt relocation).

Differential revision: http://reviews.llvm.org/D14153

llvm-svn: 251536
2015-10-28 17:59:44 +00:00
George Rimar bc590feb2b [ELF2] R_X86_64_COPY relocation implemented
Differential revision: http://reviews.llvm.org/D14090.

llvm-svn: 251526
2015-10-28 16:48:58 +00:00
Davide Italiano b12d668e3d [ELF2/AArch64] Add support for R_AARCH64_PREL64.
llvm-svn: 251523
2015-10-28 16:14:18 +00:00
Simon Atanasyan 069b2dd66c [Driver] Ignore -G option in both new and old ELF linker
This is optimization option that make sense for MIPS targets. We can
safely ignore it now.

llvm-svn: 251519
2015-10-28 14:50:58 +00:00
Igor Kudrin f1d6029016 [ELF2] Move sorting and data to the GNU hash table section.
It is the GNU hash table section that should be reaponsible for storing its own
data and applying its requirements for the order to dynamic symbols.

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

llvm-svn: 251502
2015-10-28 07:05:56 +00:00
Simon Atanasyan 07fe7a943f [Driver] Accept both -m <emulation> and -m<emulation>
GNU linkers accept both variants and at least for MIPS target gcc passes
joined variant of the '-m' option.

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

llvm-svn: 251497
2015-10-28 05:13:12 +00:00
Rui Ueyama 12504649dc ELF2: Move some code from MarkLive.cpp to InputSection.cpp.
This function is useful for ICF, so move that to a common place.

llvm-svn: 251455
2015-10-27 21:51:13 +00:00
Michael J. Spencer 4633a373e0 [elf2] Don't allocate VA space for TLS NOBITS sections.
Differential Revision: http://reviews.llvm.org/D13838

llvm-svn: 251454
2015-10-27 21:22:54 +00:00
Rui Ueyama 305a7d3f44 ELF2: Make parseEmulation side-effect free. NFC.
llvm-svn: 251440
2015-10-27 19:29:27 +00:00
Davide Italiano ce0d48adbb [ELF2/Driver] Accept both -L <arg> and -L<arg>.
This matches ld.bfd and ld.gold behavior. The change is simple enough
and avoid trouble to consumers (they don't have to change their Makefiles).
Side note: found while trying to build FreeBSD base system with lld.

llvm-svn: 251408
2015-10-27 15:10:53 +00:00
Rui Ueyama 0b2b964797 ELF2: Ignore -( and -).
They are aliases to --start-group and --end-group, respectively.

llvm-svn: 251332
2015-10-26 19:05:44 +00:00
Rui Ueyama df985afa14 COFF: De-parallelize ICF for now.
There was a threading issue in the ICF code for COFF. That seems like
a venign bug in the sense that it doesn't produce an incorrect output,
but it oftentimes misses reducible sections. As a result, mergeable
sections could remain in outputs, which makes the output nondeterministic.

Basically the algorithm we are using for ICF is this: We group sections
so that identical sections will eventually be in the same group. Initially,
all sections are in one group. We split the group by relocation targets
until we get a convergence (if relocation targets are in different gruops,
the sections are different). Once a group is split, they will never be
merged.

Each section has a group ID. That variable itself is atomic, so there's
no threading issue at the level that we can use thread sanitizer.
The point is, when we split a group, we re-assign new group IDs to group
of sections. That are multiple separate writes to atomic varaibles.
Thus, splitting a group is not an atomic operation, and there's a small
chance that the other thread observes inconsistent group IDs.

Over-splitting is always "safe", so it will never create incorrect output.

I suspect that the nondeterminism stems from that point. However, I
cannot prove or fix that at this moment, so I'm going to avoid using
threads here.

llvm-svn: 251300
2015-10-26 16:20:00 +00:00
George Rimar f940d5918f Another fix of -Wqual-const warning.
llvm-svn: 251259
2015-10-25 20:14:07 +00:00
Ed Maste add8ee31a4 Correct relocation type in test header comment
llvm-svn: 251242
2015-10-25 16:30:05 +00:00
Rui Ueyama 7ba639bdd6 Fix -Wqual-const warning.
llvm-svn: 251241
2015-10-25 16:25:04 +00:00
Rafael Espindola f82ed2a28c Add support for merging string from SHF_STRINGS sections.
llvm-svn: 251212
2015-10-24 22:51:01 +00:00
Rui Ueyama 9eb7ed0423 ELF2: Move Writer class to the top of the file. NFC.
llvm-svn: 251195
2015-10-24 18:22:59 +00:00
Rui Ueyama 6621d8ed7c ELF2: Add comments and simplify. NFC.
llvm-svn: 251194
2015-10-24 17:57:40 +00:00
Rui Ueyama 157c433a83 ELF2: Remove setNameOffset and combine that with writeHeader. NFC.
llvm-svn: 251193
2015-10-24 17:57:39 +00:00
Rui Ueyama 9fbb3d8850 ELF2: Rename StringTableSection::getFileOff -> getOffset.
getFileOff functions defined for other classes return an offset
from beginning of the file. StringTableSection's getFileOff however
returned an offset from beginning of the section. That was confusing.

llvm-svn: 251192
2015-10-24 17:44:52 +00:00
George Rimar 5dad7c1d4c Reapply r251144: fixed test.
llvm-svn: 251184
2015-10-24 08:52:46 +00:00
Lang Hames b1b67f4daf [lld][Darwin] Add support for the -sectcreate option.
llvm-svn: 251183
2015-10-24 08:20:51 +00:00
Rui Ueyama c27d2f266e ELF2: Remove FIXMEs which we are not sure if we have to fix.
llvm-svn: 251173
2015-10-24 01:46:40 +00:00
Rui Ueyama e08cd678de ELF2: Simplify file magic setter.
llvm-svn: 251159
2015-10-23 22:44:39 +00:00
Rui Ueyama bcb2d0f94b ELF2: Factor out getEntryAddr from writeHeader. NFC.
llvm-svn: 251158
2015-10-23 22:44:37 +00:00
Rui Ueyama c611d97006 ELF2: Use character literals for ELF file magic.
This is consitent with Support/ELF.h and more obvious than before.

llvm-svn: 251155
2015-10-23 22:31:47 +00:00
Rafael Espindola 6779a23626 Update for llvm api change.
llvm-svn: 251154
2015-10-23 21:48:35 +00:00
Rui Ueyama 803195ed6d ELF2: Simplify Writer::assignAddresses. NFC.
This patch is an attempt to simplify assignAddresses function by splitting
it and using less variables. I tried to split the code to create PHDRs from
the code to assign addresses, but it didn't make this code simpler, so I
didn't do that in this patch.

llvm-svn: 251152
2015-10-23 21:45:59 +00:00
Rui Ueyama b621d1ae58 Revert "[ELF2] --strip-all/-s command line implemented"
This reverts commit r251144 because the new test is failing.

llvm-svn: 251148
2015-10-23 21:08:41 +00:00
George Rimar 236bf3bfe4 [ELF2] --strip-all/-s command line implemented
-s, --strip-all - Strip all symbols
Implementation removes .strtab and .symtab sections from output.

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

llvm-svn: 251144
2015-10-23 20:24:44 +00:00
Rafael Espindola 48225b4433 Drop a few const to reduce the noise from the next patch. NFC.
llvm-svn: 251140
2015-10-23 19:55:11 +00:00
Rafael Espindola 2c1217d82a Parse and store the value of the -O option.
llvm-svn: 251136
2015-10-23 19:02:19 +00:00
Rui Ueyama c44e5a15ce ELF2: Do not apply 0xffff bit mask to uint16_t return values. NFC.
llvm-svn: 251118
2015-10-23 16:54:58 +00:00
Rui Ueyama 3835b490da Style fix.
llvm-svn: 251114
2015-10-23 16:13:27 +00:00
Lang Hames 5e7cfe4e2b [lld][MachO] Prune unused EH frames.
llvm-svn: 251095
2015-10-23 05:39:16 +00:00
Rui Ueyama 96f0e0bfc9 ELF2: Improve Target::relocateOne().
relocateOne is a function to apply a relocation. Previously, that
function took a pointer to Elf_Rel or Elf_Rela in addition to other
information that can be derived from the relocation entry. This patch
simplifies the parameter list. The new parameters, P or SA, are used
in the ELF spec to describe each relocation. These names make
relocateOne look like a mechanical, direct translation of the ELF spec.

llvm-svn: 251090
2015-10-23 02:40:46 +00:00
Rui Ueyama 2beabc9be5 ELF2: SymbolBody::repl() never returns a nullptr.
So we can use dyn_cast instead of dyn_cast_or_null here.

llvm-svn: 251076
2015-10-22 23:10:25 +00:00
Rui Ueyama 8a598f89ad ELF2: Keep .eh_frame even if they are not live.
.eh_frame sections need to be preserved if they refer to live sections.
So the liveness relation is reverse for eh_frame sections. For now,
we simply preserve all .eh_frame sections. Thanks Rafael for pointing
this out. .jcr are kept for the same reason.

llvm-svn: 251068
2015-10-22 21:42:05 +00:00
Rui Ueyama c4aaed9255 ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.

In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.

This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.

It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.

http://reviews.llvm.org/D13950

llvm-svn: 251043
2015-10-22 18:49:53 +00:00
Igor Kudrin 0cb1561e42 Fix the buildbot.
test/elf2/gnu-hash-table.s requires ppc target support to run.

llvm-svn: 251002
2015-10-22 08:58:03 +00:00
Igor Kudrin 1b0d7066ff [ELF2] Add support for GNU Hash section
This patch implements --hash-style command line switch.

* By default, or with "sysv" or "both" parameters, the linker generates
  a standard ELF hash section.
* With "gnu" or "both", it produces a GNU-style hash section.

That section requires the symbols in the dynamic symbol table section, which
are referenced in the GNU hash section, to be placed after not hashed ones and
to be sorted to correspond the order of hash buckets in the GNU Hash section.

The division function, as well as estimations for the section's parameters,
are just the first rough attempt and the subjects for further adjustments.

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

llvm-svn: 251000
2015-10-22 08:21:35 +00:00
Rui Ueyama 9cfc8e08a8 ELF2: Remove FIXMEs.
These classes are partially written, so almost all features
are FIXMEs. We do not want to add new FIXMEs to the classes
when we add new features to other non-stub classes.

llvm-svn: 250947
2015-10-21 21:13:35 +00:00
Rui Ueyama 86696f38ea ELF2: Avoid bitwise-OR hack. NFC.
The previous code is too clever that that needs a bit more
brain power than this new code.

llvm-svn: 250934
2015-10-21 19:41:03 +00:00
Rui Ueyama 8f2c4da65a ELF2: Rename getMostConstrainingVisibility -> getVisibility. NFC.
The previous name was too long.

llvm-svn: 250920
2015-10-21 18:13:47 +00:00
Rui Ueyama c96d0dd431 ELF2: Simplify DT_FLAGS{,_1} handling. NFC.
llvm-svn: 250914
2015-10-21 17:47:10 +00:00
Davide Italiano 6e91c598b9 [ELF2] Add support for -z origin.
llvm-svn: 250907
2015-10-21 17:09:47 +00:00
Craig Topper f88d22970d Update lld to match llvm r250901. OptTable constructor now takes an ArrayRef. NFC
llvm-svn: 250904
2015-10-21 16:31:56 +00:00
Rafael Espindola f5af835759 Fix symbol value calculation in SHF_MERGE.
We would get the wrong value if the symbol was in the middle of an entry.

llvm-svn: 250865
2015-10-20 22:08:49 +00:00
Igor Kudrin ab665fc475 [ELF2] Determine the order of entries of symbol tables in the finalize() phase.
* Move the responsibility to call SymbolBody::setDynamicSymbolTableIndex()
  from the hash table to the dynamic symbol table.
* Hash table is not longer responsible for filling the dynamic symbol table.
* The final order of symbols of both symbol tables is set before writing
  phase starts.
* Remove repeaded scan of the symbol table during writting SymbolTableSection.

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

llvm-svn: 250864
2015-10-20 21:47:58 +00:00
Lang Hames 2483d8f4a7 [lld][MachO] Fix indentation.
llvm-svn: 250863
2015-10-20 21:47:19 +00:00
Lang Hames 650c00be89 [lld][MachO] Fix typo in comment.
llvm-svn: 250861
2015-10-20 21:44:30 +00:00
Igor Kudrin 853b88d7ff [ELF2] Extract calculation of symbol binding as a separate function.
Differential Revision: http://reviews.llvm.org/D13910

llvm-svn: 250855
2015-10-20 20:52:14 +00:00
George Rimar 0f5ac9f571 [ELF2] .shstrtab section implemented
The section header table index of the entry that is associated with the section name string table.

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

llvm-svn: 250836
2015-10-20 17:21:35 +00:00
George Rimar 4a8c93ee85 [elf2] - remove redundant check.
This one is not needed anymore after r250812

llvm-svn: 250818
2015-10-20 11:27:00 +00:00
George Rimar 505f792cbb Fixed buildbot. Sorry.
llvm-svn: 250815
2015-10-20 11:07:03 +00:00
George Rimar 85f1d6678f [ELF2] -l behavior is JoinedOrSeparate. Keeping consistency with ld here.
llvm-svn: 250812
2015-10-20 10:03:14 +00:00
George Rimar b7d79b5c27 [ELF2] Fixed crash when no library is specified for -l
llvm-svn: 250811
2015-10-20 09:58:56 +00:00
George Rimar 648a2c37fb [ELF2] - Lazy relocation support for x86_64.
Target has supportsLazyRelocations() method which can switch lazy relocations on/off (currently all targets are OFF except x64 which is ON). So no any other targets are affected now.

Differential Revision: http://reviews.llvm.org/D13856?id=37726

llvm-svn: 250808
2015-10-20 08:54:27 +00:00
George Rimar c96c182ab4 Reverts r250775 as it breaks self-hosting.
llvm-svn: 250807
2015-10-20 08:49:43 +00:00
Davide Italiano ea03901e71 [Driver] Remove a FIXME that didn't make a lot of sense.
Thanks to Rui for pointing out!

llvm-svn: 250800
2015-10-20 05:07:59 +00:00
Davide Italiano 06edc7c0aa [ELF2] Correctly set bits when -z now is specified.
The option now just sets NOW bit in DT_FLAGS_1 but some loaders
seem to require also BIND_NOW bit to be set in DT_FLAGS. This is,
also, what ld.bfd and gold do.

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

llvm-svn: 250799
2015-10-20 04:58:40 +00:00
Davide Italiano 1ea1fd6b34 [Driver] Error out instead of silently ignoring on invalid -z argument.
This matches what both ld.bfd and gold do.

llvm-svn: 250775
2015-10-20 00:34:04 +00:00
Davide Italiano 88f476b9eb [ELF2] Introduce support for -z nodelete.
llvm-svn: 250771
2015-10-20 00:20:20 +00:00
Davide Italiano 58cbaf0604 [ELF2/OutputSections] Allocate the correct number of entries after r250739.
llvm-svn: 250760
2015-10-19 23:32:16 +00:00
Davide Italiano 56d18f4f8a [OutputSection] Set the symbolic bit in DT_FLAGS and not DT_FLAGS_1.
The two names are similar enough that they might lead to confusion.
The output of readobj clarifies but I missed it when I originally
committed this. Found while linking FreeBSD userland with lld.

llvm-svn: 250739
2015-10-19 21:34:00 +00:00
Davide Italiano 5d1ec86910 [Driver] Ignore some options used to link FreeBSD userland.
We're gonna implement them at some point, but they're mostly warning,
not of vital importance at this stage of development.

llvm-svn: 250738
2015-10-19 21:01:32 +00:00
Rafael Espindola c159c967f6 Add support for merging the contents of SHF_MERGE sections.
For now SHF_STRINGS are not supported.

llvm-svn: 250737
2015-10-19 21:00:02 +00:00
Rui Ueyama f215dac553 Replace auto with a real type. NFC.
llvm-svn: 250736
2015-10-19 20:55:28 +00:00
Rui Ueyama b7f2867a85 Reduce nesting level. NFC.
llvm-svn: 250732
2015-10-19 20:31:49 +00:00
Rafael Espindola 932efcfa77 Change getLocalRelTarget to include the addend.
Given the name, it is natural for this function to compute the full target.

This will simplify SHF_MERGE handling by allowing getLocalRelTarget to
centralize the addend logic.

llvm-svn: 250731
2015-10-19 20:24:44 +00:00
Rafael Espindola 4975752389 Simplify by computing on relocation field at a time.
llvm-svn: 250730
2015-10-19 19:58:18 +00:00
Rui Ueyama 75656eebb8 COFF: /OPT should accept comma-separated multiple arguments.
/OPT:foo,bar is equivalent to /OPT:foo /OPT:bar.

Reported by alexchandel. https://llvm.org/bugs/show_bug.cgi?id=25228

llvm-svn: 250728
2015-10-19 19:40:43 +00:00
Rafael Espindola d64430472d Fix comment.
llvm-svn: 250725
2015-10-19 19:24:03 +00:00
George Rimar 83f406cff5 [ELF2] - Linker script EXTERN command implemented.
The reason of collecting all undefines in vector is that during reading files we already need to have Symtab created. Or like was done in that patch - to put undefines from scripts somewhere to delay Symtab.addUndefinedOpt() call.

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

llvm-svn: 250711
2015-10-19 17:35:12 +00:00
Rafael Espindola 334c3e11e6 Delay the relocation scan.
We have to scan the relaxations after every symbol is defined.

This fixes pr25218.

llvm-svn: 250702
2015-10-19 15:21:42 +00:00
Igor Kudrin ea6a835f4e [ELF2] In/out parameter of writeGlobalSymbols() is changed to in parameter.
There is no outer code which requires the changed value.

llvm-svn: 250688
2015-10-19 08:01:51 +00:00
Rafael Espindola 69535df0e9 Mark R_X86_64_PLT32 as relative.
llvm-svn: 250682
2015-10-19 05:20:01 +00:00
Rafael Espindola 5045e44a17 Simplify. NFC.
llvm-svn: 250640
2015-10-18 03:13:46 +00:00
Hal Finkel 8228198049 [ELF2/PPC64] Don't create .plt entries for weak undef symbols
Instead of specifically creating .plt entries for weak undef symbols, mirror
the logic in r250584, and use canBePreempted to determine is a REL24 relocation
needs a .plt entry. This might cause relocateOne to be called for a weak undef
symbol, with a REL24 relocation, but ignore this as a special case (this will
cause SA == 0, which won't happen under any other circumstance).

llvm-svn: 250597
2015-10-17 00:48:20 +00:00
Rui Ueyama eb3d5cef34 Remove DOS newlines.
llvm-svn: 250586
2015-10-16 23:55:40 +00:00
George Rimar 8911d85c2f [ELF2] - Implemented R_X86_64_PLT32 relocation.
There is sometimes no need to generate relocation via PLT. 
Example - when symbol is not undefined and we are not creating shared library. Then we can create relative relocation instead of referencing and creating PLT records.

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

llvm-svn: 250584
2015-10-16 23:52:24 +00:00
Rafael Espindola 80c94a7856 Use a reference. NFC.
llvm-svn: 250578
2015-10-16 23:22:23 +00:00
Michael J. Spencer 1bf73000cf [elf2] Sort allocated TLS sections at the start of the R/W PT_LOAD.
Differential Revision: http://reviews.llvm.org/D13763

llvm-svn: 250572
2015-10-16 23:11:07 +00:00
Rui Ueyama 6455852a28 ELF2: Treat IsMips64EL as a global configuration.
If one file is MIPS64EL, all files are MIPS64EL, and vice versa.
We do not have to look up MIPS-ness for each file. Currently we
do not support 64-bit MIPS, so the config value is always false.

llvm-svn: 250566
2015-10-16 22:51:43 +00:00
Hal Finkel 230c5c5b52 [ELF2] Remove unneeded new Type parameter
As pointed out by Rafael (with a further suggestion by Rui), the new Type
parameter I added in r250555 is not needed. Remove it.

llvm-svn: 250563
2015-10-16 22:37:32 +00:00
Hal Finkel c91740616a [ELF2] Don't create RelativeReloc for weak undef symbols
When we have a R_PPC64_ADDR64 for a weak undef symbol, which thus resolves to
0, and we're creating a shared library, we need to make sure that it stays 0
(because code that conditionally calls the weak function tests for this).
Unfortunately, we were creating a R_PPC64_RELATIVE for these relocation
targets, making the address of the undefined weak symbol equal to the base
address of the shared library (which is non-zero). In general, we should not be
creating RelativeReloc relocs for undef weak symbols.

llvm-svn: 250558
2015-10-16 22:11:05 +00:00
Michael J. Spencer 7dccca543a [elf2] Simplify and rename x86-64 relocation error tests.
llvm-svn: 250556
2015-10-16 22:05:52 +00:00
Hal Finkel 6f97c2bc00 [ELF2] getLocalRelTarget should handle R_PPC64_TOC directly
R_PPC64_TOC does not have an associated symbol, but does have a non-zero VA
that target-specific code must compute using some non-trivial rule. We
handled this as a special case in PPC64TargetInfo::relocateOne, where
we knew to write this special address, but that did not work when creating shared
libraries. The special TOC address needs to be the subject of a
R_PPC64_RELATIVE relocation, and so we also need to know how to encode this
special address in the addend of that relocation.

Thus, some target-specific logic is necessary when creating R_PPC64_RELATIVE as
well. To solve this problem, we teach getLocalRelTarget to handle R_PPC64_TOC
as a special case. This allows us to remove the special case in
PPC64TargetInfo::relocateOne (simplifying code there), and naturally allows the
existing logic to do the right thing when creating associated R_PPC64_RELATIVE
relocations for shared libraries.

llvm-svn: 250555
2015-10-16 21:55:40 +00:00
Rui Ueyama 83a131fa73 ELF2: Remove an empty stub for 32-bit PPC.
This code will be resurrected when we start working on PPC32.

llvm-svn: 250553
2015-10-16 21:37:09 +00:00
Davide Italiano a716574b0d [ELF2/AArch64] Comment R_AARCH64_ADD_ABS_LO12_NC relocation.
Differential Revision:	 http://reviews.llvm.org/D13832

llvm-svn: 250551
2015-10-16 21:06:55 +00:00
Rafael Espindola bfaa4ef60e Fix a copy and paste error in a test.
llvm-svn: 250548
2015-10-16 20:25:12 +00:00
Rafael Espindola 890e89caad Add an interesting case where we were already producing the correct result.
llvm-svn: 250544
2015-10-16 19:57:42 +00:00
Hal Finkel 0091862801 [ELF2/PPC64] Invert PPC64TargetInfo::isRelRelative's default
When I initially implemented PPC64TargetInfo::isRelRelative, I included a fixed
set of relative relocations, and made the default false. In retrospect, this
seems unwise in two respects: First, most PPC64 relocations are relative
(either to the base address, the TOC, etc.). Second, most relocation targets
are not appropriate for R_PPC64_RELATIVE (which writes a 64-bit absolute
address). Thus, back off, and include only those relocations for which we test
(or soon will), and are obviously appropriate for R_PPC64_RELATIVE.

llvm-svn: 250540
2015-10-16 19:01:50 +00:00
Rafael Espindola 4cda58168a Add a ObjectFile<ELFT>::getSection helper and simplify. NFC.
llvm-svn: 250519
2015-10-16 15:29:48 +00:00
Rui Ueyama c7cc6ecf08 ELF2: Use ELFT to template OutputSections.
This patch is to use ELFT instead of Is64Bits to template OutputSection
and its subclasses. This increases code size slightly because it creates
two identical functions for some classes, but that's only 20 KB out of
33 MB, so it's negligible.

This is as per discussion with Rafael. He's not fan of the idea but OK
with this. We'll revisit later to this topic.

llvm-svn: 250466
2015-10-15 22:27:29 +00:00
Rui Ueyama c6ef3f28fc ELF2: Do not treat .strtab specially when creating sections.
String table is added to end of the file so that all the other sections
are finalized before string table. But we can just add section names to
the string table before calling finalize() on any section instead.

llvm-svn: 250463
2015-10-15 21:50:30 +00:00
Rui Ueyama 5f1eee1aac ELF2: Move HashTableSection::hash out of the class.
Because the function does not depend on the class.

llvm-svn: 250462
2015-10-15 21:27:17 +00:00
Rui Ueyama 2317d0d4d6 Remove a getter/setter that don't hide anything.
llvm-svn: 250458
2015-10-15 20:55:22 +00:00
Rui Ueyama 96b190428e Fix style.
llvm-svn: 250457
2015-10-15 20:55:20 +00:00
Rui Ueyama 6607227fc1 ELF2: Rename SymVA -> SA if SymVA includes addend.
llvm-svn: 250447
2015-10-15 19:52:27 +00:00
Rui Ueyama 9e82fa22e4 ELF2: s/R/SA/ in PPC64 relocations because R is S + A.
llvm-svn: 250445
2015-10-15 19:39:36 +00:00
Rafael Espindola b26d807033 Use OutputSectionBase in a few more places. NFC.
Just making room for having another output section type.

llvm-svn: 250443
2015-10-15 19:31:49 +00:00
Rafael Espindola 826941a69a Rename variable to make it clear it includes the addend.
Thanks to Rui for the suggestion.

llvm-svn: 250437
2015-10-15 18:19:39 +00:00
Rui Ueyama d9189ceb23 ELF2: Implement __start_SECNAME and __stop_SECNAME.
If a section name is valid as a C identifier (which is rare because of
the leading '.'), linkers are expected to define __start_<secname> and
__stop_<secname> symbols. They are at beginning and end of the section,
respectively. This is not requested by the ELF standard, but GNU ld and
gold provide this feature.

llvm-svn: 250432
2015-10-15 17:11:03 +00:00
Hal Finkel 33e17a7c73 [ELF2/PPC64] Error on R_PPC64_ADDR16 overflow
R_PPC64_ADDR16 is not a truncated relocation, and should error if the address
cannot be represented in 16 bits.

llvm-svn: 250424
2015-10-15 16:17:30 +00:00
Hal Finkel 000561c2f5 Revert "r250372 - [ELF2/PPC64] Remove now-dead weak/undef check"
Unfortunately, the check was not as dead as I had thought, and adjusting the
starting VA again exposed the problem. We end up trying to relocate the bl
(using a 24-bit relative offset) to a symbol address of zero, and in general,
that does not fit.

Thus, reverting for now, and adding a test case.

llvm-svn: 250423
2015-10-15 16:12:35 +00:00
Rafael Espindola aa19708f88 Centralize the handling of r_addend. NFC.
When a relocation points to a SHF_MERGE section, the addend has special meaning.
It should be used to find what in the section the relocation points to. It
should not be added to the output position.

Centralizing it means that the above rule will be implemented once, not once
per target.

llvm-svn: 250421
2015-10-15 15:52:12 +00:00
Rafael Espindola ae81a7bf49 Use OutputSectionBase in a few cases where we don't need a OutputSection.
NFC. This is just preparation for adding a new OutputSection dedicated to
SHF_MERGE input sections.

llvm-svn: 250419
2015-10-15 15:29:53 +00:00
Ed Maste cbd42b17c7 Recognize -Bshareable alias for -shared
llvm-svn: 250397
2015-10-15 13:03:16 +00:00
Rafael Espindola 37f0b7d28a Rename CAlloc since it allocates sections, not chunks.
llvm-svn: 250395
2015-10-15 12:33:04 +00:00
Rafael Espindola bdc7620191 Remove unnecessary llvm:: prefix.
llvm-svn: 250394
2015-10-15 12:30:29 +00:00
Hal Finkel 736c741752 [ELF2] Set a target-specific VAStart for PPC64
After some additional post-commit (post-revert) discussion and research, this
reverts, in part, r250205, so the ABI-recommended starting address can be used
on PPC64 (as is done by other linkers).

Also, this addresses the FIXME in ELF/Writer.cpp by making VAStart a
target-dependent property.

llvm-svn: 250378
2015-10-15 07:49:07 +00:00
Hal Finkel ae3f05b987 [ELF2/PPC64] Remove now-dead weak/undef check
After r250311, this check is dead. Remove it.

llvm-svn: 250372
2015-10-15 06:44:19 +00:00
Rui Ueyama 55c3f89edb ELF2: Do not use OutputSection as a member variable name.
We have OutputSection<ELFT> type. GCC 4.9.2 warns on the duplication.

llvm-svn: 250358
2015-10-15 01:58:40 +00:00
Rafael Espindola 39428e9358 Remove silly getter use.
It was creating a local var with the same name as the member var.

llvm-svn: 250347
2015-10-14 23:30:28 +00:00
Rui Ueyama 690db6786e Simplify.
llvm-svn: 250337
2015-10-14 22:32:10 +00:00
Rui Ueyama 2b675074fe ELF2: Support --entry=<addr>.
If an argument for --entry is a number, that's not a symbol name but
an absolute address. If that's the case, the address is directly set
to ELF header's e_entry.

llvm-svn: 250334
2015-10-14 22:20:57 +00:00
Rui Ueyama efc23de4dd ELF2: Move Target concrete classes from .h to .cpp.
llvm-svn: 250330
2015-10-14 21:30:32 +00:00
Rui Ueyama 80edbbbdf8 ELF2: Remove {set,get}OutputSection accessors.
These accessors didn't provide any additional value over a public
member variable, too.

llvm-svn: 250328
2015-10-14 21:09:55 +00:00
Rui Ueyama edffd91bce ELF2: Remove {set,get}OutputSectionOff accessors.
These accessors didn't provide any additional value over a public
member variable.

llvm-svn: 250326
2015-10-14 21:00:23 +00:00
Rui Ueyama 4fcadaf5e7 ELF2: Merge .{text,rodata,data,bss}.* sections.
Previously, we used input section names as output section names.
That resulted that we created lots of sections for comdat
or -f{function,data}-section sections.

This patch reduces the number of sections by dropping suffix from
all section names which start with ".text.", ".rodata.", ".data."
or ".bss.". GNU linker does this using the internal linker script,
but for LLD I chose to do that directly.

Interestingly, this makes the linker faster. Time to link Clang
is this.

Before:

  real    0m0.537s
  user    0m0.433s
  sys     0m0.104s

After:

  real    0m0.390s
  user    0m0.268s
  sys     0m0.120s

It make sense because previously we created 57659 sections now only 27.

llvm-svn: 250315
2015-10-14 19:21:25 +00:00
Rafael Espindola cc6ebb8e69 Handle dynamic relocs to weak undefined when possible.
llvm-svn: 250311
2015-10-14 18:42:16 +00:00
Rafael Espindola 227556e1c7 Add support for a R_X86_64_32 referring to a plt.
This can show up with a non-PIC .o being linked into an executable that uses
shared libraries.

llvm-svn: 250300
2015-10-14 16:15:46 +00:00
Simon Atanasyan 9c2d788dda [ELF2][mips] Support both big and little endian MIPS 32-bit targets
- Make the `MipsTargetInfo` template class with `ELFType` argument. Use
  the argument to select an appropriate relocation type and read/write
  routines.
- Add template function `add32` to add-and-write relocation value in
  both big and little endian cases. Keep the `add32le` to reduce code
  changes.

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

llvm-svn: 250297
2015-10-14 14:24:46 +00:00
Rui Ueyama 5f551aee02 ELF2: Remove getAddrSize().
llvm-svn: 250296
2015-10-14 14:02:06 +00:00
Hal Finkel 4e961dde16 [ELF2/PPC64] S+A -> R in more places when handling R_PPC64_REL24
We already have a variable, R, that equals S + A. Use it. NFC.

llvm-svn: 250243
2015-10-13 22:54:24 +00:00
Hal Finkel fa92f686bc [ELF2/PPC64] Fix the TOC save in the .plt stub
The comment was right, but the encoding was wrong (and, it seems, I forgot a
test case for the .plt stub).

llvm-svn: 250230
2015-10-13 21:47:34 +00:00
Davide Italiano 355cc52292 [ELF2] Don't allocate entry for DT_SYMBOLIC.
This fixes an oversight from my previous commit. Reported by
Rafael Espindola!

llvm-svn: 250229
2015-10-13 21:39:55 +00:00
Rui Ueyama 38edcec272 ELF2: Add a note about performance.
llvm-svn: 250227
2015-10-13 21:28:02 +00:00
Davide Italiano cebb449e11 [ELF2] Add support for -Bsymbolic.
llvm-svn: 250225
2015-10-13 21:02:34 +00:00
Davide Italiano 10d268d62c [ELF2/Linkerscript] Skip semicolon in linker directives parsing.
The documentation says: "You may separate commands using semicolons",
so they seem to be optional.

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

llvm-svn: 250223
2015-10-13 20:48:56 +00:00
Hal Finkel 515ed44776 [ELF2/PPC64] Fix the end-of-buffer check for TOC restoration
We'd miss the nop if it really did come right at the end of the buffer (nice
off-by-one error).

llvm-svn: 250220
2015-10-13 20:31:33 +00:00
Rui Ueyama 34f2924675 ELF2: Add comments.
llvm-svn: 250215
2015-10-13 19:51:57 +00:00
Hal Finkel 600ff141ec [ELF2] Simplify the NOBITS sorting logic
As Rafael suggested in his review of r250190, we can simplify this by writing
it like the earlier checks.

llvm-svn: 250212
2015-10-13 19:27:12 +00:00
Hal Finkel ea244fcb84 [ELF2] Drop unnecessary lld flags from test/elf2/ppc64-toc-restore.s
As Rafael pointed out in his review of r250110, -dynamic-linker, -rpath and
--export-dynamic are unnecessary.

llvm-svn: 250210
2015-10-13 19:16:56 +00:00
Hal Finkel 9abc2a50b3 [ELF2] Only call getPPC64SectionRank for EM_PPC64 files
Suggested by Rafael in his review of r250100. As Rafael points out, this may
grow into a switch in the future, but regardless, calling this on files for
other architectures is unnecessary.

llvm-svn: 250209
2015-10-13 19:07:29 +00:00
Rui Ueyama deac4909c7 Update README.
llvm-svn: 250208
2015-10-13 18:55:59 +00:00
Hal Finkel 08be61407b [ELF2] Fixup comment about section sorting requirements
As Rafael pointed out in his review of r250100, the NOBITS check is no longer
the last requirement.

llvm-svn: 250206
2015-10-13 18:55:01 +00:00
Hal Finkel d962ef0bf8 Revert: "Re: [lld] r249752 - Revert: r249728 - Roll back r249726 and r249723 because they broke buildbots."
This has turned out to be unnecessary, and while some ability to set VAStart
will be needed at some point, this is not clearly the right direction.

llvm-svn: 250205
2015-10-13 18:50:28 +00:00
Rui Ueyama 93bfee5f70 ELF2: Avoid using "finalize" as a function name.
"finalize" does not give a hint about what that function is actually
going to do. This patch make it more specific by renaming scanShlibUndefined.
Also add a comment that we basically ignore undefined symbols in DSOs except
this function.

llvm-svn: 250191
2015-10-13 18:10:33 +00:00
Hal Finkel 0d7e83bbc4 [ELF2] Ensure strict weak ordering in section sorting (v2)
The fix in r250109 to ensure a strict weak ordering in the section sorting was
a bit overzealous. We only use the NOBITS comparison if either A or B is a
NOBITS section. Otherwise, we fall through to the target-specific ranking
function. Failure to do this causes the sorting to fail in cases where, for
example, a .dynamic section happens to end up in between .got and .toc, etc. in
the initial ordering (.dynamic has a type SHT_DYNAMIC, compared to SHT_PROGBITS
or SHT_NOBITS).

llvm-svn: 250190
2015-10-13 17:57:46 +00:00
Rui Ueyama c58656c7c0 Revert r250169: "This patch implements basic variant of lazy loading for x86_x64 and for X86 targets."
With this patch LLD is not able to self-host on x86-64 Linux.

llvm-svn: 250182
2015-10-13 16:59:30 +00:00
Rui Ueyama c2c22f44bf Remove extra semicolons for -Wpedantic.
llvm-svn: 250178
2015-10-13 16:44:13 +00:00
Rui Ueyama f8432d97f3 ELF2: Fix BSD's __progname symbol issue.
BSD's DSO files have undefined symbol "__progname" which is defined
in crt1.o. On that system, both user programs and system shared
libraries depend on each other.

In general, we need to put symbols defined by user programs which are
referenced by shared libraries to user program's .dynsym.

http://reviews.llvm.org/D13637

llvm-svn: 250176
2015-10-13 16:34:14 +00:00
Rui Ueyama e717a7195b ELF2: Rename ElfKind -> EKind.
ELFKind as a type name and ElfKind is a variable name was too subtle.

llvm-svn: 250172
2015-10-13 16:20:50 +00:00
Rui Ueyama 7b94893cec ELF2: Fix typos in comment.
llvm-svn: 250171
2015-10-13 16:15:50 +00:00
Rui Ueyama adf666010f Remove trailing whitespaces.
llvm-svn: 250170
2015-10-13 16:13:18 +00:00
George Rimar 9fd8fcb5a4 This patch implements basic variant of lazy loading for x86_x64 and for X86 targets.
What was done:
1) .got.plt section is created for functions that requires PLT. .got.plt has 3 predefined empty entries now that are required for dynamic linker.
Also other new items created are configured to have correct jump to PLT[N].
2) PLT section now has PLT[0] entry, also others ones are configured to support PLT->GOT(.got.plt) calls.
3) Implemented .rel[a].plt sections (based on patch http://reviews.llvm.org/D13569).
4) Fixed plt relocations types (based on patch http://reviews.llvm.org/D13589).

NOTES:
The .plt.got zero entry is still empty now. According to ELF specification it should hold the address of the dynamic structure, referenced with the symbol
_DYNAMIC. The _DYNAMIC entry points to the .dynamic section which contains information used by the ELF interpreter to setup the binary.

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

llvm-svn: 250169
2015-10-13 16:09:55 +00:00
Rui Ueyama 9100439391 ELF2: Move createTarget to Target.cpp.
Now all Target<Arch> classes are used only in Target.cpp.
We can put them in an anonymous namespace. In order to avoid
merge conflict with other people's patches, I'll do that later.

llvm-svn: 250168
2015-10-13 16:08:15 +00:00
Rui Ueyama e7e3348aa3 ELF2: Remove dead code.
This code is completely a stub. We can resurrect when we start working on ARM.

llvm-svn: 250167
2015-10-13 16:03:39 +00:00
George Rimar 53b581c522 Removed undefined and unused member. NFC.
llvm-svn: 250163
2015-10-13 15:16:01 +00:00
Rafael Espindola 7f10746be0 Remove unnecessary include.
llvm-svn: 250161
2015-10-13 14:54:49 +00:00
Rafael Espindola 7a51305c91 Simplify by using Out<ELFT>::Opd.
Also avoid extra dependencies on the section name.

llvm-svn: 250159
2015-10-13 14:45:51 +00:00
Rafael Espindola 2a4b27111d Remove the EKind member variable.
Now that the base class is templated, it is redundant with the type.

llvm-svn: 250139
2015-10-13 01:17:02 +00:00
Rui Ueyama f03f3cc18c Use llvm::sys::path::is_absolute instead of my own.
llvm-svn: 250133
2015-10-13 00:09:21 +00:00
Rui Ueyama 63d8880b38 Fix test breakage on Windows.
llvm-svn: 250127
2015-10-12 23:49:04 +00:00
Michael J. Spencer 18255a333e [elf2] Tighten up test.
llvm-svn: 250126
2015-10-12 23:44:22 +00:00
Michael J. Spencer 350e5b5cc2 [elf2] Inline needsDynamicSections.
llvm-svn: 250125
2015-10-12 23:39:23 +00:00
Hal Finkel daedc12172 [ELF2/PPC64] Resolve local-call relocations using the correct function-descriptor values
Under PPC64 ELF v1 ABI, the symbols associated with each function name don't
point directly to the code in the .text section (or similar), but rather to a
function descriptor structure in a special data section named .opd. The
elements in the .opd structure include a pointer to the actual code, and a the
relevant TOC base value. Both of these are themselves set by relocations.

When we have a local call, we need the relevant relocation to refer directly to
the target code, not to the function-descriptor in the .opd section. Only when
we have a .plt stub do we care about the address of the .opd function
descriptor itself.

So we make a few changes here:

 1. Always write .opd first, so that its relocated data values are available
    for later use when writing the text sections. Record a pointer to the .opd
    structure, and its corresponding buffer.

 2. When processing a relative branch relocation under ppc64, if the
    destination points into the .opd section, read the code pointer out of the
    function descriptor structure and use that instead.

This this, I can link, and run, a dynamically-compiled "hello world"
application on big-Endian PPC64/Linux (ELF v1 ABI) using lld.

llvm-svn: 250122
2015-10-12 23:16:53 +00:00
Davide Italiano 9159ce9327 [ELF2/LinkerScript] Implement parsing of OUTPUT_ARCH() command.
Differential Revision:	 http://reviews.llvm.org/D13675

llvm-svn: 250115
2015-10-12 21:50:08 +00:00
Hal Finkel 87bbd5ffd4 [ELF2] Allow PPC64 to add the TOC-restore after .plt-based relocations
Under the PPC64 ELF ABI, functions that might call into other modules (and,
thus, need to load a different TOC base value into %r2), need to restore the
old value after the call. The old value is saved by the .plt code, and the
caller only needs to include a nop instruction after the call, which the linker
will transform into a TOC restore if necessary.

In order to do this the relocation handler needs two things:

 1. It needs to know whether the call instruction it is modifying is targeting
    a .plt stub that will load a new TOC base value (necessitating a restore after
    the call).

 2. It needs to know where the buffer ends, so that it does not accidentally
    run off the end of the buffer when looking for the 'nop' instruction after the
    call.

Given these two pieces of information, we can insert the restore instruction in
place of the following nop when necessary.

llvm-svn: 250110
2015-10-12 21:19:18 +00:00
Hal Finkel cf58b6a48c [ELF2] Ensure strict weak ordering in section sorting
As pointed out by Rui (post-commit review), we need to always return based on
the section type when the types differ to ensure a strict weak ordering.

llvm-svn: 250109
2015-10-12 21:14:03 +00:00
Hal Finkel ee44e2401b test/elf2/relative-dynamic-reloc-ppc64.s requires ppc
Fix the buildbot; this test also requires ppc target support.

llvm-svn: 250107
2015-10-12 21:11:53 +00:00
Davide Italiano 6836c6182d [ELF2/LinkerScript] Fix OUTPUT_FORMAT directive parsing
Differential Revision:	 http://reviews.llvm.org/D13668

llvm-svn: 250106
2015-10-12 21:08:41 +00:00
Hal Finkel 66a123806e [ELF2] Fixup test case for TOC relocation
Now that the target relocation handle will see R_PPC64_TOC, fix the test case
accordingly.

llvm-svn: 250104
2015-10-12 21:04:40 +00:00
Hal Finkel be0823dcc4 [ELF2] Implement PPC64TargetInfo::isRelRelative
This is essentially pattern-matching against the x86 target, and generates the
analogous PPC64 relocation.

llvm-svn: 250102
2015-10-12 20:58:52 +00:00
Hal Finkel 3c8cc677e6 [ELF2] Add a base set of PPC64 relocations
This is mostly an adaptation of the code in LLVM's
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp, and handles a sufficient
number of relocations to link a 'hello world' program on big-Endian PPC64/Linux
(ELF v1 ABI).

llvm-svn: 250101
2015-10-12 20:56:18 +00:00
Hal Finkel 3bae2d8733 [ELF2] Sort PPC64 special sections
PPC64 has several special sections that are intended to be accessed from the
TOC base pointer. When a .got is present, the TOC base pointer is .got + 0x8000
(as specified by the ABI). Furthermore, the glibc startup code contains an
assumption that a 16-bit relocation can hold the offset from the TOC base value
to the beginning of the .toc section. Thus, we need to make sure that .toc
appears after .got. This much, at least, is required in practice. The other
PPC64 special sections (.toc, .toc1, .opd, etc.) should also be close by to
optimize access by smaller TOC-base-pointer offsets.

llvm-svn: 250100
2015-10-12 20:51:48 +00:00
Rui Ueyama bb3c33609b Continue early to reduce indentation.
llvm-svn: 250096
2015-10-12 20:28:23 +00:00
Rui Ueyama 126d08f891 ELF2: Create a function to get VA from Elf_Rel.
And remove git getLocalSymVA because there's no user of the function anymore.

llvm-svn: 250095
2015-10-12 20:28:22 +00:00
Hal Finkel c848b321fd [ELF2/PPC64] Add a comment about the page size
Rafael requested some additional commentary (post-commit review of r249760), to
make it clear this is intended and necessary.

llvm-svn: 250087
2015-10-12 19:34:29 +00:00
Rui Ueyama 242ddf4037 Instead of computing offset from current and start, use a variable. NFC.
llvm-svn: 250080
2015-10-12 18:56:36 +00:00
Rui Ueyama c538b13a1a Remove break after error because error is _Noreturn.
llvm-svn: 250079
2015-10-12 18:53:12 +00:00
Rui Ueyama 3d45179d56 ELF2: Split SymbolTable::addFile(). NFC.
llvm-svn: 250073
2015-10-12 18:03:21 +00:00
Rui Ueyama 26479c3883 ELF2: Verify that weak undefined symbols won't add DT_NEEDED.
In order to actually verify the condition, we have to use a weak symbol.
If an undefined symbol is not used at all, it is naturally ignored not by
the code for --as-needed but by the code for something else.

llvm-svn: 250062
2015-10-12 16:25:33 +00:00
Rui Ueyama 1613c018d4 ELF2: Do not put temporary files to the test toplevel directory.
llvm-svn: 250057
2015-10-12 15:58:38 +00:00
Rui Ueyama 1c42afcbdc Remove explicit Twine instantiation if possible.
llvm-svn: 250055
2015-10-12 15:49:06 +00:00
Rui Ueyama 361d8b9350 Early return.
llvm-svn: 250054
2015-10-12 15:49:02 +00:00
Rui Ueyama c4b6506521 ELF2: Move createELFFile() from .h to .cpp.
llvm-svn: 250051
2015-10-12 15:31:09 +00:00
Rui Ueyama 2ee8e113ba Remove redundant namespace specifiers.
llvm-svn: 250050
2015-10-12 15:27:09 +00:00
Rui Ueyama 0cef68913e ELF2: Handle default entry name in the driver.
llvm-svn: 250048
2015-10-12 15:23:54 +00:00
Rui Ueyama 4702b86176 Fix indentation.
llvm-svn: 250047
2015-10-12 15:15:45 +00:00
Simon Atanasyan 3b732ac7ee [ELF2][mips] Support R_MIPS_32 relocation
llvm-svn: 250045
2015-10-12 15:10:02 +00:00
Rafael Espindola fb677dfd73 Make getStaticELFKind a member function now that we can.
llvm-svn: 250031
2015-10-12 12:14:30 +00:00
Rafael Espindola b9ca7bb6ab Delete getFirstELF.
llvm-svn: 250030
2015-10-12 11:52:31 +00:00
Rafael Espindola 9b278a1695 This doesn't need to be virtual anymore.
llvm-svn: 250028
2015-10-12 11:26:55 +00:00
Rafael Espindola dfce5a25cb Simplify the InputFile type hierarchy by removing unnecessary middle classses.
llvm-svn: 250006
2015-10-12 02:22:58 +00:00
Rafael Espindola af70764aa1 Simplify the InputFile type hierarchy.
Now that the SymbolTable is templated, we don't need the ELFData class or
multiple inheritance.

llvm-svn: 250005
2015-10-12 01:55:32 +00:00
Rui Ueyama 35da9b6e1c ELF2: Implement --as-needed.
This patch adds AsNeeded and IsUsed bool fields to SharedFile. AsNeeded bit
is set if the DSO is enclosed with --as-needed and --no-as-needed. IsUsed
bit is off by default. When we adds a symbol to the symbol table for dynamic
linking, we set its SharedFile's IsUsed bit.

If AsNeeded is set but IsUsed is not set, we don't want to write that
file's SO name to DT_NEEDED field.

http://reviews.llvm.org/D13579

llvm-svn: 249998
2015-10-11 20:59:12 +00:00
Rafael Espindola 9afbac479f Handle a crash in conflict detection with archive members.
llvm-svn: 249996
2015-10-11 20:19:20 +00:00
Rui Ueyama a561e78447 Clang-format.
llvm-svn: 249992
2015-10-11 19:46:00 +00:00
Rui Ueyama 536c999d93 Rename phdr{Copy,Set} -> {set,copy}Phdr.
They are functions, so they should be verbs.

llvm-svn: 249991
2015-10-11 19:45:58 +00:00
Rui Ueyama c6e1b97161 ELF2: Remove ArgParser class and define parseArgs() function instead.
ArgParser was a class with only one member function, so it didn't
have to be a class.

llvm-svn: 249988
2015-10-11 18:19:01 +00:00