Commit Graph

744 Commits

Author SHA1 Message Date
Rafael Espindola 8396f72f7b Simplify handling of mips gp* symbols.
Give them values instead of computing it during relocation.

llvm-svn: 265986
2016-04-11 20:34:27 +00:00
Rafael Espindola 03ef404e97 Simplify the creation of __rel[a]_iplt_{start,end}.
They can be regular DefinedSynthetic.

llvm-svn: 265981
2016-04-11 19:14:59 +00:00
Simon Atanasyan 2615c3846f [ELF] Do not skip relocation scanning checking if the symbol gets dynamic COPY relocation already
It is possible that the same symbol referenced by two kinds of
relocations at the same time. The first type requires say GOT entry
creation, the second type requires dynamic copy relocation. For MIPS
targets they might be R_MIPS_GOT16 and R_MIPS_HI16 relocations. For X86
target they might be R_386_GOT32 and R_386_32 respectively.

Now LLD never creates GOT entry for a symbol if this symbol already has
related copy relocation. This patch solves this problem.

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

llvm-svn: 265910
2016-04-10 21:48:55 +00:00
Rafael Espindola 8caf33c483 Cleanup the handling of MustBeInDynSym and IsUsedInRegularObj.
Now MustBeInDynSym is only true if the symbol really must be in the
dynamic symbol table.

IsUsedInRegularObj is only true if the symbol is used in a .o or -u. Not
a .so or a .bc.

A benefit is that this is now done almost entirilly during symbol
resolution. The only exception is copy relocations because of aliases.

This includes a small fix in that protected symbols in .so don't force
executable symbols to be exported.

This also opens the way for implementing internalize for -shared.

llvm-svn: 265826
2016-04-08 18:39:03 +00:00
Rui Ueyama d86ec30168 ELF: Add --build-id=sha1 option.
llvm-svn: 265748
2016-04-07 23:51:56 +00:00
Rui Ueyama 3a41be277a ELF: Implement --build-id=md5.
Previously, we supported only one hash function, FNV-1, so
BuildIdSection directly handled hash computation. In this patch,
I made BuildIdSection an abstract class and defined two subclasses,
BuildIdFnv1 and BuildIdMd5.

llvm-svn: 265737
2016-04-07 22:49:21 +00:00
Rafael Espindola 3828b88d86 Fix an use after free.
Thanks to asan for pointing it out that OutputSections was being
resized.

llvm-svn: 265686
2016-04-07 15:50:23 +00:00
Rafael Espindola 74031ba1e9 Simplify dynamic relocation creation.
The position of a relocation can always be expressed as an offset in an
output section.

llvm-svn: 265682
2016-04-07 15:20:56 +00:00
Rafael Espindola c012db35d7 Delete Off_Bss.
It is now just a special case of Off_Sec.

llvm-svn: 265676
2016-04-07 14:34:15 +00:00
Rafael Espindola 56004c577a Don't create dynamic relocs for discarded .eh_frame entries.
This requires knowing input section offsets in output sections before
scanRelocs. This is generally a good thing and should allow further
simplifications in the creation of dynamic relocations.

llvm-svn: 265673
2016-04-07 14:22:09 +00:00
Rafael Espindola f47657301b Change the type hierarchy for undefined symbols.
We have to differentiate undefined symbols from bitcode and undefined
symbols from other sources.

Undefined symbols from bitcode should not inhibit the symbol being
internalized. Undefined symbols from other sources should.

llvm-svn: 265536
2016-04-06 13:22:41 +00:00
George Rimar 7ca0627c51 [ELF] - Do not handle ELF and program header as dummy sections.
ELF and program header are not part of OutputSections list anymore.
That helps to avoid having and working with functions like dummySectionsNum().
Still keeping them as sections helps to simplify the code.

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

llvm-svn: 265522
2016-04-06 07:20:45 +00:00
Rafael Espindola 66a69ceed9 Make helper function static. NFC.
llvm-svn: 265501
2016-04-06 01:30:49 +00:00
Rafael Espindola f7085871fd Delete broken code.
A synthetic symbol can be global or local, and with the current
infrastructure we don't need any special code for it.

Fixes PR27228.

llvm-svn: 265478
2016-04-05 22:08:39 +00:00
Ed Schouten f2fdd013a2 Don't omit dynamic relocations for the GOT.
Where Clang's AArch64 backend seems to differ from the X86 backend is
that it tends to use the GOT more aggressively.

After getting CloudABI PIEs working on x86-64, I noticed that accessing
global variables would still crash on aarch64. Tracing it down, it turns
out that the GOT was filled with entries assuming the base address was
zero.

It turns out that we skip generating relocations for GOT entries in case
the relocation pointing towards the GOT is relative. Whether the thing
pointing to the GOT is absolute or relative shouldn't make any
difference; the GOT entry itself should contain the absolute address,
thus needs a relocation regardless.

Approved by:	rafael
Differential Revision:	http://reviews.llvm.org/D18739

llvm-svn: 265453
2016-04-05 20:17:33 +00:00
Rafael Espindola 0f7ccc3d92 Update for llvm change.
llvm-svn: 265404
2016-04-05 14:47:28 +00:00
Peter Collingbourne 4cdade6a2f ELF: Create dynamic symbols for symbol aliases of copy relocations.
For each copy relocation that we create, look through the DSO's symbol table
for aliases and create a dynamic symbol for each one. This causes the copy
relocation to correctly interpose any aliases.

Copy relocations are relatively uncommon (on my machine, 56% of binaries in
/usr/bin have no copy relocations probably due to being PIEs, 97% of them
have <10, and the binary with the largest number of them has 97) so it's
probably fine to do this in a relatively inefficient way.

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

llvm-svn: 265354
2016-04-04 22:29:24 +00:00
Rafael Espindola ccfe3cb3d6 Don't store an Elf_Sym for most symbols.
Our symbol representation was redundant, and some times would get out of
sync. It had an Elf_Sym, but some fields were copied to SymbolBody.

Different parts of the code were checking the bits in SymbolBody and
others were checking Elf_Sym.

There are two general approaches to fix this:
* Copy the required information and don't store and Elf_Sym.
* Don't copy the information and always use the Elf_Smy.

The second way sounds tempting, but has a big problem: we would have to
template SymbolBody. I started doing it, but it requires templeting
*everything* and creates a bit chicken and egg problem at the driver
where we have to find ELFT before we can create an ArchiveFile for
example.

As much as possible I compared the test differences with what gold and
bfd produce to make sure they are still valid. In most cases we are just
adding hidden visibility to a local symbol, which is harmless.

In most tests this is a small speedup. The only slowdown was scylla
(1.006X). The largest speedup was clang with no --build-id, -O3 or
--gc-sections (i.e.: focus on the relocations): 1.019X.

llvm-svn: 265293
2016-04-04 14:04:16 +00:00
Rui Ueyama 24d0d2f917 Merge two `if`s.
llvm-svn: 265241
2016-04-02 19:31:01 +00:00
Rafael Espindola 059f3fb8fb Don't create a plt when LD access is optimized.
llvm-svn: 265203
2016-04-02 00:19:22 +00:00
Rafael Espindola cf3b04dab9 Don't create a PLT when we optimize out the plt use.
llvm-svn: 265202
2016-04-01 23:36:56 +00:00
Rui Ueyama e8a45e48f9 Rename a few variables. NFC.
We had Phdr, PHdr and Phdrs in one line. That was a bit confusing.

llvm-svn: 265194
2016-04-01 22:42:04 +00:00
Rafael Espindola 36404d0030 Simplify if. NFC.
llvm-svn: 265166
2016-04-01 18:04:21 +00:00
George Rimar 687788c90e [ELF] - Split Writer::assignAddresses(): extract code for initializing dummies sections
Extracts code for initializing dummies sections
to avoid possible duplication in following patches.

Differential review: http://reviews.llvm.org/D18691

llvm-svn: 265159
2016-04-01 17:30:52 +00:00
Rui Ueyama f7f52ef65d Make error handling consistent.
Some functions in Writer reports error using HasError, and some reports
their return values. This patch makes them to consistently use HasError.

llvm-svn: 265156
2016-04-01 17:24:19 +00:00
Rui Ueyama 8ecc2ec0e3 Remove dead code.
Thanks to George Rimor for pointing it out.

llvm-svn: 265155
2016-04-01 17:17:14 +00:00
Rui Ueyama a63baf176f Don't do extra work if -r is given.
fixAbsoluteSymbols fixes linker-created symbol addresses. Since we don't
create such symbols for relocatable output, we don't need to call this
function.

llvm-svn: 265154
2016-04-01 17:11:42 +00:00
Rui Ueyama e044e9cf80 Tidy up address and file offset assignments in the Writer.
assignAddressesRelocatable function did not set addresses to sections
despite its name. What it actually did is to set file offsets to sections.
assignAddresses function assigned addresses and file offsets to sections.
So there was a confusion what they were doing, and they had duplicate code.

This patch separates file offset assignments from address assignments.
A new function, assignFileOffsets assign file offsets. assignAddresses
do not care about file offsets anymore.

llvm-svn: 265151
2016-04-01 17:07:17 +00:00
Rafael Espindola 790db9c458 Bring r264761 back with an extra fix.
The extra fix is to note that it still requires copy relocations.

Original message:

Change how we handle R_MIPS_LO16.

