Commit Graph

5624 Commits

Author SHA1 Message Date
Alex Denisov bb241249df Replace hardcoded comment at 'lit.site.cfg.in'
At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266521
2016-04-16 07:09:39 +00:00
Davide Italiano 493b683f79 [LTO] Don't crash on a BitcodeFile without DataLayout.
Emit an error instead.

llvm-svn: 266504
2016-04-16 01:33:33 +00:00
Davide Italiano 0ce90908e0 [LTO] Add datalayout to test to prevent an assertion in Debug mode.
While here, run this test only on x86.

llvm-svn: 266487
2016-04-15 22:58:57 +00:00
Rui Ueyama faac567e68 Revert r266457: "[ELF] - Implemented basic location counter support."
This reverts commit r266457 as it breaks "hello world" both on
Linux and FreeBSD.

llvm-svn: 266485
2016-04-15 22:39:27 +00:00
Davide Italiano bc176631cd [LTO] Implement parallel Codegen for LTO using splitCodeGen.
Parallelism level can be chosen using the new --lto-jobs=K option
where K is the number of threads used for CodeGen. It currently
defaults to 1.

llvm-svn: 266484
2016-04-15 22:38:10 +00:00
Rafael Espindola 5628ee7631 Simplify got handling.
Each getRelExpr is now expected to return the correct got expression
instead of having Writer patch it up with needsGot.

llvm-svn: 266466
2016-04-15 19:14:18 +00:00
Rafael Espindola 7dd20563a2 Merge duplicated cases. NFC.
llvm-svn: 266459
2016-04-15 17:57:27 +00:00
George Rimar ea25877d4a [ELF] - Implemented basic location counter support.
This patch implements location counter support. 
It also separates assign addresses for sections to assignAddressesScript() if it scipt exists.

Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now.
Implemented location counter assignment and '+' operations.

Patch by myself with LOTS of comments and design suggestions from Rui Ueyama.

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

llvm-svn: 266457
2016-04-15 17:44:19 +00:00
Mandeep Singh Grang 01ae1daafe [LLD] Remove unwanted --check-prefix=CHECK from unit tests. NFC.
Summary:
Removed unwanted --check-prefix=CHECK from the following unit tests:
      ELF/aarch64-gnu-ifunc.s
      ELF/gnu-ifunc-i386.s
      ELF/gnu-ifunc.s
      ELF/plt-i686.s

Patch by: Mandeep Singh Grang (mgrang)

Reviewers: rafael

Subscribers: aemerson

Projects: #lld

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

llvm-svn: 266453
2016-04-15 17:21:29 +00:00
Rafael Espindola ab1923d63c Add an interesting GC testcase.
It shows that we correctly look at liveness based on the final symbol
resolution.

llvm-svn: 266440
2016-04-15 15:26:52 +00:00
Rafael Espindola 38c67a27fe Store a Symbol for EntrySym.
This makes it impossible to forget to call repl on the SymbolBody.

llvm-svn: 266432
2016-04-15 14:41:56 +00:00
Rafael Espindola 11c7fd300e Add a testcase for symbol resolution with -r.
llvm-svn: 266429
2016-04-15 14:11:36 +00:00
Rafael Espindola 69a38060a8 Don't create relocations for absolute got entries.
llvm-svn: 266427
2016-04-15 12:44:43 +00:00
Rafael Espindola f8f6ad74a0 Don't create relocations for non preemptable absolute symbols.
llvm-svn: 266425
2016-04-15 12:22:22 +00:00
Rafael Espindola 3666025880 Two small related fixes.
* A hidden undefined is not preemptable.
* It is always zero, so we don't need a dynamic reloc for it.

llvm-svn: 266424
2016-04-15 11:57:07 +00:00
Simon Atanasyan 7ac68ccdc0 [ELF] Remove redundant empty line. NFC
llvm-svn: 266421
2016-04-15 09:47:36 +00:00
Rafael Espindola 5ffa13c473 Delete a dead repl.
It is only ever used on symbols taken from the symbol table.

llvm-svn: 266391
2016-04-15 00:15:02 +00:00
Rui Ueyama 34b60f1c40 Do not use llvm::getGlobalContext().
llvm-svn: 266375
2016-04-14 21:41:44 +00:00
Mehdi Amini 03a5042e4c Revert "Do not use llvm::getGlobalContext(), trying to nuke it from LLVM"
This reverts commit r266365 and r266367, the contexts in the two
places have to match.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266373
2016-04-14 21:31:46 +00:00
Simon Atanasyan 1ca263c890 [ELF][MIPS] Make R_MIPS_LO16 a relative relocation if it references _gp_disp symbol
The _gp_disp symbol designates offset between start of function and 'gp'
pointer into GOT. The following code is a typical MIPS function preamble
used to setup $gp register:

lui    $gp, %hi(_gp_disp)
addi   $gp, $gp, %lo(_gp_disp)

