Commit Graph

4552 Commits

Author SHA1 Message Date
Rui Ueyama e79b09a616 ELF: Make .note.GNU-stack more compatible with traditional linkers.
With this patch, lld creates PT_GNU_STACK segments only when all input
files have .note.GNU-stack sections. This is in line with other linkers
with a minor difference (we don't care about .note.GNU-stack rwx bits as
you can always remove .note.GNU-stack sections instead of setting x bit.)

At least, NetBSD loader does not understand PT_GNU_STACK segments and
reject any executables that have the section. This patch makes lld
compatible with such operating systems.

llvm-svn: 253797
2015-11-21 22:19:32 +00:00
Rui Ueyama df06d203e5 Update documents.
llvm-svn: 253728
2015-11-20 22:47:42 +00:00
Rui Ueyama 8486a51845 Remove trailing whitespaces and untabify.
llvm-svn: 253727
2015-11-20 22:47:40 +00:00
Davide Italiano dc67f9b7e8 [ELF/AArch64] Add support for LDST8_ABS_LO12_NC/LDST64_ABS_LO12_NC.
These two relocations where the only missing step to get a dynamically
linked (with libc) "hello world" on FreeBSD.

llvm-svn: 253714
2015-11-20 21:35:38 +00:00
Rui Ueyama 6220fd8bfd Define -E as an alias for --export-dynamic.
llvm-svn: 253713
2015-11-20 21:22:53 +00:00
Rui Ueyama 03bec877c5 Remove default values that are always overriden in Driver.cpp.
llvm-svn: 253710
2015-11-20 21:00:42 +00:00
Igor Kudrin 2f610d5e13 [ELF/AArch64] Accept -m aarch64linux.
This option is passed by clang driver if the target triple
is "aarch64-unknown-linux".

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

llvm-svn: 253639
2015-11-20 02:48:53 +00:00
Igor Kudrin b044af50f2 [ELF] Define symbols "_end" and "end" if referenced.
These symbols are expected to point to the end of the data segment.

Implements http://llvm.org/pr25528.

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

llvm-svn: 253637
2015-11-20 02:32:35 +00:00
Rui Ueyama d94478b04e Remove redundant namespace specifiers.
llvm-svn: 253635
2015-11-20 02:19:36 +00:00
Rui Ueyama 2022e81af0 Make a function out-of-line.
There's no need to write it in a .h file.

llvm-svn: 253633
2015-11-20 02:10:52 +00:00
Rui Ueyama 2dc3f8c278 Remove redundant "using namespace".
llvm-svn: 253632
2015-11-20 01:59:16 +00:00
Rui Ueyama dfa577bafb Fix formatting.
llvm-svn: 253620
2015-11-19 23:30:10 +00:00
Igor Kudrin 4bc5ad4c37 [ELF] Prevent SEGFAULT in case of conflict with an internally defined symbol.
Differential Revision: http://reviews.llvm.org/D14832

llvm-svn: 253588
2015-11-19 19:08:45 +00:00
Rui Ueyama 905c41b00d Update "Getting Started" document.
llvm-svn: 253522
2015-11-18 23:53:19 +00:00
Ed Maste c98805b493 Accept -whole-archive and -no-whole-archive (with a single dash)
Clang uses the single-dash version in addSanitizerRuntime().

llvm-svn: 253477
2015-11-18 17:22:02 +00:00
Rafael Espindola 9c8904fb38 Rename ld.lld2 to ld.lld since it is the default.
llvm-svn: 253437
2015-11-18 06:11:01 +00:00
David Majnemer 8a4be35c9c Adjust test from fallout due to r253429
As a side note, the jump target is much nicer than before.

We went from: <bar+...> to <.plt>

llvm-svn: 253433
2015-11-18 04:37:23 +00:00
Peter Collingbourne 70507e59fe COFF: Destroy LTOModules as they are linked.
This should help reduce memory consumption during LTO.

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