Mips aligns PT_LOAD to 16 bits (0x10000). That means that the lower 16
bits are always the same, so we can, effectively, say that the
relocation is relative.

P.S.: Suggestions for a better name for the predicate are welcome :-)

llvm-svn: 265150
2016-04-01 17:00:36 +00:00
Rafael Espindola 31d2ada6d5 Refactor duplicated code.
We had almost identical code to handle creating a plt entry in two
places.

llvm-svn: 265142
2016-04-01 14:14:48 +00:00
Rafael Espindola b97f4beec4 Avoid creating duplicated relocations.
llvm-svn: 265139
2016-04-01 12:54:27 +00:00
George Rimar 5a5c39ca2a Fix linux buildbot after r265136
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/20138

Fix: Move method above class that uses it.
Works fine with MSVS.

llvm-svn: 265137
2016-04-01 12:24:28 +00:00
George Rimar e2da42a762 Make dummySectionsNum() to be not a member of writer. NFC.
llvm-svn: 265136
2016-04-01 11:59:32 +00:00
George Rimar b345e0d15c Split Writer::assignAddresses(): extract common code to fixFileOff(). NFC.
llvm-svn: 265131
2016-04-01 11:04:47 +00:00
George Rimar 900a260357 Split Writer::assignAddresses(): extract assignPhdrs(). NFC.
llvm-svn: 265130
2016-04-01 10:49:14 +00:00
George Rimar efded31a61 [ELF] - Move calculation of _end to fixAbsoluteSymbols()
That is consistent with other symbols: _edata, _etext
and can help to avoid duplicate code.

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

llvm-svn: 265129
2016-04-01 10:23:32 +00:00
Simon Atanasyan 13f6da1d2c [ELF] Implement infrastructure for thunk code creation
Some targets might require creation of thunks. For example, MIPS targets
require stubs to call PIC code from non-PIC one. The patch implements
infrastructure for thunk code creation and provides support for MIPS
LA25 stubs. Any MIPS PIC code function is invoked with its address
in register $t9. So if we have a branch instruction from non-PIC code
to the PIC one we cannot make the jump directly and need to create a small
stub to save the target function address.
See page 3-38 ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

- In relocation scanning phase we ask target about thunk creation necessity
by calling `TagetInfo::needsThunk` method. The `InputSection` class
maintains list of Symbols requires thunk creation.

- Reassigning offsets performed for each input sections after relocation
scanning complete because position of each section might change due
thunk creation.

- The patch introduces new dedicated value for DefinedSynthetic symbols
DefinedSynthetic::SectionEnd. Synthetic symbol with that value always
points to the end of the corresponding output section. That allows to
escape updating synthetic symbols if output sections sizes changes after
relocation scanning due thunk creation.

- In the `InputSection::writeTo` method we write thunks after corresponding
input section. Each thunk is written by calling `TargetInfo::writeThunk` method.

- The patch supports the only type of thunk code for each target. For now,
it is enough.

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

llvm-svn: 265059
2016-03-31 21:26:23 +00:00
Simon Atanasyan cf8c42f546 [ELF][MIPS] Revert r264761 and add test case to demonstrate the problem
If we make R_MIPS_LO16 a relative relocation, linker:
- never creates R_MIPS_COPY relocation for it
- attempts to create R_MIPS_REL32 dynamic relocation if R_MIPS_LO16's
  target is a preemptible symbol

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

llvm-svn: 264956
2016-03-30 22:43:14 +00:00
Rui Ueyama 4709190376 Split Writer::assignAddresses. NFC.
llvm-svn: 264905
2016-03-30 19:41:51 +00:00
George Rimar f1c0bf5b40 [ELF] - Do not keep undefined locals in .symtab
gold and bfd do not include the undefined locals in symtab.
We have no reasons to support that either.

That fixes PR27016

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

llvm-svn: 264843
2016-03-30 08:16:11 +00:00
Rafael Espindola cba3e8b4b5 Change how we handle R_MIPS_LO16.
Mips aligns PT_LOAD to 16 bits (0x10000). That means that the lower 16
bits are always the same, so we can, effectively, say that the
relocation is relative.

llvm-svn: 264761
2016-03-29 18:18:19 +00:00
Rafael Espindola 5432287bad Make needsPlt a plain function instead of a template.
llvm-svn: 264267
2016-03-24 12:55:27 +00:00
Rafael Espindola 26d239c293 Skip some relocations in scanRelocs.
When a tls access is optimized, a group of relocations is converted at a
time.

We were already skipping relocations that were optimized out in
relocate, but not in scanRelocs.

This is a small optimization. I got here while working on a patch that
will always keep scanRelocs and relocate in sync.

llvm-svn: 264048
2016-03-22 13:24:29 +00:00
Simon Atanasyan f3ec3be178 [ELF][MIPS] Delete GotSection::addMipsLocalEntry method
Now local symbols have SymbolBody so we can handle all kind of symbols
in the GotSection::addEntry method. The patch moves the code from
addMipsLocalEntry to addEntry. NFC.

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

llvm-svn: 264032
2016-03-22 08:36:48 +00:00
Rafael Espindola 69082f051d Revert "bar"
This reverts commit r263799.
It was a mistake. Sorry about that.

llvm-svn: 263801
2016-03-18 18:11:26 +00:00
Rafael Espindola c2cfd9fa34 bar
llvm-svn: 263799
2016-03-18 18:09:32 +00:00
George Rimar 786e866fea [ELF] - -pie/--pic-executable option implemented
-pie
--pic-executable

Create a position independent executable.  This is currently only
 supported on ELF platforms.  Position independent executables are
 similar to shared libraries in that they are relocated by the
 dynamic linker to the virtual address the OS chooses for them
 (which can vary between invocations).  Like normal dynamically
 linked executables they can be executed and symbols defined in the
 executable cannot be overridden by shared libraries.

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

llvm-svn: 263693
2016-03-17 05:57:33 +00:00
Rui Ueyama 9328b2cdde Use ELFT instead of ELFFile<ELFT>.
llvm-svn: 263510
2016-03-14 23:16:09 +00:00
Rui Ueyama f50e1d8358 Make getAlignment a non-member function. NFC.
This function did not rely on Writer class.

llvm-svn: 263502
2016-03-14 22:41:08 +00:00
Rui Ueyama cc232d1f90 Simplify. NFC.
llvm-svn: 263398
2016-03-13 22:08:11 +00:00
Rui Ueyama 98a4b8b05c Remove a local variable. NFC.
llvm-svn: 263389
2016-03-13 20:18:12 +00:00
Simon Atanasyan 0295bb42c0 [ELF][MIPS] Use TargetInfo::needsGot call to check necessity of GOT for local symbols. NFC.
llvm-svn: 263388
2016-03-13 20:13:24 +00:00
Rui Ueyama 6c5638b01a ELF: Add `Rela` member variable to Config.
The member is true if we want to create relocatin sections with RELA
instead of REL.

llvm-svn: 263387
2016-03-13 20:10:20 +00:00
Rui Ueyama c4466605d8 ELF: Redefine canBeDefined as a member function of SymbolBody.
We want to make SymbolBody the central place to query symbol information.
This patch also renames canBePreempted to isPreemptible because I feel that
the latter is slightly better (the former is three words and the latter
is two words.)

llvm-svn: 263386
2016-03-13 19:48:18 +00:00
Rui Ueyama 22b5d1f901 ELF: Set e_flags header only when MIPS.
The field is zero by default, so this is NFC.

llvm-svn: 263385
2016-03-13 19:29:17 +00:00
Rui Ueyama fc467e77b8 Use RelTy instead of Elf_Rel_Impl<ELFT, isRela> for readability.
llvm-svn: 263368
2016-03-13 05:06:50 +00:00
Rui Ueyama 7ede54310a Redefine isGnuIfunc as a member function of SymbolBody.
llvm-svn: 263365
2016-03-13 04:40:14 +00:00
Rui Ueyama cb8fd3ac68 Body can never be null in this context.
Because of the recent commit to allocate SymbolBodies for local symbols.

llvm-svn: 263364
2016-03-13 04:40:12 +00:00
Rui Ueyama 6eafa7fb23 Do not return a bool value from error().
error returned true if there was an error. This allows us to replace
the code like this

  if (EC) {
    error(EC, "something failed");
    return;
  }

with

  if (error(EC, "something failed"))
    return;

I thought that that was a good idea, but it turned out that we only
have two places to use this pattern. So this patch removes that feature.

llvm-svn: 263362
2016-03-13 04:25:41 +00:00
Rui Ueyama b30f73568f The difference of getBss() and Out<ELFT>::Bss is subtle, so remove that function.
llvm-svn: 263361
2016-03-13 04:11:53 +00:00
Rui Ueyama a969218f91 Split addCopyRelSymbols. NFC.
llvm-svn: 263360
2016-03-13 04:05:42 +00:00
Rui Ueyama 28286cdfc7 ELF: Include the build ID section in the first page.
At least Linux has the kernel configuration to include the first page
of the executable into core files. We want build ID section to be
included in core files to identify them.

Here is the link to the description about the kernel configuration.

097f70b3c4/fs/Kconfig.binfmt (L46)

