Commit Graph

4434 Commits

Author SHA1 Message Date
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