Commit Graph

4475 Commits

Author SHA1 Message Date
Eugene Zelenko 6e43b499d2 Fix Clang-tidy modernize-use-override warnings, other minor fixes.
Differential revision: http://reviews.llvm.org/D14310

llvm-svn: 252034
2015-11-04 02:11:57 +00:00
Rafael Espindola 5fbe008eb7 Simplify the logic to avoid the Closed set.
IMHO this makes the code easier to read: at each iteration we add
a section to a PT_LOAD and increase its size.

llvm-svn: 252011
2015-11-03 23:19:42 +00:00
Michael J. Spencer 2c6f213bcd [elf2] Use value-initialization instead of memset.
llvm-svn: 252006
2015-11-03 22:43:11 +00:00
Michael J. Spencer d77f0d2526 [elf2] Implement R_X86_64_TPOFF32.
This does not support TPOFF32 relocations to local symbols as the address calculations are separate. Support for this will be a separate patch.

llvm-svn: 251998
2015-11-03 22:39:09 +00:00
Rafael Espindola 61362ce876 Handle 0 sized sections like any other section.
This is a case where there is inconsistency among ELF linkers:

* The spec says nothing special about empty sections.
* BFD ld removes them.
* Gold handles them like regular sections.

We were outputting them but sometimes ignoring them. This would create
odd looking outputs where a rw section could be in a ro segment for example.

The bfd way of doing things is also strange for the case where a symbol
points to the empty section.

Now we match gold and what seems to be the intention of the spec.

llvm-svn: 251988
2015-11-03 22:08:08 +00:00
Rafael Espindola d7a267b84b Remove redundant = nullptr.
llvm-svn: 251987
2015-11-03 22:01:20 +00:00
Rafael Espindola 443f50a833 Create .bss only when needed.
This is a small complication, but produces nicer output and is a step to
handling zero size sections uniformly.

llvm-svn: 251980
2015-11-03 21:35:14 +00:00
Rafael Espindola d1ec682411 Update for llvm change.
llvm-svn: 251971
2015-11-03 20:02:28 +00:00
Rafael Espindola 7bb1adfd66 Avoid checking for irrelevant facts.
If the test is not for layout, it should not depend on the address for example.

llvm-svn: 251969
2015-11-03 19:56:47 +00:00
Rafael Espindola b8c3b1523f Fix thinko.
This would match SHF_ALLOC or SHF_TLS. We want both.

llvm-svn: 251939
2015-11-03 16:30:27 +00:00
Rafael Espindola 9eb3e57042 Simplify and fix style.
llvm-svn: 251927
2015-11-03 15:46:15 +00:00
Rafael Espindola 9b89608698 Remove a redundant boolean.
llvm-svn: 251921
2015-11-03 14:34:11 +00:00
Rafael Espindola 115f0f365d Two small fixes to copy relocation processing.
* We can determine the alignment requirement.
* We have to update the bss alignment with it.

llvm-svn: 251914
2015-11-03 14:13:40 +00:00
Rafael Espindola 31b71a921a Make the test a bit more strict and fix the math.
llvm-svn: 251913
2015-11-03 14:08:43 +00:00
Rafael Espindola e1bd952ea9 Simplify. NFC.
llvm-svn: 251912
2015-11-03 14:03:11 +00:00
Rafael Espindola f486beab7e Make this input a bit more readable.
llvm-svn: 251911
2015-11-03 13:58:27 +00:00
Rafael Espindola de212f1589 Delete dead getter.
llvm-svn: 251908
2015-11-03 13:36:38 +00:00
Michael J. Spencer 78aa1de3ae [elf2] Generate PT_TLS.
Differential Revision: http://reviews.llvm.org/D14167

llvm-svn: 251872
2015-11-03 00:34:39 +00:00
Rafael Espindola 31f8888cd9 Make a method static. NFC.
llvm-svn: 251799
2015-11-02 14:33:11 +00:00
Igor Kudrin 2169b1bd26 [ELF2] Ensure that .dynsym section is finalized before .gnu.hash.
It is required to fill up the GNU hash table section before its
finalize() method is called.

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

llvm-svn: 251789
2015-11-02 10:46:14 +00:00
George Rimar 0e8d1922c8 [ELF2] Revert of r251692
llvm-svn: 251782
2015-11-02 08:24:16 +00:00
George Rimar d98bcc713d Comments about how values were calculated for functions below were added.
1. X86_64TargetInfo::writePltZeroEntry.
2. X86_64TargetInfo::writePltEntry.

llvm-svn: 251692
2015-10-30 09:11:12 +00:00
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