Commit Graph

4810 Commits

Author SHA1 Message Date
Tom Stellard 68a55e6c34 [ELF] Fix REQUIRES line in amdgpu tests
'REQUIRES' needs to be in all caps.

Also update lit.cfg so these tests get run when the AMDGPU target is
enabled.

llvm-svn: 257029
2016-01-07 05:02:38 +00:00
Tom Stellard a09245cddb [ELF] Fix amdgpu tests
The triples in these tests were completely wrong, but the tests were
still passing for me locally.

llvm-svn: 257027
2016-01-07 04:22:24 +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
Pete Cooper 69b18f4703 Set CMake ADDITIONAL_HEADER_DIRS on libraries with headers in /include. NFC.
In a UI such as XCode, it can group the headers for a library with that library.
This is done in the CMakeLists.txt for the library itself by setting the path(s)
as ADDITIONAL_HEADER_DIRS.

LLVM already does this for all of its libraries, so just adding this to lld to
make things easier.  Should be NFC.

llvm-svn: 257002
2016-01-07 00:14:09 +00:00
Pete Cooper f154b678c6 Set the folder for libraries to 'lld libraries'. NFC.
In a UI such as XCode, LLVM source files are in 'libraries' while clang
files are in 'clang libraries'.

This change moves the lld source to 'lld libraries' to make code browsing easier.

It should be NFC as the build itself is still the same, just the structure in a
UI differs.

llvm-svn: 257001
2016-01-07 00:14:04 +00:00
Rui Ueyama f1cbb93050 Use RoundUpToAlignment instead of writing the expression to round up.
The original code might be more readable than the new one if you
remember the expression. Otherwise the new one is probably better.

llvm-svn: 256995
2016-01-06 23:34:12 +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 cf07a31107 Remove redundant `llvm::ELF::`.
llvm-svn: 256986
2016-01-06 22:53:58 +00:00
Rui Ueyama 70eed364fc Simplify MipsReginfoInputSection.
MipsReginfoInputSection is basically just a container of Elf_Mips_Reginfo
struct. This patch makes that struct directly accessible from others.

llvm-svn: 256984
2016-01-06 22:42:43 +00:00
Rui Ueyama 58a636ac06 Add llvm_unreachable to unreachable code.
The original code was an infinite recursion when the control reaches there.

llvm-svn: 256981
2016-01-06 22:01:25 +00:00
Pete Cooper d53090ac5e Fix MachO arm64 delta32ToGOT reloc encoding in -r.
The fixup content we encode here should be the offset from the
fixup location back to the last nonlocal label.  We were only encoding
the address of the fixup, and not taking in to account the base address
of the atom we are in.

Updated the test case here to have a text section which will come before
the data section where the relocation lives.  .data being at offset 0 had
previously been hiding this bug.

llvm-svn: 256974
2016-01-06 20:53:19 +00:00
Rui Ueyama 33b3f21168 Rename GroupEntryType -> uint32_X.
GroupEntryType was a 32-bit integral type but that was not obvious
from its name.

llvm-svn: 256971
2016-01-06 20:30:02 +00:00
Rui Ueyama 83cd6e00e9 Remove unnecessary `lld::`.
llvm-svn: 256970
2016-01-06 20:11:55 +00:00
Ed Maste 2991812d49 Add DT_DEBUG debugger rendezvous test for r256942
llvm-svn: 256943
2016-01-06 15:56:04 +00:00
Ed Maste f5d3cf6270 Add debugger rendezvous DT_DEBUG .dynamic entry
The runtime linker may store a pointer to a data structure used by
debuggers.

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

llvm-svn: 256942
2016-01-06 15:52:27 +00:00
Rui Ueyama 5a32c7647e Add comments.
llvm-svn: 256905
2016-01-06 03:16:23 +00:00
Rui Ueyama ad87ff7235 Simplify. NFC.
llvm-svn: 256903
2016-01-06 02:52:24 +00:00
Rui Ueyama 52d3b67c1d Rename Comdats -> ComdatGroups.
I usually prefer short names, but in this case the new descriptive
name should improve readability a bit.