To calculate R_MIPS_HI16 / R_MIPS_LO16 relocations results we use
the following formulas:

%hi(_gp - P + A)
%lo(_gp - P + A + 4),
where _gp is a value of _gp symbol, A is addend, and P current address.

The R_MIPS_LO16 relocation references _gp_disp symbol is always the second
instruction. That is why we need four byte adjustments. The patch assigns
R_PC type for R_MIPS_LO16 relocation and adjusts its addend by 4. That fix
R_MIPS_LO16 calculation.

For details see p. 4-19 at ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

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

llvm-svn: 266368
2016-04-14 21:10:05 +00:00
Mehdi Amini 9a15293ec1 Use fully qualified name to refer to LLVMContext
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266367
2016-04-14 21:09:10 +00:00
Mehdi Amini f1e7ff9d0e Do not use llvm::getGlobalContext(), trying to nuke it from LLVM
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266365
2016-04-14 20:53:39 +00:00
Rafael Espindola 7f0b727235 Specialize the symbol table data structure a bit.
We never need to iterate over the K,V pairs, so we can avoid copying the
key as MapVector does.

This is a small speedup on most benchmarks.

llvm-svn: 266364
2016-04-14 20:42:43 +00:00
Rafael Espindola c9157d35d9 Hash symbol names only once per global SymbolBody.
The DenseMap doesn't store hash results. This means that when it is
resized it has to recompute them.

This patch is a small hack that wraps the StringRef in a struct that
remembers the hash value. That way we can be sure it is only hashed
once.

llvm-svn: 266357
2016-04-14 19:17:16 +00:00
Rafael Espindola 3151d89595 Simplify handling of size relocations. NFC.
llvm-svn: 266355
2016-04-14 18:39:44 +00:00
George Rimar 5cfd306e00 Move variables closer to code scopes that uses them. NFC.
llvm-svn: 266340
2016-04-14 17:05:56 +00:00
Rafael Espindola e149b488af Remove the only case where we would relocate a R_386_TLS_TPOFF.
llvm-svn: 266330
2016-04-14 16:05:42 +00:00
Rafael Espindola c1c14a227e Merge duplicated cases. NFC.
llvm-svn: 266328
2016-04-14 15:56:14 +00:00
Rafael Espindola 735bbaa1d9 Add missing typename.
llvm-svn: 266318
2016-04-14 14:40:38 +00:00
George Rimar 8bbff7ec85 [ELF] - Refactoring of end/edata/etext implementation.
Minor refactoring of how end/edata/etext symbols are handled.

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

llvm-svn: 266317
2016-04-14 14:37:59 +00:00
George Rimar 4c2ae3a171 Return back the zero parameter of aggregate initialization in OutputSectionFactory::lookup().
That was removed in r266304, but leads to warnings by Clang.
Thanks to Rafael Espíndola for pointing on that.

Though I think change was legal from point of C++.

llvm-svn: 266306
2016-04-14 14:24:23 +00:00
George Rimar d502f47726 Make OutputSectionFactory::lookup() inline. NFC.
Also I removed the last zero parameter of 
aggregate initialization as it is excessive here.

llvm-svn: 266304
2016-04-14 14:07:54 +00:00
George Rimar 2122168912 Removed excessive line. NFC.
llvm-svn: 266303
2016-04-14 13:56:28 +00:00
George Rimar 0fa18b8923 Reduce expression to single line. NFC.
llvm-svn: 266302
2016-04-14 13:47:04 +00:00
George Rimar ee741cfa5f Clang formated file. NFC.
llvm-svn: 266299
2016-04-14 13:23:02 +00:00
George Rimar 4e8cf85b74 Combine code branch into single line. NFC.
llvm-svn: 266298
2016-04-14 13:00:03 +00:00
Peter Collingbourne 0a68cf50f8 ELF: Do not create copy relocations for references in writable sections.
They are unnecessary, as the dynamic loader can apply the original relocations
directly. This was also resulting in the creation of copy relocations in PIEs.

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

llvm-svn: 266273
2016-04-14 01:48:11 +00:00
Rafael Espindola 3fa7352fc7 Fix warning about unused variable.
llvm-svn: 266232
2016-04-13 19:09:48 +00:00
Rafael Espindola ab14c88984 git-clang-format. NFC.
llvm-svn: 266231
2016-04-13 19:07:40 +00:00
Rafael Espindola f9d3dcf0a8 Don't set MustBeInDynSym for hidden symbols.
llvm-svn: 266230
2016-04-13 19:03:34 +00:00
Adhemerval Zanella 9df0720766 ELF: Implement --dynamic-list
This patch implements the --dynamic-list option, which adds a list of
global symbol that either should not be bounded by default definition
when creating shared libraries, or add in dynamic symbol table in the
case of creating executables.