llvm-svn: 263351
2016-03-13 01:54:48 +00:00
Rui Ueyama 634ddf0bec ELF: Implement --build-id.
This patch implements --build-id. After the linker creates an output file
in the memory buffer, it computes the FNV1 hash of the resulting file
and set the hash to the .note section as a build-id.

GNU ld and gold have the same feature, but their default choice of the
hash function is different. Their default is SHA1.

We made a deliberate choice to not use a secure hash function for the
sake of performance. Computing a secure hash is slow -- for example,
MD5 throughput is usually 400 MB/s or so. SHA1 is slower than that.

As a result, if you pass --build-id to gold, then the linker becomes about
10% slower than that without the option. We observed a similar degradation
in an experimental implementation of build-id for LLD. On the other hand,
we observed only 1-2% performance degradation with the FNV hash.

Since build-id is not for digital certificate or anything, we think that
a very small probability of collision is acceptable.

We considered using other signals such as using input file timestamps as
inputs to a secure hash function. But such signals would have an issue
with build reproducibility (if you build a binary from the same source
tree using the same toolchain, the build id should become the same.)

GNU linkers accepts --build-id=<style> option where style is one of
"MD5", "SHA1", or an arbitrary hex string. That option is out of scope
of this patch.

http://reviews.llvm.org/D18091

llvm-svn: 263292
2016-03-11 20:51:53 +00:00
Rui Ueyama 6b074f5c9f Fix MSVC build.
llvm-svn: 263277
2016-03-11 18:56:05 +00:00
Rafael Espindola 2230483812 Now that it is trivial, fix pr26878.
llvm-svn: 263271
2016-03-11 18:33:48 +00:00
Rafael Espindola 7862097a45 Yet more MSVC fixes.
llvm-svn: 263253
2016-03-11 16:41:23 +00:00
Rafael Espindola 36a73d2deb More MSVC fixes.
llvm-svn: 263251
2016-03-11 16:32:46 +00:00
Rafael Espindola 5d57fb823b Don't invent names for STT_SECTION symbols.
We should just copy the symbol names with -r.

llvm-svn: 263244
2016-03-11 14:57:33 +00:00
George Rimar 5761042db7 This reverts the r263125
It was discussed to make all messages be 
lowercase to be consistent with clang.
(also reverts the r263128 which fixed 
build bot fail after r263125)

Original commit message:
[ELF] - Consistent spelling for error/warning messages

Previously error and warnings were not consistent in lld.
Some of them started from lowercase letter, others from
uppercase. Also there was one or two which had a dot at the end.
This patch changes all messages to start from uppercase letter if
they were not before.

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

llvm-svn: 263240
2016-03-11 14:43:02 +00:00
Rafael Espindola 1f5b70f64f Represent local symbols with DefinedRegular.
llvm-svn: 263237
2016-03-11 14:21:37 +00:00
Rafael Espindola 4e90611ed2 Remove a redundant cast.
llvm-svn: 263230
2016-03-11 13:17:15 +00:00
Rafael Espindola ccb8b4d4fe Remember the input section of locals.
This is already a simplification, but will allow much more.

llvm-svn: 263224
2016-03-11 12:14:02 +00:00
Rafael Espindola 67d72c02bc Create a SymbolBody for locals.
pr26878 shows a case where locals have to be in the got.

llvm-svn: 263222
2016-03-11 12:06:30 +00:00
Rui Ueyama 17d6983a4e Rename MaxAlignment -> Alignment.
We can argue about a maximum alignment of a group of symbols,
but for each symbol, there is only one alignment.
So it is a bit weird that each symbol has a "maximum alignment".

llvm-svn: 263151
2016-03-10 18:58:53 +00:00
George Rimar e094388861 [ELF] - Consistent spelling for error/warning messages
Previously error and warnings were not consistent in lld.
Some of them started from lowercase letter, others from
uppercase. Also there was one or two which had a dot at the end.
This patch changes all messages to start from uppercase letter if
they were not before.

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

llvm-svn: 263125
2016-03-10 16:58:34 +00:00
Rafael Espindola e090fb2891 ELF: Remove non-standard ELF features from AMDGPU target.
Patch by Tom Stellard!

llvm-svn: 263063
2016-03-09 21:37:22 +00:00
Rafael Espindola e02f4dfb9e Remove an unnecessary hack.
It doesn't look like anything is depending on using local dynamic tls
relocations with preemptable  symbols.

llvm-svn: 262957
2016-03-08 21:17:31 +00:00
Rafael Espindola 1f04c44885 Delete isTlsDynRel.
It was a badly specified hack for when a tls relocation should be
propagated to the dynamic relocation table.

This replaces it with a not as bad hack of saying that a local dynamic
tls relocation is never preempted.

I will try to remove even that second hack in the next patch.

llvm-svn: 262955
2016-03-08 20:24:36 +00:00
Rui Ueyama 3f9f09265b ELF: Rename NoInhibitExec -> NoinhibitExec.
The variables corresponding to command line options are named mechanically.
Because the option for the variable is -noinhibit-exec and not -no-inhibit-exec,
it should be name this way.

llvm-svn: 262911
2016-03-08 04:06:29 +00:00
Rafael Espindola e711fc3767 Adjust the .bss alignment to include common symbols.
llvm-svn: 262840
2016-03-07 17:43:39 +00:00
George Rimar 2f0fab53e4 [ELF] - Simplify a SymbolBody class interface a bit.
Get rid of few accessors in that class, and replace
them with direct fields access.

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

llvm-svn: 262796
2016-03-06 06:26:18 +00:00
George Rimar 98b060d228 [ELF] - Use the uint32_t instead of unsigned in Target class for relocations types
Patch changes all relocations types to be uint32_t and also 
fixes some dependent inconsistency in callers code.

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

llvm-svn: 262793
2016-03-06 06:01:07 +00:00
Rafael Espindola d405f4721c Refactor target independent code.
The rules for when we can relax tls relocations are target independent.
The only things that are target dependent are the relocation values.

llvm-svn: 262748
2016-03-04 21:37:09 +00:00
Rui Ueyama d4530c6eb8 Add a comment about _DYNAMIC.
llvm-svn: 262735
2016-03-04 18:34:14 +00:00
Davide Italiano 255730cdc5 [ELF] Generalize symbol type handling.
SymbolBody constructor and friends take isFunc and isTLS boolean arguments.
ELF symbols have already a type so than be easily passed as argument.
If we want to support another type, this scheme is not good enough, that is,
the current code logic would require passing another `bool isObject` around.
Up to two argument, this stretching exercise was a little bit goofy but
still acceptable, but with more types to support, is just too much, IMHO.

Change the code so that the type is passed instead.

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

llvm-svn: 262684
2016-03-04 01:55:28 +00:00
Rafael Espindola 75714f618c Rename 'fatal' to 'check' when it doesn't always fail.
llvm-svn: 262666
2016-03-03 22:24:39 +00:00
George Rimar e5960ceb6b [ELF] - Do not allow .bss to occupy the file space when producing relocatable output
When generating relocatable output SHT_NOBITS sections
were still occupy the file space.

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

llvm-svn: 262650
2016-03-03 20:24:14 +00:00
Rafael Espindola 1130935c4a Simplify error handling.
This makes fatal return T when there is no error. This avoids the need
for quite a few temporaries.

llvm-svn: 262626
2016-03-03 16:21:44 +00:00
George Rimar 4cfe572932 [ELF] - add support for relocations against local symbols when producing relocatable output.
There was a known limitation for -r option:
relocations against local symbols were not supported. 
For example rel[a].eh_frame sections contained relocations against sections
and that was not supported for -r before. Patch fixes that.

Differential review: http://reviews.llvm.org/D17813

llvm-svn: 262590
2016-03-03 07:49:35 +00:00
George Rimar 2abc587c1e [ELF] - More direct implementation of edata/etext
As was suggested in mails, this patch implements edata/etext
symbols in a more direct way.
It iterates through PT_LOADs.

Result seems to be the same and equal to gold output.

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

llvm-svn: 262369
2016-03-01 19:18:07 +00:00
George Rimar c1034a85d0 [ELF] - do not create special symbols when creating relocatable output
__start_/__end_ <section-name> symbols and other specials like:
preinit_array_start/end
init_array_start/end
fini_array_start/end

should not be created by linker when creating relocatable files.

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

llvm-svn: 262366
2016-03-01 19:12:35 +00:00
George Rimar aa4dc20f09 [ELF] - Create _DYNAMIC symbol for dynamic output
lld needs to provide _DYNAMIC symbol when creating a shared library
both bfd and gold do that.

This should fix the https://llvm.org/bugs/show_bug.cgi?id=26732

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

llvm-svn: 262348
2016-03-01 16:23:13 +00:00
Rafael Espindola 9907eb0b0a Produce PT_NOTE program headers.
llvm-svn: 262331
2016-03-01 13:23:29 +00:00
George Rimar 6de3f63bb0 [ELF] use of already declared reference instead of indirect access to fields. NFC.
llvm-svn: 262315
2016-03-01 08:46:03 +00:00
Rafael Espindola e0df00b91f Rename elf2 to elf.
llvm-svn: 262159
2016-02-28 00:25:54 +00:00
Rafael Espindola 18f0950783 Report duplicated symbols in bitcode.
llvm-svn: 262076
2016-02-26 21:49:38 +00:00
Rui Ueyama 68e15559b8 Fix broken buildbots.
llvm-svn: 262034
2016-02-26 16:49:54 +00:00
Rui Ueyama 4d169bdca2 Simplify. NFC.
Regarding the comment, it is out of context because it describes
what it does not do there. It got too long because it was originally
two different comments that were simply merged together.
The semantics is described in fixAbsoluteSymbols, so we don't need it.

