Commit Graph

534 Commits

Author SHA1 Message Date
Rafael Espindola a8777c2ef8 Handle gd tls relocs pointing to local symbols.
If the symbol is local we don't need to create a R_X86_64_DTPOFF64, we
can just write the correct value in the got.

Should fix pr28018.

llvm-svn: 272205
2016-06-08 21:31:59 +00:00
George Rimar 2030cacc67 [ELF] - Tweak verneed.s test to use new llvm-readobj functionality
Previously this test performed check of binary data. Since
llvm-readobj currently able to dump all 3 types of version relative
sections, that can be used to make this test more transparent.
Patch do that.

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

llvm-svn: 272120
2016-06-08 06:54:23 +00:00
Peter Smith 5dd3c292bc Add missing REQUIRES: arm from test. To fix tests building without ARM.
llvm-svn: 271994
2016-06-07 09:49:40 +00:00
Peter Smith 8646ced053 Initial support for ARM in lld.
Add support for an ARM Target and the initial set of relocations
    and PLT entries that are necessary for an ARM only hello world to
    link. This has been tested against an ARM only sysroot from the
    4.2.0 CodeSourcery Lite release.
    
    Tests have been added to test/ELF for the support that has been
    implemented.
    
    Main limitations:
    - No Thumb support
    - Relocations incomplete
    - No C++ exceptions support
    - No TLS support
    - No range extension or interworking veneer (thunk) support
    - No Build Attribute support
    - No Big-endian support
    
    The deprecated relocations R_ARM_PLT32 and R_ARM_PC24 have been
    implemented as these are used by the 4.2.0 CodeSourcery Lite release.

llvm-svn: 271993
2016-06-07 09:31:52 +00:00
Rafael Espindola acad605df9 Ignore the "globally available" version.
Reduced from a firefox build.

llvm-svn: 271950
2016-06-06 22:42:57 +00:00
Rui Ueyama 4ffda7a9cf Create version.txt in a reproduce archive file.
Differential Revision: http://reviews.llvm.org/D21008

llvm-svn: 271901
2016-06-06 15:34:37 +00:00
George Rimar 8b3c5f2b30 [ELF] - Assign sh_link field of SHT_GNU_versym section to DynSymTab section index.
.gnu.version should have sh_link field initialized with index of DynSymTab section.

GNU documentation looks misses that, but Sun docs mention it, according to
https://docs.oracle.com/cd/E19120-01/open.solaris/819-0690/chapter6-54676/index.html 
versym sh_link is indeed supposed to point to the .dynsym section.

Binutils readelf tool also relies on that:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=binutils/readelf.c;h=b6454d353279dc57745cd5a2d68b5f3f69f8e17c;hb=5522f910cb539905d6adfdceab208ddfa5e84557#l9988

Both gold/bfd do the same + after this patch I am able to see this section in readelf output, was unable before in my case.

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

llvm-svn: 271874
2016-06-06 08:04:53 +00:00
Rafael Espindola e325b98836 add missing REQUIRES
llvm-svn: 271859
2016-06-05 22:54:11 +00:00
Rafael Espindola 4f5046ce87 Add a missing REQUIRES.
llvm-svn: 271854
2016-06-05 19:28:44 +00:00
Rafael Espindola 6211d9a4fa Move GlobalDynIndex to SymbolBody.
With that we can have local symbols with a tls gd index.

llvm-svn: 271852
2016-06-05 19:03:28 +00:00
Rafael Espindola 698dba74f8 Include version in --reproduce.
llvm-svn: 271829
2016-06-05 13:19:39 +00:00
Davide Italiano cd76e49888 Attempt to fix non-determinism in test.
Otherwise it could just use a leftover a.out from
some other test.

llvm-svn: 271820
2016-06-05 01:04:59 +00:00
Rafael Espindola e1979aed0a Implement gd to ie relaxation for aarch64.
llvm-svn: 271815
2016-06-04 23:33:31 +00:00
Rafael Espindola d167a25eef Add missing REQUIRES.
llvm-svn: 271799
2016-06-04 19:30:58 +00:00
Rafael Espindola 12dc446939 Fix implicit plt creation on aarch64.
We were not handling page relative relocations.

llvm-svn: 271798
2016-06-04 19:11:14 +00:00
Davide Italiano df24d5b8c8 [LTO] Add --lto-aa-pipeline.
Differential Revision:  http://reviews.llvm.org/D20888

llvm-svn: 271605
2016-06-02 22:58:11 +00:00
Rafael Espindola e37d13b9ec Start adding tlsdesc support for aarch64.
This is mostly extracted from http://reviews.llvm.org/D18960.

The general idea for tlsdesc is that the two GD got entries are used
for a function pointer and its argument. The dynamic linker sets
both. In the non-dlopen case the dynamic linker sets the function to
the identity and the argument to the offset in the tls block.

All that the static linker has to do in the non-dlopen case is
relocate the code to point to the got entries and create a dynamic
relocation.

The dlopen case is more complicated, but can be implemented in another patch.

llvm-svn: 271569
2016-06-02 19:49:53 +00:00
George Rimar f10c8290fa [ELF] - Implemented support for test/binop relaxations from latest ABI.
Patch implements next relaxation from latest ABI:

"Convert memory operand of test and binop into immediate operand, where binop is one of adc, add, and, cmp, or,
sbb, sub, xor instructions, when position-independent code is disabled."

It is described in System V Application Binary Interface AMD64 Architecture Processor 
Supplement Draft Version 0.99.8 (https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r249.pdf, 
B.2 "B.2 Optimize GOTPCRELX Relocations").

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

llvm-svn: 271405
2016-06-01 16:45:30 +00:00
Davide Italiano 64ebf32ef3 [LTO] Fix (incorrect) TLS attribute mismatch.
When we undefine, we also preserve type of symbol so that we get
it right in the combined LTO object.

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

llvm-svn: 271403
2016-06-01 16:38:13 +00:00
Rafael Espindola 3d6d4c39be Handle the -T option.
We were not reading it or including in the --reproduce archive.

llvm-svn: 271367
2016-06-01 06:17:27 +00:00
Rafael Espindola a8433c1d1b Revert "bar"
This reverts commit r271365.
Sorry, wrong branch.

llvm-svn: 271366
2016-06-01 06:15:22 +00:00
Rafael Espindola 74540516ef bar
llvm-svn: 271365
2016-06-01 06:13:54 +00:00
Rafael Espindola 3b1ecb563f Make test more realistic.
It doesn't make mach sense to fetch less than 64 bits from a got
entry.

llvm-svn: 271116
2016-05-28 15:38:13 +00:00
Simon Atanasyan 9a9a3169e3 [ELF][MIPS] Always resolve MIPS GP-relative relocations to 'local' definitions
In case of MIPS, GP-relative relocations always resolve to a definition
in a regular input file, ignoring the one-definition rule. Such
relocations are used to setup GP relative offsets in a function's
prologue. So we, for example, should not attempt to create a dynamic
relocation even if the target symbol is preemptible.

Fixes bug 27880.

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

llvm-svn: 271100
2016-05-28 04:49:57 +00:00
Rafael Espindola 6af546188f Avoid having to check in a binary.
llvm-svn: 270986
2016-05-27 12:27:21 +00:00
Peter Collingbourne 5079f3b727 Update LLD for D20550.
Differential Revision: http://reviews.llvm.org/D20704

llvm-svn: 270968
2016-05-27 05:21:45 +00:00
Simon Atanasyan 84bb355c3a [ELF][MIPS] Handle section symbol points to the .MIPS.options / .reginfo section
MIPS .reginfo and .MIPS.options sections are consumed by the linker, and
the linker produces a single output section. But it is possible that
input files contain section symbol points to the corresponding input
section. In case of generation a relocatable output we need to write
such symbols to the output file.

Fixes bug 27878.

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

llvm-svn: 270910
2016-05-26 20:46:01 +00:00
George Rimar 95433df129 [ELF] - Added support for jmp/call relaxations when R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX are used.
D15779 introduced basic approach to support new relaxations.
This patch implements relaxations for jmp and call instructions,
described in System V Application Binary Interface AMD64 Architecture Processor 
Supplement Draft Version 0.99.8 (https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r249.pdf, 
B.2 "B.2 Optimize GOTPCRELX Relocations")

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

llvm-svn: 270721
2016-05-25 16:51:08 +00:00
Ed Maste 2e04361a21 ELF: improve CIE no-augmentation test
Add another possible error that may be reported for the same case. The
original reproduction case that prompted r270706 produced the error
"corrupted CIE" instead of "corrupted or unsupported CIE information".
The specific error depends on arbitrary data later in the file so
check that neither is emitted in case the input is ever changed.

Document the process used to create the input .o and rename the test
file to .s, as requested by Rafael.

llvm-svn: 270709
2016-05-25 15:14:08 +00:00
Ed Maste 594e06b879 ELF: Handle empty CIE augmentation string
"A zero length string indicates that no augmentation data is present."

The FreeBSD/mips toolchain (GCC 4.2.1) generates .debug_frame sections
containing CIE records that have an empty augmentation string.

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

llvm-svn: 270706
2016-05-25 14:45:28 +00:00
George Rimar 5c33b91bbe [ELF] - Implemented optimization for R_X86_64_GOTPCREL relocation.
System V Application Binary Interface AMD64 Architecture Processor Supplement Draft Version 0.99.8 
(https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r249.pdf, B.2 "B.2 Optimize GOTPCRELX Relocations")
introduces possible relaxations for R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX.

That patch implements the next relaxation: 
mov foo@GOTPCREL(%rip), %reg => lea foo(%rip), %reg
and also opens door for implementing all other ones.

Implementation was suggested by Rafael Ávila de Espíndola with few additions and testcases by myself.

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

llvm-svn: 270705
2016-05-25 14:31:37 +00:00
Rui Ueyama c789b631f3 Really define --export-dynamic-symbol= as an alias to --export-dynamic-symbol.
Thanks to Sean for pointing it out.