llvm-svn: 256899
2016-01-06 02:06:33 +00:00
Rui Ueyama 7c713319b9 Rename SharedFile::parse -> SharedFile::parseRest.
Unlike ObjectFile or ArchiveFile, SharedFile had two parse functions,
parseSoName() and parse(). parse must have been called after parseSoName,
but that requirement was not obvious from their names. (So it looked
like you could call parse() on a shared object file right away.)

This patch rename parseRest. It is now obvious that there's no single
parse function for the shared object file.

llvm-svn: 256898
2016-01-06 01:56:36 +00:00
Rui Ueyama e69ab10301 Remove redundant this->.
llvm-svn: 256894
2016-01-06 01:14:11 +00:00
Rui Ueyama 9b09369b3d Simplify --whole-archive handling.
Previously, we handle archive files with --whole-archive this way:
create instances of ArchiveFile, call getMembers to obtain memory
buffers of archive members, and create ObjectFiles for the members.
We didn't call anything except getMembers if --whole-archive was
specified.

I noticed that we didn't actually have to create ArchiveFile instaces
at all for that case. All we need is to get a list of memory buffers
for members, which can be done by a non-member function.

This patch removes getMembers member function from ArchiveFile.
Also removed unnecessary code for memory management.

llvm-svn: 256893
2016-01-06 00:51:35 +00:00
Rui Ueyama 533c03078b Do not use templates to instantiate {Object,Shared}Files.
createELFFile looked complex because of its use of template,
so I want to keep it private within this file.

llvm-svn: 256880
2016-01-06 00:09:43 +00:00
Rui Ueyama f588ac4663 Simplify. NFC.
llvm-svn: 256879
2016-01-06 00:09:41 +00:00
Rui Ueyama 2e0a9fff12 Fix local variable naming.
llvm-svn: 256878
2016-01-06 00:09:39 +00:00
Rui Ueyama c9559d9378 Add comments.
llvm-svn: 256872
2016-01-05 20:47:37 +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 ddec22d55d Add comments.
llvm-svn: 256850
2016-01-05 17:55:05 +00:00
Rui Ueyama c7b073a23a Simplify. NFC.
llvm-svn: 256846
2016-01-05 16:35:48 +00:00
Rui Ueyama f53b1b7fde Update comments.
llvm-svn: 256845
2016-01-05 16:35:46 +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
Pete Cooper 52db793d33 Improved debugging printing. NFC
llvm-svn: 256805
2016-01-05 01:56:59 +00:00
Pete Cooper 921227c3bc Fix test case comment after r256786. NFC.
The comment spacing was meant to show the interesting bytes in the prior
line, but the prior line moved slightly.

llvm-svn: 256800
2016-01-05 00:47:22 +00:00
Pete Cooper bd364ce694 Sort sections in relocatable files.
The final section order in relocatable files was just a side effect
of the atom sorter.  This meant that sections like __data were before
__text because __data has RW permissions and __text RX and RW was less
than RX in our enum.

Final linked images had an actual section/segment sorter.  There was no
reason for the difference, so simplify a bunch of code and just use the
same sorted for everything.

Reviewed by Lang Hames.

http://reviews.llvm.org/D15868

llvm-svn: 256786
2016-01-04 22:29:36 +00:00
Pete Cooper 9942bd025d Fix x86_64 delta*Anon relocs.
The encoded value should be an offset from the fixup location, which
means that it should take in to account the fixup offset in its section.

We weren't subtracting the base address of the atom, which meant that when
we parsed the file again for a round trip, we had 2x the atom address in our
target address.

I've also improved comments for these to try and describe what is going on.

There's no test case right now, as the bug is only exhibited when __data is at
a non-zero address in a -r link.  A commit will soon sort the sections differently
and move __data to after __text.  Then these relocations in
test/mach-o/parse-data-relocs-x86_64.yaml will test for this bug.

llvm-svn: 256779
2016-01-04 21:23:12 +00:00
George Rimar 147747ab0b Revert or r256638. I`ve lost a little piece of code when resolved conflicts right before commit. Sorry about that.
Test did not catch this either, so I`ll improve it and recommit later.

Original commit message:
[ELF] - Optimize .eh_frame section: remove CIE if all FDEs referencing it were removed.