llvm-svn: 262031
2016-02-26 16:38:39 +00:00
George Rimar 9e8593949d Description of symbols is avalable here:
https://docs.oracle.com/cd/E53394_01/html/E54766/u-etext-3c.html

It is said that:
_etext - The address of _etext is the first 
location after the last read-only loadable segment.

_edata - The address of _edata is the first 
location after the last read-write loadable segment.

_end - If the address of _edata is greater than the address 
of _etext, the address of _end is same as the address of _edata.

In real life _end and _edata has different values for that case.
Both gold/bfd set _edata to the end of the last non SHT_NOBITS section.
This patch do the same for consistency.

It should fix the https://llvm.org/bugs/show_bug.cgi?id=26729.

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

llvm-svn: 262019
2016-02-26 14:36:36 +00:00
Rafael Espindola a350e266aa Refactor multiple calls to canBePreempted.
llvm-svn: 262018
2016-02-26 14:33:23 +00:00
Rafael Espindola 993f0273e3 Fix some confusion about what can be preempted.
For shared libraries we allow any weak undefined symbol to eventually be
resolved, even if we never see a definition in another .so. This matches
the behavior when handling other undefined symbols in a shared library.

For executables, we require seeing a definition in a .so or resolve it
to zero. This is also similar to how non weak symbols are handled.

llvm-svn: 262017
2016-02-26 14:27:47 +00:00
Rui Ueyama ad59b65f18 ELF: Add '*' to auto.
llvm-svn: 261941
2016-02-25 23:58:21 +00:00
Rui Ueyama a354c5c433 ELF: Create MIPS .rld_map section earlier.
This is the usual way of instantiating a globally-visible section.

llvm-svn: 261938
2016-02-25 23:54:49 +00:00
Rui Ueyama 3095148015 ELF: Split Writer::addPredefiendSections. NFC.
llvm-svn: 261924
2016-02-25 19:34:37 +00:00
Rui Ueyama 4cea4e81d4 ELF: Split Writer::writeHeader. NFC.
llvm-svn: 261923
2016-02-25 19:28:37 +00:00
George Rimar 12737b7f72 [ELF] - Referencing __start or __stop should keep the section from GC.
This fixes the https://llvm.org/bugs/show_bug.cgi?id=22906 bug.

In GNU Binutils, a reference to start or stop is sufficient to 
prevent the section from being garbage collected.
Patch implements the same behavior for lld.

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

llvm-svn: 261840
2016-02-25 08:40:26 +00:00
George Rimar 58941ee12a [ELF2] - Basic implementation of -r/--relocatable
-r, -relocatable - Generate relocatable output

Currently does not have support for files containing 
relocation sections with entries that refer to local 
symbols (like rel[a].eh_frame which refer to sections
and not to symbols)

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

llvm-svn: 261838
2016-02-25 08:23:37 +00:00
Rui Ueyama 733153de3c ELF: Do not instantiate InputSectionBase::Discarded.
"Discarded" section is a marker for discarded sections, and we do not
use the instance except for checking its identity. In that sense, it
is just another type of a "null" pointer for InputSectionBase. So,
it doesn't have to be a real instance of InputSectionBase class.

In this patch, we no longer instantiate Discarded section but instead
use -1 as a pointer value. This eliminates a global variable which
needed initialization at startup.

llvm-svn: 261761
2016-02-24 18:33:35 +00:00
Rafael Espindola 795dc5a0fb Move target independent code out of x86_64 only path.
The logic for deciding if an undefined symbol should have the value of a
got entry is not target specific.

llvm-svn: 261760
2016-02-24 18:24:23 +00:00
Rui Ueyama 8fc070d64d ELF: Remove InputSectionBase::isLive and use Live member instead. NFC.
This is also a preparation for ICF.

llvm-svn: 261711
2016-02-24 00:23:15 +00:00
Rafael Espindola 435c00f39c Fix the aarch64 logic for dynamic relocations.
There is nothing aarch64 specific in here. If a symbol can be preempted,
we need to copy the full relocation to the dynamic linker.

If a symbol cannot be preempted, we can make the dynamic linker life
easier and produce a relative relocation.

This is directly equivalent to R_X86_64_64 to R_x86_64_RELATIVE
conversion.

llvm-svn: 261678
2016-02-23 20:19:44 +00:00
Rafael Espindola f7ae359d2c Simplify. NFC.
llvm-svn: 261668
2016-02-23 18:53:29 +00:00
Rafael Espindola 75baf09be5 Don't include tbss's alignment in offset.
The .tbss section is in the middle of a PT_LOAD. Whatever treatment we
give to its address we must also give to the offset.

We were ignoring it for address computations, but not for offset.

Fixes pr26712.

llvm-svn: 261667
2016-02-23 18:39:55 +00:00
Adhemerval Zanella 668ad0ffcb [lld] [ELF/AArch64] Fix R_AARCH64_ABS64 in Shared mode
This patch fixes the R_AARCH64_ABS64 relocation when used in shared mode,
where it requires a dynamic R_AARCH64_RELATIVE relocation. To correct set
the addend on the dynamic relocation (since it will be used by the dynamic
linker), a new TargetInfo specific hook was created (getDynRelativeAddend)
to get the correct addend based on relocation type.

The patch fixes the issues when creating shared library code against
{init,fini}_array, where it issues R_AARCH64_ABS64 relocation against
local symbols.

llvm-svn: 261651
2016-02-23 16:54:40 +00:00
Rafael Espindola 5e8b54afdb Remove a trivial getter.
llvm-svn: 261590
2016-02-22 23:16:05 +00:00
Rafael Espindola 56da313e86 Correctly handle two gd relocations to the same symbol.
Fixes PR26676.

llvm-svn: 261561
2016-02-22 19:57:55 +00:00
Rafael Espindola 7efa5be205 Add support for merging strings with alignment larger than one char.
This reduces the .rodata of scyladb from 4501932 to 4334639 bytes (1.038
times smaller).

I don't think it is critical to support tail merging, just exact
duplicates, but given the code organization it was actually a bit easier
to support both.

llvm-svn: 261327
2016-02-19 14:17:40 +00:00
Rui Ueyama 874e7aee29 Split SymbolTableSection::writeGlobalSymbols.
Previously, we added garbage-collected symbols to the symbol table
and filter them out when we were writing symbols to the file. In
this patch, garbage-collected symbols are filtered out from beginning.

llvm-svn: 261064
2016-02-17 04:56:44 +00:00
Rafael Espindola f8b8b7b5d0 Don't create multiple .got.plt entries for the same symbol.
We were doing it for ifunc symbols.

llvm-svn: 260980
2016-02-16 16:46:31 +00:00
Rafael Espindola 8ae1290058 Merge multiple tdata.* into a single section.
llvm-svn: 260977
2016-02-16 16:12:06 +00:00
Rafael Espindola 1492820aaa Merge multiple .gcc_except_table.* into a single section.
llvm-svn: 260976
2016-02-16 16:05:27 +00:00
Rafael Espindola b032aa1b2b Merge multiple .tbss.* sections into one output section.
llvm-svn: 260974
2016-02-16 15:57:07 +00:00
Rui Ueyama 1ebc8ed78a ELF: Add wildcard pattern matching to SECTIONS linker script command.
Each rule in SECTIONS commands is something like ".foo *(.baz.*)",
which instructs the linker to collect all sections whose name matches
".baz.*" from all files and put them into .foo section.

Previously, we didn't recognize the wildcard character. This patch
adds that feature.

Performance impact is a bit concerning because a linker script can
contain hundreds of SECTIONS rules, and doing pattern matching against
each rule would be too expensive. We could merge all patterns into
single DFA so that it takes O(n) to the input size. However, it is
probably too much at this moment -- we don't know whether the
performance of pattern matching matters or not. So I chose to
implement the simplest algorithm in this patch. I hope this simple
pattern matcher is sufficient.

llvm-svn: 260745
2016-02-12 21:47:28 +00:00
Rafael Espindola 852860e920 make needsPlt a pure predicate.
llvm-svn: 260685
2016-02-12 15:47:37 +00:00
Rui Ueyama 5af8368f8b ELF: Implement the correct semantics of .[cd]tors.
As I noted in the comment, the sorting order of .[cd]tors are
different from .{init,fini}_array's.

http://reviews.llvm.org/D17120

llvm-svn: 260620
2016-02-11 23:41:38 +00:00
Rui Ueyama 717677af35 ELF: Create LinkerScript class to move code out of Writer.
Previously, we had code for linker scripts in Writer. This patch
separates that as LinkerScript class. The class provides a few
functions to query linker scripts and is also a container of some
linker-script-specific information.

Hopefully, Writer will only implement the default behavior and let
the new class handle gotchas regarding linker scripts.

llvm-svn: 260591
2016-02-11 21:17:59 +00:00
George Rimar 2960c9867a [ELF] - Remove R_X86_64_GOTTPOFF from static relocation processing
R_X86_64_TPOFF64 is a dynamic relocation,
it should not appear in static relocation processing.
Patch fixes it.

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