llvm-svn: 270660
2016-05-25 04:29:55 +00:00
Rafael Espindola 1f5696f9c1 Fix a wrong assumption.
llvm-svn: 270573
2016-05-24 16:03:27 +00:00
Rafael Espindola 820f4bb972 Handle terminator .eh_frame when creating the index.
llvm-svn: 270568
2016-05-24 15:17:47 +00:00
Rafael Espindola bfffa94ea7 Fix crash in .eh_frame marker section.
llvm-svn: 270563
2016-05-24 14:51:50 +00:00
Rafael Espindola fe3a2f1b81 Revert "Simplify. Thanks to Rui for the suggestion."
This reverts commit r270551.

Sorry, I commited the wrong branch :-(

llvm-svn: 270554
2016-05-24 12:12:06 +00:00
Rafael Espindola dba64b8ea4 Simplify. Thanks to Rui for the suggestion.
llvm-svn: 270551
2016-05-24 11:53:15 +00:00
Rafael Espindola 97434957ef Update for llvm change.
llvm-svn: 270550
2016-05-24 11:16:14 +00:00
Rui Ueyama afa35a2a37 Remove Writer::ensureBss().
Previously, we created a .bss section when needed. We had a function
ensureBss() for that purpose. Turned out that was error-prone
because it was easy to forget to call that function before accessing
the .bss section.

This patch always make the BSS section. The section is added to the
output when it's not empty.

llvm-svn: 270527
2016-05-24 03:16:51 +00:00
Rui Ueyama 98843087cb Reject zero-sized symbols when creating copy relocations.
Copy relocations are relocations to copy data from DSOs to
executable's .bss segment at runtime. It doesn't make sense to
create such relocations for zero-sized symbols.

GNU linkers don't agree with each other. ld rejects such
relocation/symbol pair. gold don't reject that but do not create
copy relocations as well.  I took the former approach because
I don't think the latter is what user wants.

llvm-svn: 270525
2016-05-24 02:37:40 +00:00
Rui Ueyama f86cb90a2d Do not propagate section name and attributes to .eh_frame.
.eh_frame is always ".eh_frame" and its attribute is fixed.
No need to copy from inputs to outputs. GNU gold also sets
SHT_PROGBITS.

llvm-svn: 270443
2016-05-23 15:12:41 +00:00
Rui Ueyama e75e933efc Refactor EhFrameHdr.
Previously, EhFrameHdr section computed addresses to which FDEs are
applied to. This is not an ideal design because EhFrameHdr does not
know much about FDEs unless EhFrame passes the information to EhFrameHdr.
It is what we did.

This patch simplifies the code by making EhFrame to compute the
values and pass the cooked information to EhFrameHdr. EhFrameHdr no
longer have to know about the details of FDEs such as FDE encodings.

llvm-svn: 270393
2016-05-23 03:00:33 +00:00
Rui Ueyama f8b285c037 Refactor EHOutputSection.
This patch refactors EHOutputSection using SectionPiece struct.
EHRegion class was removed since we can now directly use SectionPiece.

An incomplete support of large CIE/FDE record (> 2^32 bytes) was removed
because it silently created broken executable. There are several places
in the existing code that "size" field is always 4 bytes and at offset 4
in the record, which is not true for 64-bit size records. We will have to
support that in future, but it is better to error out instead of creating
malformed eh_frame sections.

llvm-svn: 270382
2016-05-22 23:16:14 +00:00
Simon Atanasyan 1c980ca5aa [ELF] Take into account offset in the output section when read addends for a non-alloc input section
llvm-svn: 270328
2016-05-21 19:48:54 +00:00
Rafael Espindola fb0ceb5153 Check pc relative relocations too.
llvm-svn: 270264
2016-05-20 20:02:27 +00:00
Dima Stepanov fb8978fc6a Fix the function to set the section VMA/LMA fields in case of using
the linker script. The cycle in the ELF/LinkerScript.cpp:assignAddresses()
routine will be used to go through all the sections and set all the
addresses correctly.

Add new test to check this case.

llvm-svn: 270090
2016-05-19 18:15:54 +00:00
Rafael Espindola e4c86d83fe Drop vestigial support for UseLazyBinding=false.
Lazy binding is quite important for use case like a shared build of
llvm. Also, if someone wants to disable it, it is better done in the
compiler (disable plt generation).

The only reason to keep it is to make it easier to add a new
architecture. But it doesn't really help much as it is possible to start
with non lazy relocation and plt code but still let the generic part
create a dedicated .got.plt and .rela.plt.

llvm-svn: 269982
2016-05-18 21:03:36 +00:00
Davide Italiano d26c4a14ca [LTO] Add the ability to specify a subset of passes to run.
Differential Revision:  http://reviews.llvm.org/D20267

llvm-svn: 269605
2016-05-15 19:29:38 +00:00
Rui Ueyama 109ff37430 Update for a recent format change.
llvm-svn: 269496
2016-05-13 21:58:46 +00:00
Rui Ueyama 9194db78fb Support --build-id=0x<hexstring>.
If you specify the option in the form of --build-id=0x<hexstring>,
that hexstring is set as a build ID. We observed that the feature
is actually in use in some builds, so we want this feature.

llvm-svn: 269495
2016-05-13 21:55:56 +00:00