This patch performs little optimization for eh_frame section.
If all FDE`s that referenced CIE are removed then CIE is also removed from output. 
That can happen for example when dropping FDEs that point to dropped sections. Testcase showing that is included.
The same optimization was added to ld about 14 years ago: https://sourceware.org/ml/binutils/2001-12/msg00144.html, gold does not do that it seems.

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

llvm-svn: 256693
2016-01-02 16:55:01 +00:00
George Rimar 57286644f7 [ELF] - Optimize .eh_frame section: remove CIE if all FDEs referencing it were removed.
This patch performs little optimization for eh_frame section.
If all FDE`s that referenced CIE are removed then CIE is also removed from output. 
That can happen for example when dropping FDEs that point to dropped sections. Testcase showing that is included.
The same optimization was added to ld about 14 years ago: https://sourceware.org/ml/binutils/2001-12/msg00144.html, gold does not do that it seems.

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

llvm-svn: 256638
2015-12-30 11:40:44 +00:00
Simon Atanasyan 69b3cbef43 [ELF][MIPS] Rename test file. NFC
llvm-svn: 256577
2015-12-29 21:09:26 +00:00
George Rimar 4b5346fa49 Reformat of conditions for calculating r_offset in RelocationSection<ELFT>::writeTo(). NFC.
llvm-svn: 256563
2015-12-29 16:17:32 +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
Simon Atanasyan 57830b60dc [ELF][MIPS] Implement R_MIPS_GPREL16/R_MIPS_GPREL32 relocations
The R_MIPS_GPREL16 / R_MIPS_GPREL32 relocations use the following
expressions for calculations:
```
local symbol:  S + A + GP0 - GP
global symbol: S + A - GP

GP  - Represents the final gp value, i.e. _gp symbol
GP0 - Represents the gp value used to create the relocatable object
```
The GP0 value is taken from the .reginfo data section defined by an object
file. To implement that I keep a reference to `MipsReginfoInputSection`
in the `ObjectFile` class. This reference is used by the
`ObjectFile::getMipsGp0` method to return the GP0 value.

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

llvm-svn: 256416
2015-12-25 13:02:13 +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
George Rimar 6ab275c0c8 [ELF] - Fixed handling relocations against zero sized .eh_frame section.
The file crtbeginT.o has relocations pointing to the start of an empty
.eh_frame that is known to be the first in the link. It does that to
identify the start of the output .eh_frame. Handle this special case.

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

llvm-svn: 256414
2015-12-25 09:51:42 +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 7d332f5eb7 Add comments.
llvm-svn: 256409
2015-12-25 06:55:39 +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 7f040bf658 Simplify. NFC.
llvm-svn: 256404
2015-12-25 01:00:41 +00:00
Rafael Espindola 91bd48a33a Update the recorded CIE length when aligning.
We cannot just pad with 0s as that would be a terminator mark.

llvm-svn: 256392
2015-12-24 20:44:06 +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 01a65b19cf Add comments.
llvm-svn: 256380
2015-12-24 10:37:32 +00:00
Rui Ueyama 74f598b2b5 Remove `continue` to make the code a bit shorter. NFC.
llvm-svn: 256379
2015-12-24 10:14:05 +00:00
Rui Ueyama da735325fa Mark .eh_frame sections as live by default. NFC.
This change eliminates a string comparison from the
garbage collector.

llvm-svn: 256378
2015-12-24 10:08:54 +00:00
Davide Italiano b40553751a [README] Update to reflect the new world order.
llvm-svn: 256376
2015-12-24 10:03:46 +00:00
Davide Italiano bcbfedc927 [ELF] Don't reclaim .ctors/.dtors sections.
In FreeBSD, rtld expects .ctors containing -1 (0xffffffff), and a
.ctors section containing the correct bits is provided to the linker as
input (/usr/lib/crtbegin.o).

Contents of section .ctors:
 0000 ffffffff ffffffff                    ........

This section is not stripped even if not referenced or empty, also in
gold or ld.bfd. It would be nice to strip it when not needed but
since existing object files rely on that we can't do better to keep it
around.

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