llvm-svn: 260508
2016-02-11 11:14:46 +00:00
Rui Ueyama 6f46de21e1 ELF: Sort .[cd]tors by priority as we do for .{init,fini}_array.
llvm-svn: 260477
2016-02-11 01:07:19 +00:00
Rui Ueyama c2dca5d76e Reduce code repetition. NFC.
llvm-svn: 260476
2016-02-11 01:07:18 +00:00
Rafael Espindola ef762f2639 Don't include NOBITS TLS in PT_LOAD.
They don't count for the memory or file size, so this is mostly just a
simplification.

The only noticeable difference should be fewer empty program headers.

llvm-svn: 260465
2016-02-10 23:29:38 +00:00
Rui Ueyama c418570db5 ELF: Implement __attribute__((init_priority(N)) support.
llvm-svn: 260460
2016-02-10 23:20:42 +00:00
Rafael Espindola 4fc6044a5e Split the creation of program headers in a few steps.
IMHO this makes the code easier to read and should help with linker
scripts.

This is strongly based on D16575. The main differences are:

We record a range of sections, not every section in a program header.

scanHeaders takes case of deciding what goes in every program header,
including PT_GNU_RELRO

We create dummy sections for the start of the file

With this, program header creation has 3 isolated stages:

Map sections to program headers.
Assign addresses to *sections*
Looking at sections find the address and size of each program header.

Thanks to George Rimar for the initial version.

llvm-svn: 260453
2016-02-10 22:43:13 +00:00
Rafael Espindola a0a65f973a Use the plt entry as the address of some symbols.
This is the function equivalent of a copy relocation.

Since functions are expected to change sizes, we cannot use copy
relocations. In situations where one would be needed, what is done
instead is:
* Create a plt entry
* Output an undefined symbol whose addr is the plt entry.

The dynamic linker makes sure any shared library uses the plt entry as
the function address.

llvm-svn: 260224
2016-02-09 15:11:01 +00:00
Rafael Espindola a64f7d1148 Fix the alignment of PT_PHDR.
We were claiming it was aligned to 8 bytes even on 32 bit files, which
is not the case.

llvm-svn: 260102
2016-02-08 15:33:53 +00:00
Simon Atanasyan b76108a63a [ELF][MIPS] Add comments to describe __gnu_local_gp magic symbol
NFC. Follow-up to r259781.

llvm-svn: 260027
2016-02-07 12:09:40 +00:00
Rafael Espindola d0078b2dba Sort headers. NFC.
llvm-svn: 259959
2016-02-06 00:06:26 +00:00
Rafael Espindola 95708931cf Fix PT_GNU_RELRO computation.
We were not including TLS sections.

llvm-svn: 259945
2016-02-05 22:55:06 +00:00
Rui Ueyama 4197a6ab1b ELF: Make Out<ELFT> initialization less error-prone.
Previously, it was easy to leave some Out<ELFT> fields uninitialized
because assignments to the fields are mixed with output section
instantiations. In this patch, I separate initializations from assignments
to improve readability.

http://reviews.llvm.org/D16864

llvm-svn: 259899
2016-02-05 18:41:40 +00:00
Rafael Espindola abebed982a Rename IsUsedInDynamicReloc to MustBeInDynSym.
The variable was marking various cases where a symbol must be included
in the dynamic symbol table. Being used by a dynamic relocation was only
one of them.

llvm-svn: 259889
2016-02-05 15:27:15 +00:00
Rafael Espindola d30eb7d77d Centralize most calls to setUsedInDynamicReloc.
llvm-svn: 259887
2016-02-05 15:03:10 +00:00
Rui Ueyama 0e53c7dd2c ELF: Make names for TLS module indices shorter.
The previous names contained "Local" and "Current", but what we
are handling is always local and current, so they were redundant.

TlsIndex comes from "tls_index" struct that Ulrich Drepper is using
in this document to describe this data structure in GOT.

llvm-svn: 259852
2016-02-05 00:10:02 +00:00
Rui Ueyama f9cec37880 Merge conditions of two nested `if`s.
llvm-svn: 259843
2016-02-04 23:18:22 +00:00
Rafael Espindola de9857e3c1 Avoid code duplication when creating dynamic relocations.
Another case where we currently have almost duplicated code is the
creation of dynamic relocations. First to decide if we need one, then to
decide what to write.

This patch fixes it by passing more information from the relocation scan
to the section writing code. This is the same idea used for r258723.

I actually think it should be possible to simplify this further by
reordering things a bit in the writer. For example, we should be able to
represent almost every position in the file with an OutputSeciton and
offset. When writing it out we then just need to add the offset to the
OutputSection VA.

llvm-svn: 259829
2016-02-04 21:33:05 +00:00
Simon Atanasyan 597df21eb2 [ELF][MIPS] Add handling for __gnu_local_gp symbol
This symbol is a "fake" symbol like "_gp_disp" and denotes
the GOT + 0x7FF0 value.

llvm-svn: 259781
2016-02-04 12:09:49 +00:00
Simon Atanasyan 4b03451cac [ELF][MIPS] Replace needsMipsLocalGot function by canBePreempted
Symbol does not need an entry i the 'global' part of GOT if it cannot be
preempted. So canBePreempted fully satisfies us at least for now.

llvm-svn: 259779
2016-02-04 11:51:45 +00:00
Simon Atanasyan 170356ba32 [ELF][MIPS] Always create global GOT entry for symbols defined in DSO
If relocation against symbol requires GOT entry creation and this symbol
is defined in DSO, the GOT entry should be created in the 'global' part
of the GOT even if we link executable file. Also we do not need to create
a dynamic symbol table entry for global symbol corresponding to the
local GOT entry.

llvm-svn: 259778
2016-02-04 11:51:39 +00:00
Rui Ueyama cbe392629b ELF: Do not exit if it cannot open an output file.
It can fail to open an output file for various reasons, including
lack of permission, too long filename, or the output file is not
a mmap'able file.

llvm-svn: 259596
2016-02-02 22:48:04 +00:00
Rafael Espindola 0df1b0bf42 Expand comment a bit.
I have spent some time prototyping this idea. While it seems to work, I
now think it is probably not worth it.

llvm-svn: 259516
2016-02-02 15:45:37 +00:00
Simon Atanasyan 40d25f3358 [ELF] Finalize .dynamic section at the end
Some dynamic table tags like RELSZ and PLTRELSZ depens on result of
finalizing corresponding relocation sections. Therefore we have to
finalize .dynamic section at the end.

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

llvm-svn: 259478
2016-02-02 09:07:47 +00:00
Rui Ueyama 82b4288b1a ELF: Simplify and add comments.
llvm-svn: 259474
2016-02-02 07:50:18 +00:00
Rui Ueyama 05aecba118 Do not use "No" prefix for boolean variables to make it simpler. NFC.
llvm-svn: 259472
2016-02-02 07:18:15 +00:00
Rui Ueyama f263c4b0f1 ELF: Move GOT relocation handler code to one place. NFC.
llvm-svn: 259471
2016-02-02 07:07:35 +00:00
Rui Ueyama 554f273b9d ELF: Move PLT relocation handler to one place. NFC.
llvm-svn: 259470
2016-02-02 07:07:34 +00:00
Rui Ueyama 343f7e5d8d ELF: Move GNU_IFUNC relocation handler to one place. NFC.
llvm-svn: 259468
2016-02-02 06:29:10 +00:00
Rui Ueyama 6d3874b995 ELF: Move copy relocation handler to one place. NFC.
llvm-svn: 259467
2016-02-02 06:08:08 +00:00
Rui Ueyama 1ac1338ac8 ELF: Move code for MIPS local GOT entries to one place. NFC.
llvm-svn: 259466
2016-02-02 05:55:28 +00:00
Rui Ueyama cdb7882cb2 Always initialize Out<ELFT> members.
Instead of leave unused fields as is, set them to nullptr.
Currnetly this is NFC, but if you call writeResults more than
once, you should be able to see the difference.

llvm-svn: 259444
2016-02-02 00:35:49 +00:00
Rui Ueyama 21923996f8 ELF: Do not call fatal() if relocation contraints are not satisfied.
http://reviews.llvm.org/D16648

llvm-svn: 259435
2016-02-01 23:28:21 +00:00
Rafael Espindola 4d91f7fc25 Simplify.
Now that we remember the StringRefs when they are first added, we can
write the table in any order.

llvm-svn: 259417
2016-02-01 21:52:00 +00:00
Rui Ueyama b5a6970ace ELF: Teach SymbolBody about how to get its addresses.
Previously, the methods to get symbol addresses were somewhat scattered
in many places. You can use getEntryAddr returns the address of the symbol,
but if you want to get the GOT address for the symbol, you needed to call
Out<ELFT>::Got->getEntryAddr(Sym). This change adds new functions, getVA,
getGotVA, getGotPltVA, and getPltVA to SymbolBody, so that you can use
SymbolBody as the central place to ask about symbols.

http://reviews.llvm.org/D16710

llvm-svn: 259404
2016-02-01 21:00:35 +00:00
Rui Ueyama 5e378ddc1e Consistenly use sizeof(uintX_t) instead of ELFT::Is64Bits ? 8 : 4.
llvm-svn: 259250
2016-01-29 22:18:57 +00:00
Rui Ueyama c516ae1719 ELF: Make Target's member function names shorter.
llvm-svn: 259147
2016-01-29 02:33:45 +00:00
Rui Ueyama c112c1be69 Rename includeInDynamicSymtab -> includeInDynsym.
llvm-svn: 259144
2016-01-29 02:17:01 +00:00
Rui Ueyama 724d625c7a ELF: Remove accessors from Target.
These accessors do not provide values. We can simply make the variables public.

llvm-svn: 259141
2016-01-29 01:49:32 +00:00
Rafael Espindola e2c2461a6b Merge identical strings.
This avoids the need to have reserve and addString in sync.

We avoid hashing the global symbols again. This means that we don't
merge a global symbol that has the same name as some other string, but
that doesn't seem very common. The string table size is the same in
clang an scylladb with or without hashing global symbols again.

llvm-svn: 259136
2016-01-29 01:24:25 +00:00
Rui Ueyama baf16512ea Rename isTlsOptimized -> canRelaxTls.
This function is a predicate that a given relocation can be relaxed.
The previous name implied that it returns true if a given relocation
has already been optimized away.

llvm-svn: 259128
2016-01-29 00:20:12 +00:00
Rui Ueyama 0e36e09b9c Update comments.
llvm-svn: 259127
2016-01-29 00:20:09 +00:00
Rui Ueyama c2a0d7e351 ELF: Report more than one undefined symbols if exist.
http://reviews.llvm.org/D16643

llvm-svn: 259107
2016-01-28 22:56:29 +00:00
Rui Ueyama 64cfffd333 ELF: Rename error -> fatal and redefine error as a non-noreturn function.
In many situations, we don't want to exit at the first error even in the
process model. For example, it is better to report all undefined symbols
rather than reporting the first one that the linker picked up randomly.

In order to handle such errors, we don't need to wrap everything with
ErrorOr (thanks for David Blaikie for pointing this out!) Instead, we
can set a flag to record the fact that we found an error and keep it
going until it reaches a reasonable checkpoint.

This idea should be applicable to other places. For example, we can
ignore broken relocations and check for errors after visiting all relocs.

In this patch, I rename error to fatal, and introduce another version of
error which doesn't call exit. That function instead sets HasError to true.
Once HasError becomes true, it stays true, so that we know that there
was an error if it is true.

I think introducing a non-noreturn error reporting function is by itself
a good idea, and it looks to me that this also provides a gradual path
towards lld-as-a-library (or at least embed-lld-to-your-program) without
sacrificing code readability with lots of ErrorOr's.

http://reviews.llvm.org/D16641

llvm-svn: 259069
2016-01-28 18:40:06 +00:00
Rafael Espindola 10d71ffc65 Remove another case of almost duplicated code.
Were had very similar code for deciding to keep a local symbol and for
actually writing it.

llvm-svn: 258958
2016-01-27 18:04:26 +00:00
Rafael Espindola 81e05525e3 Handle local symbols in discarded sections.
We were reserving space for them but never writing them out.

llvm-svn: 258948
2016-01-27 17:09:37 +00:00
Rui Ueyama 231b5e23c5 Simplify. NFC.
llvm-svn: 258796
2016-01-26 07:17:29 +00:00
Rafael Espindola de06936f28 Avoid almost duplication in .dynamic finalize and write.
There are a few cases where we have almost duplicated code.

This patches fixes the simplest: the finalize and write of dynamic
section. Right now they have to have exactly the same structure to
decide if a DT_* entry is needed and then to actually write it.

We cannot just write it to a std::vector in the first pass since
addresses have not been computed yet.

llvm-svn: 258723
2016-01-25 21:32:04 +00:00
Sean Silva f1c5a0f09c [ELF] Avoid unnecessary global variable.
Summary: It looks like this snuck through in r256143/D15383.

Reviewers: ruiu, grimar

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

llvm-svn: 258599
2016-01-23 01:49:37 +00:00
George Rimar bfd29a1567 [ELF] - Refactoring of Writer<ELFT>::scanRelocs()
Code for handling TLS relocations was moved out scanRelocs() to new function handleTlsRelocations().
That is because scanRelocs already too large to put more TLS code into it.

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

llvm-svn: 258392
2016-01-21 09:14:22 +00:00
Simon Atanasyan 56ab5f0289 [ELF][MIPS] Initial support of MIPS local GOT entries
Some MIPS relocation (for now R_MIPS_GOT16) requires creation of GOT
entries for symbol not included in the dynamic symbol table. They are
local symbols and non-local symbols with 'local' visibility. Local GOT
entries occupy continuous block between GOT header and regular GOT
entries.

The patch adds initial support for handling local GOT entries. The main
problem is allocating local GOT entries for local symbols. Such entries
should be initialized by high 16-bit of the symbol value. In ideal world
there should be no duplicated entries with the same values. But at the
moment of the `Writer::scanRelocs` call we do not know a value of the
symbol. In this patch we create new local GOT entry for each relocation
against local symbol, though we can exhaust GOT quickly. That needs to
be optimized later. When we calculate relocation we know a final symbol
value and request local GOT entry index. To do that we maintain map
between addresses and local GOT entry indexes. If we start to calculate
relocations in parallel we will have to serialize access to this map.

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

llvm-svn: 258388
2016-01-21 05:33:23 +00:00
Rui Ueyama 90f76fbb54 Return early before iterating over local symbols. NFC.
llvm-svn: 258385
2016-01-21 03:07:38 +00:00
Rafael Espindola 65e80b963a Rename IgnoredWeak to Ignored.
Thanks to Rui for the suggestion.

llvm-svn: 258189
2016-01-19 21:19:52 +00:00
Rafael Espindola 3a6a0a0109 Delete addIgnoredStrong.
It is not needed now that we resolve symbols is shared libraries
correctly.

llvm-svn: 258104
2016-01-19 00:05:54 +00:00
Rafael Espindola f312d89f50 Clarify the comment and code a bit. NFC.
llvm-svn: 258069
2016-01-18 20:06:59 +00:00
George Rimar f6bc65a3b2 Reapply r257753 with fix:
Added check for terminator CIE/FDE which has zero data size.
void EHOutputSection<ELFT>::addSectionAux(
...
 // If CIE/FDE data length is zero then Length is 4, this
 // shall be considered a terminator and processing shall end.
    if (Length == 4)
      break;
...

After this "Bug 25923 - lld/ELF2 linked application crashes if exceptions were used." is fixed for me. Self link of clang also works.

Initial commit message:
[ELF] - implemented --eh-frame-hdr command line option.

--eh-frame-hdr
Request creation of ".eh_frame_hdr" section and ELF "PT_GNU_EH_FRAME" segment header.

Both gold and the GNU linker support an option --eh-frame-hdr which tell them to construct a header for all the .eh_frame sections. This header is placed in a section named .eh_frame_hdr and also in a PT_GNU_EH_FRAME segment. At runtime the unwinder can find all the PT_GNU_EH_FRAME segments by calling dl_iterate_phdr.
This section contains a lookup table for quick binary search of FDEs.
Detailed info can be found here:
http://www.airs.com/blog/archives/462

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

llvm-svn: 257889
2016-01-15 13:34:52 +00:00
Rui Ueyama 489a806965 Update for LLVM function name change.
llvm-svn: 257801
2016-01-14 20:53:50 +00:00
Simon Atanasyan 682aeea9de [ELF][MIPS] Ignore 'hint' relocations like R_MIPS_JALR in the `scanRelocs` method
MIPS ABI has relocations like R_MIPS_JALR which is just a hint for
linker to make some code optimization. Such relocations should not be
handled as a regular ones and lead to say dynamic relocation creation.

The patch introduces new virtual `Target::isHintReloc` method, overrides
it in the `MipsTargetInfo` class and calls it in the `Writer<ELFT>::scanRelocs`
method.

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

llvm-svn: 257798
2016-01-14 20:42:09 +00:00
Rui Ueyama 5f91ace828 Revert r257753: "[ELF] - implemented --eh-frame-hdr command line option."
This reverts commit r257753 because we cannot link Clang with this patch.

llvm-svn: 257797
2016-01-14 20:32:19 +00:00
George Rimar 28f4fbe480 [ELF] - implemented --eh-frame-hdr command line option.
--eh-frame-hdr
Request creation of ".eh_frame_hdr" section and ELF "PT_GNU_EH_FRAME" segment header.

Both gold and the GNU linker support an option --eh-frame-hdr which tell them to construct a header for all the .eh_frame sections. This header is placed in a section named .eh_frame_hdr and also in a PT_GNU_EH_FRAME segment. At runtime the unwinder can find all the PT_GNU_EH_FRAME segments by calling dl_iterate_phdr.
This section contains a lookup table for quick binary search of FDEs.
Detailed info can be found here:
http://www.airs.com/blog/archives/462

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

llvm-svn: 257753
2016-01-14 10:30:32 +00:00
Rui Ueyama 09eb0b3b3f Rename IgnoredUndef -> Ignored since it is not an undefined symbol.
Also rename Ignored -> IgnoredWeak and IgnoredStrong -> Ignored,
since strong symbol is a norm.

llvm-svn: 257507
2016-01-12 19:24:55 +00:00
Simon Atanasyan 3a5b6e2750 [ELF][MIPS] Do not create dynamic relocations against _gp_disp symbol
MIPS _gp_disp designates offset between start of function and gp pointer
into GOT therefore any relocations against it do not require dynamic
relocation.

llvm-svn: 257492
2016-01-12 17:31:45 +00:00
Simon Atanasyan db147eb5ac [ELF][MIPS] Fix a typo in the comment
llvm-svn: 257450
2016-01-12 06:24:02 +00:00
Simon Atanasyan 188558e5eb [ELF][MIPS] Prevent substitution of _gp_disp symbol
On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
start of function and gp pointer into GOT. To make seal with such symbol
we add new method addIgnoredStrong(). It adds ignored symbol with global
binding to prevent the symbol substitution. The addIgnored call is not
enough here because this call adds a weak symbol which might be
substituted by symbol from shared library.

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

llvm-svn: 257449
2016-01-12 06:23:57 +00:00
Rui Ueyama 94b08e3bf0 Simplify. NFC.
llvm-svn: 257432
2016-01-12 01:33:23 +00:00
Rui Ueyama 902c75cd7b Remove dead code.
llvm-svn: 257421
2016-01-12 00:32:49 +00:00
Rui Ueyama f949f7f15e Merge two small functions. NFC.
llvm-svn: 257418
2016-01-11 23:50:55 +00:00
Rui Ueyama 885260e480 ELF: Remove SIZE relocs from isRelRelative.
SIZE relocations are not PC-relative, so isRelRelative should return false.

llvm-svn: 257141
2016-01-08 03:25:26 +00:00
Tom Stellard 80efb16aad [ELF] Add AMDGPU support
Summary: This will allow us to remove the AMDGPU support from old ELF.

Reviewers: rafael, ruiu

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

llvm-svn: 257023
2016-01-07 03:59:08 +00:00
Rui Ueyama 76c0063eeb ELF: Improve performance of string table construction.
String tables in unstripped executable files are fairly large in size.
For example, lld's executable file is about 34.4 MB in my environment,
and of which 3.5 MB is the string table. Efficiency of string table
construction matters.

Previously, the string table was built in an inefficient way. We used
StringTableBuilder to build that and enabled string tail merging,
although tail merging is not effective for the symbol table (you can
only make the string table 0.3% smaller for lld.) Tail merging is
computation intensive task and slow.

This patch eliminates string tail merging.

I changed the way of adding strings to the string table in this patch
too. Previously, strings were added using add() and the same strings
were then passed to getOffset() to get their offsets in the string table.
In this way, getOffset() needs to look up a hash table to get offsets
for given strings. This is a violation of "we look up the symbol table
(or a hash table) only once for each symbol" dogma of the new LLD's
design. Hash table lookup for long C++ mangled names is slow.
I eliminated that lookup in this patch.

In total, this patch improves link time of lld itself about 12%
(3.50 seconds -> 3.08 seconds.)

llvm-svn: 257017
2016-01-07 02:35:32 +00:00
Rui Ueyama e2e2a631bf Simplify. NFC.
llvm-svn: 256994
2016-01-06 23:34:11 +00:00
Rui Ueyama f71358dcc9 Define align() and use that instead of RoundUpToAlignment().
The name "RoundUpToAlignment" is too long compared to what it does.

llvm-svn: 256993
2016-01-06 23:25:42 +00:00
Rui Ueyama 83cd6e00e9 Remove unnecessary `lld::`.
llvm-svn: 256970
2016-01-06 20:11:55 +00:00
Rui Ueyama 2ef58a18af Remove SymbolTable::isUndefined.
Because it can be implemented outside of the symbol table.

llvm-svn: 256869
2016-01-05 20:35:16 +00:00
Rui Ueyama 2a65a49bcf Make findFile() a member function of SymbolTable to simplify. NFC.
llvm-svn: 256867
2016-01-05 20:01:29 +00:00
Rui Ueyama e57c487eee Consistently use 'Bss' instead of 'BSS'.
llvm-svn: 256844
2016-01-05 16:35:43 +00:00
Rui Ueyama 7f9e7ea343 Remove redundant typedef.
llvm-svn: 256843
2016-01-05 16:35:41 +00:00
Rui Ueyama 1a311f1da6 Split Writer::assignAddresses. NFC.
llvm-svn: 256449
2015-12-26 10:52:26 +00:00
Rui Ueyama 5a4ae1f584 Simplify. NFC.
llvm-svn: 256448
2015-12-26 10:34:33 +00:00
Rui Ueyama 1b2a8bf643 Add comments.
llvm-svn: 256447
2015-12-26 10:22:16 +00:00
Rui Ueyama 7b7ec71fea Rename SharedCopy -> CopyRel.
Because I think CopyRel is a better name for copy relocations
than SharedCopy.

llvm-svn: 256446
2015-12-26 10:07:03 +00:00
Rui Ueyama a5d79d1676 Define SECNAME_{start,end} symbols in a separate function. NFC.
llvm-svn: 256445
2015-12-26 09:48:00 +00:00
Rui Ueyama 0168722e39 Simplify __rel[a]_iplt_{start,end} handling a bit.
Also updated a comment.

llvm-svn: 256444
2015-12-26 09:47:57 +00:00
Rui Ueyama 84417f83cc Split Writer::createSections even more. NFC.
llvm-svn: 256442
2015-12-26 07:50:41 +00:00
Rui Ueyama f18fe7b439 Split Writer::createSections. NFC.
The linker has to create __tls_get_addr, end and _end symbols.
Previously, these symbols were created in createSections().
But they are not actually related to creating output sections.
This patch moves code out of the function.

llvm-svn: 256441
2015-12-26 07:50:39 +00:00
Rui Ueyama d30e4de717 Remove dead variable.
llvm-svn: 256440
2015-12-26 07:27:10 +00:00
Rui Ueyama 63de917f75 Add comment on .eh_frame sh_type.
Also simplifies the code a bit.

llvm-svn: 256439
2015-12-26 07:13:38 +00:00
Rui Ueyama 3a1f036cc6 Define a factory class to create output sections. NFC.
Previously, this code was directly written in createSections()
function. This patch moves some code out of that function to a
new class.

llvm-svn: 256438
2015-12-26 07:01:28 +00:00
Rui Ueyama d4ea7ddd57 Do not use SpecificBumpPtrAllocator to create output sections.
The number of output sections is usually limited, so the cost
of allocating them is not a bottleneck. This patch simplifies
the code by removing the allocators.

llvm-svn: 256437
2015-12-26 07:01:26 +00:00
Rui Ueyama 40845e6d37 Use virtual function instead of hand-written type dispatch.
OutputSectionBase already has virtual member functions.
This patch makes addSection() a virtual function to remove code
from Writer::createSections().

llvm-svn: 256436
2015-12-26 05:51:07 +00:00
George Rimar a7afacae70 Fixed MSVS warning "not all control paths return a value". NFC.
llvm-svn: 256415
2015-12-25 11:15:26 +00:00
Rui Ueyama 2df0fd86c2 Split Writer::createSections().
This function was longer than 250 lines, which is way too long
in my own standard. This patch reduces the size. It is still
too long, but this patch should be toward the right direction.

llvm-svn: 256411
2015-12-25 07:38:58 +00:00
Rui Ueyama 89f4ec74c1 Move a function to a file where it is used.
llvm-svn: 256410
2015-12-25 07:01:09 +00:00
Rui Ueyama a246e094bc Factor out static members from DefinedRegular.
This patch moves statically-allocated Elf_Sym objects out
of DefinedRegular class, so that the class definition becomes
smaller.

llvm-svn: 256408
2015-12-25 06:12:18 +00:00
Rafael Espindola 1119191c4f Make it possible to create common symbols from bitcode.
Since the only missing bit was the size, I just replaced the Elf_Sym
with the size.

llvm-svn: 256384
2015-12-24 16:23:37 +00:00
Rafael Espindola 02ce26a1b4 Delete DefinedAbsolute.
There are 3 symbol types that a .bc can provide during lto: defined,
undefined, common.

Defined and undefined symbols have already been refactored. I was
working on common and noticed that absolute symbols would become an
oddity: They would be the only symbol type present in a .o but not in
a.bc.

Looking a bit more, other than the special section number they were only
used for special rules for computing values. In that way they are
similar to TLS, and we don't have a DefinedTLS.

This patch deletes it. With it we have a reasonable rule of the thumb
for having a symbol kind: It exists if it has special resolution
semantics.

llvm-svn: 256383
2015-12-24 14:22:24 +00:00
Rui Ueyama 3d312a684a Remove unnecessary explicit instantiation.
llvm-svn: 256370
2015-12-24 08:41:55 +00:00
Rui Ueyama 3bfaba928f Make a member function non-member. NFC.
llvm-svn: 256368
2015-12-24 08:37:34 +00:00
Rafael Espindola ae53324cd4 Move function to the file where it is used.
llvm-svn: 256348
2015-12-23 20:37:51 +00:00
Rafael Espindola 97cbe3e39c Place RW sections that go after relro to another memory page.
Before this patch sections that go after relro sequence were placed at
the same memory page with relro ones. It caused segmentation fault on
freebsd.

Fixes PR25790.

Patch by George Rimar with some tweaks by myself.

llvm-svn: 256334
2015-12-23 15:20:38 +00:00
Rafael Espindola 5d7593bc59 Split Undefined and UndefinedElf.
I am working on adding LTO support to the new ELF lld.

In order to do that, it will be necessary to represent defined and
undefined symbols that are not from ELF files. One way to do it is to
change the symbol hierarchy to look like

Defined : SymbolBody
Undefined : SymbolBody

DefinedElf<ELFT> : Defined
UndefinedElf<ELFT> : Undefined

Another option would be to use bogus Elf_Sym, but I think that is
getting a bit too hackish.

This patch does the Undefined/UndefinedElf. Split. The next one
will do the Defined/DefinedElf split.

llvm-svn: 256289
2015-12-22 23:00:50 +00:00
Rafael Espindola 495bb46b34 Remove unnecessary cast.
llvm-svn: 256196
2015-12-21 20:50:51 +00:00
Rafael Espindola 8614dd7e19 Delete dead typedefs.
llvm-svn: 256181
2015-12-21 19:10:27 +00:00
Rafael Espindola 8a9f90e669 Refactor duplicated code. NFC.
llvm-svn: 256180
2015-12-21 19:09:19 +00:00
George Rimar a07ff66112 [ELF] - Implemented R_*_IRELATIVE relocations for x86, x64 targets.
This relocation is similar to R_*_RELATIVE except that the value used in this relocation is the program address returned by the function, which takes no arguments, at the address of
the result of the corresponding R_*_RELATIVE relocation as specified in the processor-specific ABI. The purpose of this relocation to avoid name lookup for locally defined STT_GNU_IFUNC symbols at load-time.

More info can be found in ifunc.txt from https://sites.google.com/site/x32abi/documents.

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

llvm-svn: 256144
2015-12-21 10:12:06 +00:00
George Rimar bfb7bf7429 [ELF] - R_386_GOTOFF relocation implemented.
R_386_GOTOFF is calculated as S + A - GOT, where:
S - Represents the value of the symbol whose index resides in the relocation entry.
A - Represents the addend used to compute the value of the relocatable field.
GOT - Represents the address of the global offset table.

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

llvm-svn: 256143
2015-12-21 10:00:12 +00:00
Simon Atanasyan 1d7df40711 [ELF][MIPS] MIPS .reginfo sections handling
MIPS .reginfo section provides information on the registers used by
the code in the object file. Linker should collect this information and
write .reginfo section in the output file. This section contains a union
of used registers masks taken from input .reginfo sections and final
value of the `_gp` symbol.

For details see the "Register Information" section in Chapter 4 in the
following document:
ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

The patch implements .reginfo sections handling with a couple missed
features: a) it does not put output .reginfo section into the separate
REGINFO segment; b) it does not merge `ri_cprmask` masks from input
section. These features will be implemented later.

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

