Commit Graph

4843 Commits

Author SHA1 Message Date
Rui Ueyama 1e056ebe3c Fix indentation.
llvm-svn: 258374
2016-01-21 00:45:39 +00:00
Simon Atanasyan c3e54cf17b [ELF][MIPS] Update test case to reflect recent changes in llvm-readobj
llvm-svn: 258340
2016-01-20 20:01:28 +00:00
Simon Atanasyan 0d5e1b753e [ELF] Do not keep STT_FILE symbols in the symbol table
STT_FILE symbols usually contain source file names. It is redundant
to keep this information in the output file.

llvm-svn: 258331
2016-01-20 18:59:45 +00:00
Pete Cooper 90dbab0b0d Add an ObjCPass to the MachO linker.
This pass currently emits an objc image info section if one is required.

This section contains the aggregated version and flags for all of the input
files.

llvm-svn: 258197
2016-01-19 21:54:21 +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
Pete Cooper 0872e46c9d Set the objc constraint on the context based on the parsed files.
Like arch, os, etc, when we know we are going to use a file, we check
that the file has compatible objc constraints to the context, throw
appropriate errors where that is not the case, and hopefully set the
objc constraints on the context for use later.

Added 2 tests to ensure that we don't have incompatibilities between
host and simulator code as both will get x86 based architectures.

llvm-svn: 258173
2016-01-19 19:46:41 +00:00
Pete Cooper feaa967ee8 Cache the objc image info constraints in file.
Image info flags describe the objc constraint which is GC/retain/release/etc.

These need to be parsed and stored in the file so that we can do error checking.

That will come in a later commit.

llvm-svn: 258160
2016-01-19 18:46:40 +00:00
George Rimar ffb673515e [ELF] - R_386_GOT32 relocation calculation fix.
R_386_GOT32 has multiple descriptions:

"System V Application Binary Interface Intel386 Architecture Processor Supplement Version 1.1" (https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf), p36 contains next calculation for R_386_GOT32: G + A - GOT.
SYSTEM V APPLICATION BINARY INTERFACE 4 (https://refspecs.linuxfoundation.org/elf/abi386-4.pdf, p78) tolds us its G + A - P.
Oracle docs (https://docs.oracle.com/cd/E19455-01/816-0559/chapter6-26/index.html) says its should be G + A.

gold/bfd calculates it as "G + A - GOT", but GOT means the end of the GOT section.
Patch fixes current calculation to gold/ld behavior.

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

llvm-svn: 258115
2016-01-19 11:00:48 +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 0bc0c02387 Prefer symbols from .o over .so.
This matches the behavior of gold and bfd ld.

llvm-svn: 258102
2016-01-18 23:54:05 +00:00
Rafael Espindola 591c6cefae Delete dead code.
llvm-svn: 258078
2016-01-18 20:50:28 +00:00
Rafael Espindola f312d89f50 Clarify the comment and code a bit. NFC.
llvm-svn: 258069
2016-01-18 20:06:59 +00:00
Pete Cooper 12b094d5f4 Only emit files with subsections_via_symbols if all inputs had that set.
When generating a relocatable file, its only valid to set this flag if
all of the inputs also had the flag.  Otherwise we may atomize incorrectly
when we link the relocatable file again.

Reviewed by Lang Hames.

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

llvm-svn: 257976
2016-01-16 01:09:23 +00:00
Pete Cooper 4b6bed98e2 Give error on binaries containing GC objc image infos.
The image info struct contains flags for what kind of GC/retain/release is required.

Give an error if we parse GC flags as these are unsupported.

llvm-svn: 257974
2016-01-16 00:57:07 +00:00
Pete Cooper a014ffef87 Add checking of differing swift versions in input files.
Swift versions are part of the objc image info section, and must match
for all files linked which actually have an image info section

llvm-svn: 257964
2016-01-16 00:07:22 +00:00
Pete Cooper 78f7907953 Remove unnecessary extra linked file in RUN line. NFC.
This test case was already suitably self-contained that linking against the
helloworld file added no value.

llvm-svn: 257954
2016-01-15 23:25:40 +00:00
Pete Cooper 20de822232 Check that the objc image info version is exactly 0
llvm-svn: 257953
2016-01-15 23:25:37 +00:00
Pete Cooper 2735783090 Add the GC commandline options and throw errors if they are used
llvm-svn: 257907
2016-01-15 17:39:02 +00:00
Pete Cooper 7162e8c597 Remove out of bounds reloc from reduced file.
This file was failing to build with asan enabled.  The reason being that
applyFixupFinal was writing 4-bytes worth of fixup in to an atom only
a single byte in length.

The test case didn't actually need this particular reloc so i've removed
it, although i'll follow up with future commits to actually verify that
relocs are to an address with enough space for the fixup to be applied.

llvm-svn: 257906
2016-01-15 17:25:12 +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
Davide Italiano 2dfc5fd1ea [ELF/AArch64] Add support for R_AARCH64_LDST16_ABS_LO12_NC relocation.
Found while trying to self-host the toolchain that libLTO needs it.

llvm-svn: 257854
2016-01-15 01:49:51 +00:00
Pete Cooper 00de8b5a1a Don't use explicit paths in my own test check lines
llvm-svn: 257842
2016-01-14 23:44:00 +00:00
Pete Cooper d7b5c5bcef Error check the size of the __objc_imageinfo section
llvm-svn: 257841
2016-01-14 23:35:05 +00:00
Pete Cooper 99f3b9494b Check for mismatched arch and OS when linking MachO files.
This patch makes use of the handleLoadedFile hook added in r257814.

That method is used to check the arch and the OS of the files we are linking
against the arch and OS on the context.

The first test to use this ensures that we do not try to combine i386 Mac OS code
with i386 simulator code.

llvm-svn: 257837
2016-01-14 23:25:06 +00:00
Pete Cooper f0c0f3c477 Add File::kind's for all subclasses of File.
This is to enable isa<> support for any files which need it.

It will be used in an upcoming patch to differentiate MachOFile from other implicitly generated files.

Reviewed by Lang Hames.

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

llvm-svn: 257830
2016-01-14 22:55:38 +00:00
Rui Ueyama 528a56eb0d Remove XFAIL:win32 from a test which does not fail on win32.
This test uses a regexp so that it matches both Unix output and
Windows output.

llvm-svn: 257817
2016-01-14 22:04:35 +00:00
Pete Cooper 80c0974c6b Add handleLoadedFile hook to the context.
This is called from the resolver on each file we decide we actually want to use.

Future commits will make use of this to extract useful information from the files and do
error checking against the context.  For example, ensure that files are the same arch as
each other.

Reviewed by Lang Hames.

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

llvm-svn: 257814
2016-01-14 21:53:13 +00:00
Simon Atanasyan ca558ea627 [ELF][MIPS] Create dynamic relocations for R_MIPS_32/64 relocations
llvm-svn: 257806
2016-01-14 21:34:50 +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
Davide Italiano 0d4fbae0e7 [ELF/AArch64] Support R_AARCH64_LDST128_ABS_LO12_NC relocation.
llvm-svn: 257731
2016-01-14 01:30:21 +00:00
Rui Ueyama df1545163f Update comment for __cxa_demangle again to make it precise.
Thanks for Ed Maste for the suggestion.

llvm-svn: 257685
2016-01-13 22:09:09 +00:00
Rui Ueyama e16d1b0a9c Update comment for __cxa_demangle.
llvm-svn: 257678
2016-01-13 21:39:40 +00:00
Rui Ueyama 5fa978b4c0 Attempt to make FreeBSD buildbot green.
It seems that __cxa_demangle function on the buildbot tried to demangle
a variable "tlsvar" as a C++ symbol. Do not call that function unless
it does not start with "_Z" which is the prefix of mangled names.

llvm-svn: 257661
2016-01-13 19:40:13 +00:00
Rui Ueyama a4a628fb51 Demangle symbols when including them in error messages.
llvm-svn: 257647
2016-01-13 18:55:39 +00:00
George Rimar 3d737e45c0 Reapply r257588
Fix: Added missed input file.

Initial commit message:
[ELF/AArch64] - Implemented R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 and R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC relocations

* R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 is calculated as Page(G(GTPREL(S+A))) – Page(P), set an ADRP immediate field to bits [32:12] of X; check –2^32 ≤ X < 2^32;
* R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC is calculated as G(GTPREL(S+A)), set an LD offset field to bits [11:3] of X. No overflow check; check that X&7 = 0.

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

llvm-svn: 257596
2016-01-13 13:04:46 +00:00
George Rimar cc6c093f6f Revert r257588 as it broke buildbot
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/18715/steps/test_lld/logs/stdio

llvm-svn: 257595
2016-01-13 12:58:51 +00:00
George Rimar 253dbf5405 [ELF/AArch64] - Implemented R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 and R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC relocations
* R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 is calculated as Page(G(GTPREL(S+A))) – Page(P), set an ADRP immediate field to bits [32:12] of X; check –2^32 ≤ X < 2^32;
* R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC is calculated as G(GTPREL(S+A)), set an LD offset field to bits [11:3] of X. No overflow check; check that X&7 = 0.

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

llvm-svn: 257588
2016-01-13 11:29:45 +00:00
Rui Ueyama 4b00e7310f COFF: Update test for recent llvm-objdump change (r257539).
This test now correctly checks if the specified forwarding-to
symbol exists in the export table.

llvm-svn: 257540
2016-01-12 23:29:42 +00:00
Rui Ueyama ab12361c4e Merge two consecutive if's. NFC.
llvm-svn: 257527
2016-01-12 21:57:44 +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 49f98c742c [ELF][MIPS] Do not use 'sed' to modify binary files
On Windows different versions of 'sed' work in different text/binary
mode by default. If default mode is text, sed produces corrupted binary
files. Unfortunately there is no standard command line option to select
the mode. Some 'sed' support '-b' to switch to binary mode, while other
ones support '--text' option and does not have '-b' option at all.

llvm-svn: 257471
2016-01-12 12:38:43 +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
Davide Italiano 15414cd0a7 [ELF] FreeBSD has slightly different emulation strings for PPC.
Teach lld about them.

llvm-svn: 257437
2016-01-12 02:58:59 +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