llvm-svn: 253397
2015-11-17 23:30:59 +00:00
Yunzhong Gao fbee89263f Fixing build failures caused by r253367. Sorry for breaking the build.
llvm-svn: 253374
2015-11-17 20:48:12 +00:00
Igor Kudrin db7de9f590 [ELF2/AArch64] Add lazy relocation support for AArch64.
Differential Revision: http://reviews.llvm.org/D14749

llvm-svn: 253352
2015-11-17 18:01:30 +00:00
Igor Kudrin e7ad0937bb [ELF2] getPLTRefReloc() -> getPltRefReloc().
llvm-svn: 253351
2015-11-17 17:47:53 +00:00
Rafael Espindola 7477e99af7 Make ELF2 the default.
With this the only way to get the old elf linker is "-flavor old-elf".

llvm-svn: 253318
2015-11-17 07:19:44 +00:00
Rafael Espindola 4b1285c55a Rename test/elf2 to test/ELF.
llvm-svn: 253313
2015-11-17 05:36:42 +00:00
Rafael Espindola f16ba74ed2 Rename test/elf to test/old-elf.
llvm-svn: 253312
2015-11-17 05:34:56 +00:00
Rafael Espindola 97a8695aa1 Rename gnu2 to gnu.
This is the second step in making ELF2 the default.

llvm-svn: 253270
2015-11-16 23:21:55 +00:00
Igor Kudrin 351b41de4e [ELF2] Remove target specific code from GotPltSection.
The content of reserved entries of the .got.plt section is target specific.

In particular, on x86_64 the zero entry holds the address of the .dynamic section,
but on AArch64 the same info is stored in the zero entry of the .got section.

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

llvm-svn: 253239
2015-11-16 17:44:08 +00:00
Rafael Espindola 7467461ccc Rename the gnu flavour to gnu old.
This is the first step in making ELF2 the default.

llvm-svn: 253188
2015-11-16 08:54:19 +00:00
George Rimar 03220309e1 [ELF2] - Implemented PT_GNU_STACK support, -z execstack option.
PT_GNU_STACK is a entry in the elf file format which contains the access rights (read, write, execute) of the stack,
it is always generated now. By default stack is not executable in this implementation. 
-z execstack can be used to make executable.

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

llvm-svn: 253145
2015-11-14 20:56:08 +00:00
Rui Ueyama 1d37e60dc5 ELF2: Make comment less opinionated.
llvm-svn: 253058
2015-11-13 18:56:07 +00:00
George Rimar 687138c7d1 [ELF2] - Implemented R_X86_64_GOTTPOFF relocation
Generates single GOT entry, R_X86_64_TPOFF64 is added to RelaDyn.

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

llvm-svn: 253049
2015-11-13 16:28:53 +00:00
Rafael Espindola f8ce28676a Use ld.lld2, not -flavor gnu2
llvm-svn: 253044
2015-11-13 15:01:17 +00:00
George Rimar 4b40ebce66 [ELF2] - fix of eh-frame-merge.s and eh-frame-merge.s tests fails for win32 configuration.
llvm-svn: 253043
2015-11-13 13:44:59 +00:00
George Rimar 51e37d9997 [ELF2] - dont merge .data.rel.ro/.data.rel.ro.local into .data section.
This sections can be protected with relro after resolving relocations by dynamic linker.

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

llvm-svn: 253018
2015-11-13 07:56:27 +00:00
Denis Protivensky e1a89c2d1c Fix failing test on Windows
Remove backslash before redirection as it causes
echo to fail on Windows.

llvm-svn: 253017
2015-11-13 07:19:20 +00:00
Igor Kudrin b34115b7fe [ELF2/AArch64] Add support for R_AARCH64_CALL26 and R_AARCH64_JUMP26.
This patch covers only the case where no DSO is involved.

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

