Commit Graph

8292 Commits

Author SHA1 Message Date
George Rimar 5f72e056e7 [ELF] - Add compress-debug-output-i386.s testcase.
This is for --compress-debug-sections (r300444), we have
x64 testcase, but did not have i386 one.

llvm-svn: 300445
2017-04-17 09:04:07 +00:00
George Rimar dbf9339715 [ELF] - Implemented --compress-debug-sections option.
Patch implements --compress-debug-sections=zlib.

In compare with D20211 (a year old patch, abandoned), it implementation
uses streaming and fully reimplemented, does not support zlib-gnu for
simplification.

This is PR32308.

Differential revision: https://reviews.llvm.org/D31941

llvm-svn: 300444
2017-04-17 08:58:12 +00:00
Davide Italiano 0eb8030369 [MachO/X86_64] Simplify isDataInCodeTransition().
llvm-svn: 300385
2017-04-15 01:50:51 +00:00
Davide Italiano 2a34b6395f [MachO/AArch64] Merge multiple switch cases into one. NFCI.
llvm-svn: 300384
2017-04-15 01:42:55 +00:00
Rui Ueyama 3a16769e04 [ELF] Remove unused member [NFC]
Patch by Alexander Richardson.

Differential Revision: https://reviews.llvm.org/D32077

llvm-svn: 300359
2017-04-14 18:38:38 +00:00
George Rimar 1022112d77 [ELF] - Linkerscript: make section with no content to be SHT_PROGBITS by default.
Imagine next script:

SECTIONS { BYTE(0x11); }

Section content written to disk will be 0x11. Previous LLD behavior was to make this
section SHT_NOBITS. What is not correct because section has content.
ld.bfd makes such sections SHT_PROGBITS, this patch do the same.

This fixes PR32537

Differential revision: https://reviews.llvm.org/D32016