llvm-svn: 256119
2015-12-20 10:57:34 +00:00
Simon Atanasyan 034c4cd58a [ELF] Allow target to configure ELF header flags in the output file
The patch configure ELF header flags for MIPS target. For now the flags
are hard coded. In fact they depends on ELF flags of input object files
and selected emulation.

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

llvm-svn: 256089
2015-12-19 05:51:49 +00:00
George Rimar 6f17e09307 [ELF] - implemented @indntpoff (x86) relocation and its optimization.
@indntpoff is similar to @gotntpoff, but for use in position dependent code. While @gotntpoff resolves to GOT slot address relative to the
start of the GOT in the movl or addl instructions, @indntpoff resolves to the
absolute GOT slot address. ("ELF Handling For Thread-Local Storage", Ulrich Drepper).

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

llvm-svn: 255884
2015-12-17 09:32:21 +00:00
Rui Ueyama 02dfd496b0 ELF: Rename relocNeedsCopy -> needsCopyRel
Just "copy" was a bit too ambiguous to say about copy relocations.

llvm-svn: 255866
2015-12-17 01:18:40 +00:00
Rui Ueyama bb93606755 ELF: Separate NeedsCopy and OffsetInBSS.
Previously, OffsetInBSS is -1 if it has no information about copy
relocation, 0 if it needs a copy relocation, and >0 if its offset
in BSS has been assigned. These flags were too subtle. This patch
adds a new flag, NeedsCopy, to carry information about whether
a shared symbol needs a copy relocation or not.