llvm-svn: 256373
2015-12-24 09:52:11 +00:00
Rui Ueyama 7924fb8142 Add a comment.
llvm-svn: 256372
2015-12-24 09:50:22 +00:00
Rui Ueyama 3d312a684a Remove unnecessary explicit instantiation.
llvm-svn: 256370
2015-12-24 08:41:55 +00:00
Rui Ueyama 3f11c8c97e Split functions and add comments. NFC.
llvm-svn: 256369
2015-12-24 08:41:12 +00:00
Rui Ueyama 3bfaba928f Make a member function non-member. NFC.
llvm-svn: 256368
2015-12-24 08:37:34 +00:00
Rui Ueyama dc8d3a2104 Return early and remove a redundant error check. NFC.
llvm-svn: 256367
2015-12-24 08:36:56 +00:00
Rui Ueyama 215d6a31b7 Add machine type check for MIPS-specific code path.
llvm-svn: 256355
2015-12-24 01:32:39 +00:00
Rafael Espindola 4d4b06a0f8 Split Defined and DefinedElf.
This is similar to what was done for Undefined and opens the way for
having a symbol defined in bitcode.

llvm-svn: 256354
2015-12-24 00:47:42 +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 21f7bd4ba1 Simplify memory management.
We no longer need an explicit delete or a polymorphic destructor.

llvm-svn: 256333
2015-12-23 14:35:51 +00:00
Rafael Espindola ce7d39d5e1 Fix the last leak asan found in test/ELF.
llvm-svn: 256316
2015-12-23 03:40:17 +00:00
Rafael Espindola 7300afa36a Fix another asan detected leak.
llvm-svn: 256311
2015-12-23 01:18:40 +00:00
Rafael Espindola 05b0375e93 Fix an asan found leak.
I will make better use of std::unique_ptr in followup patch.

llvm-svn: 256310
2015-12-23 01:14:37 +00:00
Rafael Espindola 5f2c46d62e Fix two asan found bugs:
We were leaking InputFile subclasses data.
UndefinedElf was missing a classof.

llvm-svn: 256309
2015-12-23 01:06:39 +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 88dddf9198 Drop remaining uses of the Base typedef idiom.
llvm-svn: 256200
2015-12-21 21:07:31 +00:00
Rafael Espindola 167e62f8c1 Simplify types. NFC.
llvm-svn: 256197
2015-12-21 20:59:29 +00:00
Rafael Espindola 495bb46b34 Remove unnecessary cast.
llvm-svn: 256196
2015-12-21 20:50:51 +00:00
Rafael Espindola 1e2967e81c Remove simple uses of Base::.
They have a tendency to get out of date and obscure where the value/type
is from.

llvm-svn: 256195
2015-12-21 20:47:33 +00:00
Rafael Espindola 0234640882 Remove unnecessary cast.
llvm-svn: 256189
2015-12-21 20:18:04 +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
Simon Atanasyan 0fc0acf180 [ELF][MIPS] Support some of R_MIPS_PCxxx relocations
The patch adds support for R_MIPS_PC16, R_MIPS_PC19_S2, R_MIPS_PC21_S2,
R_MIPS_PC26_S2, R_MIPS_PCHI16, R_MIPS_PCLO16 relocations handling.

llvm-svn: 256172
2015-12-21 17:36:40 +00:00
George Rimar 0b8ed1d162 [ELF] - fixed not properly handled @GOTTPOFF relocation against local symbols
This patch changes sequence of applying relocations, moving tls optimized relocation handling code before code for other locals.
Without that change relocation @GOTTPOFF against local symbol caused runtime error ("unrecognized reloc ...").
That change also should fix other tls optimized relocations, but I did not check them, that's a field for another patch.

R_X86_64_GOTTPOFF relocations against locals can be found when linking against libc.a(malloc.o):
000000000036 000600000016 R_X86_64_GOTTPOFF 0000000000000000 libc_tsd_MALLOC - 4
000000000131 000600000016 R_X86_64_GOTTPOFF 0000000000000000 libc_tsd_MALLOC - 4

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

llvm-svn: 256145
2015-12-21 10:37:33 +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
George Rimar e72bebaf2d [ELF] - Fixed padding for CIE/FDE entries of .eh_frame section
Spec says both CIE/FDE has "Padding
Extra bytes to align the CIE structure to an addressing unit size boundary."
https://refspecs.linuxfoundation.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html

Patch aligns CIE/FDE entries to the size of platform pointer.

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

llvm-svn: 256141
2015-12-21 09:38:59 +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