llvm-svn: 300317
2017-04-14 09:37:00 +00:00
George Rimar 36a0b98e24 [ELF] - Cleanup of align.s testcase. NFC.
llvm-svn: 300316
2017-04-14 09:30:50 +00:00
George Rimar 01aa795f82 [ELF] LinkerScript: Don't assign zero to all regular symbols
This fixes an assertion `Align != 0u && "Align can't be 0."'
in llvm::alignTo() when a linker script references a globally
defined variable in an ALIGN() context.

Patch by Alexander Richardson !

Differential revision: https://reviews.llvm.org/D31984

llvm-svn: 300315
2017-04-14 09:23:26 +00:00
Peter Collingbourne 8446f1fe6a Object, LTO: Add target triple to irsymtab and LTO API.
Start using it in LLD to avoid needing to read bitcode again just to get the
target triple, and in llvm-lto2 to avoid printing symbol table information
that is inappropriate for the target.

Differential Revision: https://reviews.llvm.org/D32038

llvm-svn: 300300
2017-04-14 02:55:06 +00:00
Peter Collingbourne aa68ca3d5f COFF: Remove some unused fields.
llvm-svn: 300298
2017-04-14 02:34:47 +00:00
Peter Collingbourne c0987938ea ELF: Remove some dead code.
llvm-svn: 300297
2017-04-14 02:34:32 +00:00
Rui Ueyama 0faa53aaab Remove useless local variable.
llvm-svn: 300294
2017-04-14 01:35:04 +00:00
Rui Ueyama c49bdd6d5d Replace uintX_t with uint64_t.
We generally want to use uint64_t instead of uintX_t if the 64-bit
type works for both 32-bit and 64-bit because it is simpler than
the variable-size type.

llvm-svn: 300293
2017-04-14 01:34:45 +00:00
Rui Ueyama 1c2b3c43fe Remove useless namespaces.
llvm-svn: 300284
2017-04-13 23:49:54 +00:00
Rui Ueyama 8acbf1cca9 Rename readOutputSectionFiller parseFill.
"read" is used as a prefix for functions that read tokens from input
streams. This function doesn't really read anything, but just parses
a given string as an integer, so rename.

llvm-svn: 300281
2017-04-13 23:40:19 +00:00
Rui Ueyama 15732b718b Fix FILL linker script command.
FILL command doesn't need a semicolon.
Fixes https://bugs.llvm.org/show_bug.cgi?id=32657

llvm-svn: 300280
2017-04-13 23:40:00 +00:00
Rui Ueyama 3e1fc3f6fe Add "1" suffix if there's varaible ends with "2".
If we knew that we'd add End2, Edata2 and Etext2, we'd name their
original symbols with "1". This patch does it.

llvm-svn: 300263
2017-04-13 21:37:56 +00:00
Rui Ueyama 1505ba826c Replace a clever lambda helper with a simpler one.
llvm-svn: 300259
2017-04-13 21:23:03 +00:00
Peter Smith 4dc4bc4e3c [ELF] Tidy up handleARMTlsRelocation [NFC]
Replace addModuleReloc with AddTlsReloc so that we can use it for both the
module relocation and the offset relocation.

Differential Revision: https://reviews.llvm.org/D31751

llvm-svn: 300192
2017-04-13 10:56:40 +00:00
Peter Smith cec1e260c3 [ELF] Mark ARM Exceptions that refer to folded code as not live
ARM Exception Index Table sections .ARM.exidx have an implicit dependency
on code sections via SHF_LINK_ORDER. When code sections are folded by ICF
we must mark the unique .ARM.exidx table that describes it as not live
to prevent an illegal entry in the exception table.
    
Note that we do not try and follow the relocations from the .ARM.exidx
section to the .ARM.extab sections to mark these as not live. Leaving
these sections is not a correctness problem. In theory these could be
removed via an application of garbage collection.
    
Fixes https://bugs.llvm.org/show_bug.cgi?id=32614

Differential Revision: https://reviews.llvm.org/D31932

llvm-svn: 300182
2017-04-13 08:52:58 +00:00
Rui Ueyama 9d773f3cb2 Add comments for the RELRO segment.
RELRO is a feature to make segments read-only after dynamic relocations
are applied. It is different from read-only segments because RELRO is
initially writable. And of course RELRO is different from writable
segments.

RELRO is not a very well known feature. We have a series of checks to
make a decision whether a section should be in a RELRO segment or not,
but we didn't describe why. This patch adds comments to explain how
that decision is made.

llvm-svn: 300176
2017-04-13 05:40:07 +00:00
Rui Ueyama 3233d3eb46 Do not initialize this->SoName with this->DefaultSoName.
This patch uses DefaultSoName in getSoName instead of in parseSoName.
I think this is more readable. This patch also add comments.

llvm-svn: 300147
2017-04-13 00:23:32 +00:00
Richard Smith a13714ea5f Update to match LLVM r300135.
llvm-svn: 300141
2017-04-12 23:51:20 +00:00
Rui Ueyama 040af7deab Allow expressions in MEMORY command.
Previously, we allowed only integers in this context. Now you can
write expressions there. LLD is now able to handle the following
linker, for example.

  MEMORY { rom (rx) : ORIGIN = (1024 * 1024) }

llvm-svn: 300131
2017-04-12 23:16:52 +00:00
Rui Ueyama e9c9edf67b Make intentional typos look more obvious.
We do not check for similarities when handling unknown tokens in
linker scripts, so "ORIGI" and "LENTH" are not good tokens as a test
for unknown tokens, as I was tempted to "fix" them.

llvm-svn: 300130
2017-04-12 23:16:33 +00:00
Rui Ueyama 732baa4d03 Remove redundant spaces.
llvm-svn: 300129
2017-04-12 23:16:13 +00:00
Rui Ueyama 53e0fd33d4 Remove useless 0x prefixes.
llvm-svn: 300128
2017-04-12 23:15:55 +00:00
Rui Ueyama 58c18f8f23 Make a few tests shorter. NFC.
llvm-svn: 300120
2017-04-12 22:38:02 +00:00
Bob Haarman dd4b4325ee [coff] default to multiple parallel ThinLTO jobs
Summary:
lld-link allows the number of parallel ThinLTO jobs to be specified
using /opt:lldltojobs=N. If left unspecified, the implementation
conservatively defaults to 1. This leads to very long link times. This
change makes it so that the default is to automatically set the
parallelism, as we do in the ELF linker.

Reviewers: ruiu, hans

Reviewed By: ruiu, hans

Subscribers: pcc, mehdi_amini, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D31986

llvm-svn: 300089
2017-04-12 18:36:13 +00:00
Rui Ueyama 5c5bc7bc0a Accept not only lld-link but also LLD-LINK, for example.
Filenames are case-insensitive on Windows, so when we dispatch based
on argv0, we need to handle it case-insensitively.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32637.

llvm-svn: 300087
2017-04-12 18:29:52 +00:00
Evgeniy Stepanov a76349bffe [lld] Keep full library path in DT_NEEDED.
Fixes PR32572.

When
    (a) a library has no soname
and (b) library is given on the command line with path (and not through -L/-l flags)
DT_NEEDED entry for such library keeps the path as given.

This behavior is consistent with gold and bfd, and is used in compiler-rt test suite.

This is a second attempt after r300007 got reverted. This time relro-omagic test is
changed in a way to avoid hardcoding the path to the test directory in the objdump'd
binary.

llvm-svn: 300011
2017-04-12 00:13:48 +00:00
Evgeniy Stepanov d512afe3da Revert "[lld] Keep full library path in DT_NEEDED."
This reverts commit r300007. Reason: breaks all the bots.

llvm-svn: 300008
2017-04-12 00:01:21 +00:00
Evgeniy Stepanov 2c2dcae13c [lld] Keep full library path in DT_NEEDED.
Fixes PR32572.

When
    (a) a library has no soname
and (b) library is given on the command line with path (and not through -L/-l flags)
DT_NEEDED entry for such library keeps the path as given.

This behavior is consistent with gold and bfd, and is used in compiler-rt test suite.

llvm-svn: 300007
2017-04-11 23:46:58 +00:00
Rui Ueyama b58079d4e2 Remove big-endianness from =<fillexp> code.
llvm-svn: 300005
2017-04-11 22:45:57 +00:00
Rui Ueyama 8f8c2f9599 Call getFiller only when filler is not zero.
llvm-svn: 300004
2017-04-11 22:45:38 +00:00
Evgeniy Stepanov 6c973d647f [lld] --export-dynamic overrides --dynamic-list.
Fixes PR32573.

--export-dynamic exports everything, even in the presence of a --dynamic-list,
or --export-dynamic-symbol.

llvm-svn: 300002
2017-04-11 22:37:54 +00:00
Reid Kleckner 6e545ffc4e [PDB] Emit index/offset pairs for TPI and IPI streams
Summary:
This lets PDB readers lookup type record data by type index in O(log n)
time. It also enables makes `cvdump -t` work on PDBs produced by LLD.
cvdump will not dump a PDB that doesn't have an index-to-offset table.

The table is sorted by type index, and has an entry every 8KB. Looking
up a type record by index is a binary search of this table, followed by
a scan of at most 8KB.

Reviewers: ruiu, zturner, inglorion

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31636

llvm-svn: 299958
2017-04-11 16:26:15 +00:00
George Rimar e7bf968803 [ELF] - Stop producing broken output for R_386_GOT32[X] relocations.
Previously we silently produced broken output for R_386_GOT32X/R_386_GOT32 
relocations if they were used to compute the address of the symbol’s global
offset table entry without base register when position-independent code is disabled.

Situation happened because of recent ABI changes. Released ABI mentions that
R_386_GOT32X can be calculated in a two different ways (so we did not follow ABI here 
before this patch), but draft ABI also mentions R_386_GOT32 relocation here. 
We should use the same calculations for both relocations.

Problem is that we always calculated them as G + A - GOT (offset from end of GOT),
but for case when PIC is disabled, according to i386 ABI calculation should be G + A,
what should produce just an address in GOT finally.

ABI: https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-draft.pdf (p36, p60).
llvm-svn: 299812
2017-04-08 06:14:14 +00:00
Reid Kleckner c9bc745518 Remove .rdata section size checks from pdb.test, they are not the same on Windows and Unix
llvm-svn: 299795
2017-04-07 19:58:33 +00:00
Reid Kleckner f519ef0990 [PDB] Re-add RAW FileCheck testing to pdb.test
Update the expected output to match the current llvm-pdbdump raw output.

llvm-svn: 299793
2017-04-07 18:38:38 +00:00
Rafael Espindola e4c8b9b78c Simplify this further.
Thanks to Rui for noticing it.

llvm-svn: 299777
2017-04-07 16:10:46 +00:00
Simon Atanasyan 60d0e982f0 [ELF] Do not pass GOT section as an argument to handleARMTlsRelocation and handleMipsTlsRelocation functions. NFC
Both functions always use the same GOT sections In<ELFT>::Got and
In<ELFT>::MipsGot respectively, so we do not need to pass them as an
argument.

llvm-svn: 299773
2017-04-07 15:05:44 +00:00
James Henderson 9d9a663731 [ELF] Recommit r299635 to pad x86 executable sections with 0xcc
This follows r299748 which fixed a latent bug the original commit exposed.

llvm-svn: 299755
2017-04-07 10:36:42 +00:00
Peter Smith 99a992343c [ELF] Fix ARM TLS global dynamic TlsOffsetRel for non-preemtible symbols
When the target of the TlsOffsetRel is non-preemptible we can write the
offset directly into the GOT without needing a dynamic relocation. This
is optional for dynamically linked executables but is required for static
linking.
    
This change adds the relocation to the GOT entry and a test case for
non-0 offsets so that if we miss out the offset the test won't spuriously
pass by virtue of the default value being 0.

Differential Revision: https://reviews.llvm.org/D31749

llvm-svn: 299751
2017-04-07 09:37:30 +00:00
Peter Smith a630d0f01b [ELF] Split handleNoRelaxTlsRelocation into ARM and Mips specific impls
The handleNoRelaxTlsRelocation handled both ARM and Mips as at a
high-level the actions of what to do when encountering a local dynamic or
global dynamic TLS relocation are the same. However due to Mips using a
custom GOT the differences of the implementation are enough that the
function became difficult to understand.
    
This change replaces handleNotRelaxTlsRelocation into
handleARMTlsRelocation() and handleMipsTlsRelocation() so that the ARM and
Mips specific code is isolated.

Differential Revision: https://reviews.llvm.org/D31748

llvm-svn: 299750
2017-04-07 09:09:48 +00:00
James Henderson db664b6c86 Fix signed/unsigned comparison warning in a unit test. This was appearing on
lld-x86_64-darwin13.

llvm-svn: 299749
2017-04-07 08:48:17 +00:00
James Henderson 8abda20a9f [Core] Fix parallel_for for Linux
r299635 exposed a latent bug in the Linux implementation of parallel_for, which
resulted in it calling the function outside of the range requested, resulting
later in a segmentation fault. This change fixes this issue and adds a unit test.

llvm-svn: 299748
2017-04-07 08:11:28 +00:00
Rafael Espindola dc8eb810db Move a cast out of a function. NFC.
The argument was always casted, so cast it in the caller.

llvm-svn: 299742
2017-04-07 01:40:21 +00:00
Rafael Espindola 7f91d44fba Remove unnecessary cast.
llvm-svn: 299740
2017-04-07 01:25:01 +00:00
Saleem Abdulrasool 671029daec COFF: support the /appcontainer flag
The /appcontainer flag indicates that the module may only be used inside
an application container (for isolation).  This has been supported by
link.exe since Windows 8.0.  It sets an additional bit in the PE DLL
Characteristics flag to indicate the behavioural change.

llvm-svn: 299728
2017-04-06 23:07:53 +00:00