The patch modifies the ScriptParserBase class to use a list of Token
instead of StringRef, which contains information if the token is a
quoted or unquoted strings. It is used to use a faster search for
exact match symbol name.

The input file follow a similar format of linker script with some
simplifications (it does not have scope or node names). It leads
to a simplified parser define in DynamicList.{cpp,h}.

Different from ld/gold neither glob pattern nor mangled names
(extern 'C++') are currently supported.

llvm-svn: 266227
2016-04-13 18:51:11 +00:00
George Rimar 2a78fceb2c [ELF] - Change -t implementation to print which archive members are used.
Previously each archive file was reported no matter were it's member used or not,
like:
lib/libLLVMSupport.a

Now lld prints line for each used internal file, like:
lib/libLLVMSupport.a(lib/Support/CMakeFiles/LLVMSupport.dir/StringSaver.cpp.o)
lib/libLLVMSupport.a(lib/Support/CMakeFiles/LLVMSupport.dir/Host.cpp.o)
lib/libLLVMSupport.a(lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o)

That should be consistent with what gold do.

This fixes PR27243.

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

llvm-svn: 266220
2016-04-13 18:07:57 +00:00
Peter Collingbourne f6e9b4ec24 ELF: Use hidden visibility for all DefinedSynthetic symbols.
This simplifies the code by allowing us to remove the visibility argument
to functions that create synthetic symbols.

The only functional change is that the visibility of the MIPS "_gp" symbol
is now hidden. Because this symbol is defined in every executable or DSO, it
would be difficult to observe a visibility change here.

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

llvm-svn: 266208
2016-04-13 16:57:28 +00:00
Rafael Espindola 9b46861eae Test dynamic relocations pointing to __stop_ symbols.
llvm-svn: 266207
2016-04-13 16:33:02 +00:00
Peter Collingbourne 1f71d748ae ELF: Do not create relative relocations for undefined symbols.
We need to ensure that the address of an undefined weak symbol evaluates to
zero. We were getting this right for non-PIC executables (where the symbol
can be evaluated directly) and for DSOs (where we emit a symbolic relocation
for these symbols, as they are preemptible). But we weren't getting it right
for PIEs. Probably the simplest way to ensure that these symbols evaluate
to zero is by not creating a relocation in .got for them.

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

llvm-svn: 266161
2016-04-13 02:24:48 +00:00
Rafael Espindola 22ef956a45 Change how we apply relocations.
With this patch we use the first scan over the relocations to remember
the information we found about them: will them be relaxed, will a plt be
used, etc.

With that the actual relocation application becomes much simpler. That
is particularly true for the interfaces in Target.h.

This unfortunately means that we now do two passes over relocations for
non SHF_ALLOC sections. I think this can be solved by factoring out the
code that scans a single relocation. It can then be used both as a scan
that record info and for a dedicated direct relocation of non SHF_ALLOC
sections.

I also think it is possible to reduce the number of enum values by
representing a target with just an OutputSection and an offset (which
can be from the start or end).

This should unblock adding features like relocation optimizations.

llvm-svn: 266158
2016-04-13 01:40:19 +00:00
Rafael Espindola a969b2ed0e Add test for the interaction of copy relocations and non alloc sections.
llvm-svn: 266143
2016-04-12 22:36:05 +00:00
Rafael Espindola 91641d9947 Add a few more cases to this test.
It now documents how we currently handle relocations for
alloc/non-alloc.

llvm-svn: 266141
2016-04-12 22:08:23 +00:00
Davide Italiano 3774afba07 [COFF] Simplify the code leveraging implicit conversion.
Suggested by: David Blaikie!

llvm-svn: 266140
2016-04-12 22:05:38 +00:00
Peter Collingbourne 173ee84530 ELF: Give automatically generated __start_* and __stop_* symbols hidden visibility.
These symbols describe a property of a linkage unit, so it seems reasonable
to limit their visibility to the linkage unit. Furthermore the use cases I
am aware of do not require more than hidden visibility.

This is a departure from the behavior of the bfd and gold linkers. However,
it is unclear that the decision to give these symbols default visibility
in those linkers was made deliberately. The __start_*/__stop_* feature
was added to the bfd linker in 1994 [1], while the visibility feature was
added about five years later [2], so it may have been that the visibility
of these symbols was not considered. The feature was implemented in gold
[3] in the same way; the behavior may have simply been copied from bfd.

The only related discussion I could find on the binutils mailing list [4]
was a user issue which would most likely not have occurred if the symbols
had hidden visibility.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=5efddb2e7c3229b569a862205f61d42860af678b
[2] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=0fc731e447cd01e7fc35197b487ff0e4fd25afca
[3] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bfd58944a64b0997a310b95fbe0423338961e71c
[4] https://sourceware.org/ml/binutils/2014-05/msg00011.html

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

llvm-svn: 266121
2016-04-12 20:41:42 +00:00