llvm-svn: 255865
2015-12-17 01:14:23 +00:00
Rui Ueyama 61805ec343 ELF: Rename IsTLS -> IsTls for consistency with other identifiers containing 'TLS'.
llvm-svn: 255856
2015-12-17 00:12:03 +00:00
Rui Ueyama 62d0e3297b ELF: Rename isTLS -> isTls for consistency.
llvm-svn: 255855
2015-12-17 00:04:18 +00:00
Rui Ueyama 6192c122f4 ELF: Move shouldUseRela to Writer.cpp.
The function was used only in Writer.cpp and did not depend on SymbolTable.
There is no reason to have that function in SymbolTable.cpp.

llvm-svn: 255850
2015-12-16 23:33:56 +00:00
Rui Ueyama dd7d998919 ELF: Drop 'Sym' suffix from member function names for consistency.
Since the functions are members of SymbolTable class, it is obvious
that they are adding symbols.

llvm-svn: 255832
2015-12-16 22:31:14 +00:00
Rafael Espindola 69d1ca6af2 Fix alignment computation for copy relocs.
Fixes PR25798.

Thanks to Ed Maste for the bug report and suggested fix.

llvm-svn: 255307
2015-12-10 22:53:24 +00:00
Rui Ueyama 01faef0ddc Simplify. NFC.
llvm-svn: 255284
2015-12-10 19:19:04 +00:00
Rui Ueyama ccfc3261f3 Simplify an expression. NFC.
llvm-svn: 255282
2015-12-10 19:13:08 +00:00
George Rimar a5fbebc206 [ELF] - Implemented --print-gc-sections command line argument.
List all sections removed by garbage collection. This option is only effective if garbage collection has been enabled via the `--gc-sections' option.

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

llvm-svn: 255235
2015-12-10 09:12:18 +00:00
George Rimar 95c1a58539 Renamed addLocalModelTlsIndex() -> addCurrentModuleTlsIndex(), NFC.
(per discussion with Michael Spencer)

llvm-svn: 254896
2015-12-07 08:02:20 +00:00
George Rimar 25411f2558 [ELF] - Implemented @tlsgd optimization (GD->IE case, x64).
"Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5 x86-x64 linker optimizations, http://www.akkadia.org/drepper/tls.pdf) shows how GD can be optimized to IE.
This patch implements the optimization.

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

llvm-svn: 254713
2015-12-04 11:20:13 +00:00
George Rimar 90cd0a8234 [ELF] - Fixed bug leading to miss of tls relocation when @tlsgd and @gottpoff relocations were used at the same time.
Combination of @tlsgd and @gottpoff at the same time leads to miss of R_X86_64_TPOFF64 dynamic relocation. Patch fixes that.

@tlsgd(%rip) - Allocate two contiguous entries in the GOT to hold a tls index
structure (for passing to tls get addr).
@gottpoff(%rip) - Allocate one GOT entry to hold a variable offset in initial TLS
block (relative to TLS block end, %fs:0).

The same situation can be observed for x86 (probably others too, not sure) with corresponding for that target relocations: @tlsgd, @gotntpoff.

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

llvm-svn: 254443
2015-12-01 19:20:26 +00:00
George Rimar b17f739808 Reapply r254428.
Fix was:
uint32_t getLocalTlsIndexVA() { return getVA() + LocalTlsIndexOff; }
=>
uint32_t getLocalTlsIndexVA() { return Base::getVA() + LocalTlsIndexOff; }
Both works for my MSVS.

Original commit message:
[ELF] - Refactor of tls_index implementation for tls local dynamic model.

Patch contains the next 2 changes:
1) static variable Out<ELFT>::LocalModuleTlsIndexOffset moved to Out<ELFT>::Got. At fact there is no meaning for it to be separated from GOT class because at each place of using it anyways needs to call GOT`s getVA(). Also it is impossible to have that offset and not have GOT.
2) addLocalModuleTlsIndex -> addLocalModelTlsIndex (word "Module" changed to "Model"). Not sure was it a mistype or not but I think that update is closer to Urlich terminology.

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