llvm-svn: 253007
2015-11-13 03:26:59 +00:00
Michael J. Spencer ecd7f377dd [elf2] get{Local,Global}DynamicReloc -> is{LocalGlobal}DynamicReloc.
llvm-svn: 252982
2015-11-13 00:32:58 +00:00
Michael J. Spencer 627ae703b5 [elf2] Implement global dynamic tls.
llvm-svn: 252979
2015-11-13 00:28:34 +00:00
Rui Ueyama a6f103f705 ELF2: Add comments and reorganize option list a bit.
llvm-svn: 252978
2015-11-13 00:26:12 +00:00
Rui Ueyama b2f6fc177c Early continue. NFC.
llvm-svn: 252935
2015-11-12 19:45:58 +00:00
Rui Ueyama 92ce0e9122 ELF2: Make type a bit stricter. NFC.
llvm-svn: 252934
2015-11-12 19:42:43 +00:00
Rui Ueyama 1a8fffa2fb ELF2: Simplify -z option handling. NFC.
llvm-svn: 252924
2015-11-12 19:00:37 +00:00
Rui Ueyama f5bcf2a72f ELF2: Print an error message for --relocatable.
llvm-svn: 252923
2015-11-12 18:54:15 +00:00
Denis Protivensky 8e3b38aba1 [ELF2] SECTIONS command basic support
* determine output section by input section name
* discard input sections
* order output sections accordingly

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

llvm-svn: 252868
2015-11-12 09:52:08 +00:00
Denis Protivensky 1b1b34ef95 [ELF2] Fix gcc warning in section kind switch
llvm-svn: 252864
2015-11-12 09:11:20 +00:00
Igor Kudrin 304860ab67 [ELF2] Add mandatory .dynamic section entries on MIPS.
The MIPS target requires specific dynamic section entries to be defined.

 * DT_MIPS_RLD_VERSION and DT_MIPS_FLAGS store predefined values.
 * DT_MIPS_BASE_ADDRESS holds base VA.
 * DT_MIPS_LOCAL_GOTNO holds the number of local GOT entries.
 * DT_MIPS_SYMTABNO holds the number of .dynsym entries.
 * DT_MIPS_GOTSYM holds the index of the .dynsym entry
   which corresponds to the first entry of the global part of GOT.
 * DT_MIPS_RLD_MAP holds the address of the reserved space in the data segment.
 * DT_MIPS_PLTGOT points to the .got.plt section if it exists.
 * DT_PLTGOT holds the address of the GOT section.

See "Dynamic Section" in Chapter 5 in the following document for detailed
description: ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

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

llvm-svn: 252857
2015-11-12 04:39:49 +00:00
Igor Kudrin f4cdfe88ee [ELF2] Sort dynamic symbols according to the MIPS requirements.
The MIPS ABI has requirements to sort the entries in the .dyn.sym section.
Symbols which are not in the GOT have to precede the symbols which are added to
the GOT. The latter must have the same order as the corresponding GOT entries.

Since these sorting requirements contradict those of the GNU hash section,
they cannot be used together.

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

llvm-svn: 252854
2015-11-12 04:08:12 +00:00
Rafael Espindola 0c6a4f197f Add support for processing .eh_frame.
This adds support for:
* Uniquing CIEs
* Dropping FDEs that point to dropped sections

It drops 657 488 bytes from the .eh_frame of a Release+Asserts clang.

The link time impact is smallish. Linking clang with a Release+Asserts
lld goes from 0.488064805 seconds to 0.504763060 seconds (1.034 X slower).

llvm-svn: 252790
2015-11-11 19:54:14 +00:00
Rafael Espindola 7c84aecb58 Fix indentation. Thank to David Blaikie for noticing.
llvm-svn: 252759
2015-11-11 17:40:08 +00:00
Rafael Espindola a016b1e186 Canonicalize the type of .eh_frame.
GNU as can give it type SHT_PROGBITS or SHT_X86_64_UNWIND depending on
teh construct.

MC gives it type SHT_X86_64_UNWIND.

The linker has to canonicalize to one or the other so that there is only
one .eh_frame in the end.

llvm-svn: 252757
2015-11-11 17:33:22 +00:00
Rafael Espindola db9bf4dbfe Add a helper for getting the output offset of an input offset.
This will get a non st_value use shortly.

llvm-svn: 252753
2015-11-11 16:50:37 +00:00