llvm-svn: 254433
2015-12-01 18:24:07 +00:00
George Rimar 60849f2913 revert r254428 [ELF] - Refactor of tls_index implementation for tls local dynamic model.
It failed buildbot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/3782/steps/build/logs/stdio

Target.cpp
In file included from /home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/lld/ELF/Target.cpp:20:
/home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.src/tools/lld/ELF/OutputSections.h:136:42: error: use of undeclared identifier 'getVA'
  uint32_t getLocalTlsIndexVA() { return getVA() + LocalTlsIndexOff; }

llvm-svn: 254432
2015-12-01 18:11:16 +00:00
George Rimar 0ec3f306d4 [ELF] - Refactor of tls_index implementation for tls local dynamic model.
Patch contains the next 2 changes:
1) static variable Out<ELFT>::LocalModuleTlsIndexOffset moved to Out<ELFT>::Got. At fact there is no meaning for it to be separated from GOT class because at each place of using it anyways needs to call GOT`s getVA(). Also it is impossible to have that offset and not have GOT.
2) addLocalModuleTlsIndex -> addLocalModelTlsIndex (word "Module" changed to "Model"). Not sure was it a mistype or not but I think that update is closer to Urlich terminology.

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

llvm-svn: 254428
2015-12-01 17:45:31 +00:00