Commit Graph

6976 Commits

Author SHA1 Message Date
Rafael Espindola ca656239eb Compact SymbolBody from 56 to 48 bytes.
llvm-svn: 284878
2016-10-21 20:32:41 +00:00
Rafael Espindola 8b2c8536e5 Use a CachedHashString for comdats too.
We were already using it in the larger sets/maps. This provides about
1% speedup in linking xul and chromium.

llvm-svn: 284862
2016-10-21 19:49:42 +00:00
Rui Ueyama fe4c9f96c6 Use FileCheck's -strict-whitespace option instead of sed.
llvm-svn: 284846
2016-10-21 17:50:26 +00:00
Peter Smith 580ba95b16 [ELF] Add sh_link field to .ARM.exidx sections for relocatable links
When doing a relocatable link the .ARM.exidx sections with the
SHF_LINK_ORDER flag set need to set the sh_link field to the executable
section they describe. We find the appropriate OutputSection by
following the sh_link field of the .ARM.exidx InputSections.
    
The getOutputSectionName() function rules make sure that when there are
multiple .ARM.exidx InputSections in an OutputSection they all have the
same sh_link field.

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

llvm-svn: 284820
2016-10-21 11:25:33 +00:00
George Rimar 032fa65606 [ELF] Add DebugInfoDWARF dependency
rL284708 introduces a link error when building with BUILD_SHARED_LIBS:

undefined reference to `llvm::DWARFContext::parseCompileUnits()'
undefined reference to `llvm::DWARFContextInMemory::DWARFContextInMemory(
                            llvm::object::ObjectFile const&,
                            llvm::LoadedObjectInfo const*)'
The functions are available in libDebugInfoDWARF, from llvm.

Patch by Visoiu Mistrih Francis

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

llvm-svn: 284810
2016-10-21 07:46:24 +00:00
Simon Atanasyan bed04bf1df [ELF][MIPS] Put local GOT entries accessed via a 16-bit index first
Some MIPS relocations used to access GOT entries are able to manipulate
16-bit index. The other ones like R_MIPS_CALL_HI16/LO16 can handle
32-bit indexes. 16-bit relocations are generated by default. The 32-bit
relocations are generated by -mxgot flag passed to compiler. Usually
these relocation are not mixed in the same code but files like crt*.o
contain 16-bit relocations so even if all "user's" code compiled with
-mxgot flag a few 16-bit relocations might come to the linking phase.

Now LLD does not differentiate local GOT entries accessed via a 16-bit
and 32-bit indexes. That might lead to relocation's overflow if 16-bit
entries are allocated to far from the beginning of the GOT.

The patch introduces new "part" of MIPS GOT dedicated to the local GOT
entries accessed by 32-bit relocations. That allows to put local GOT
entries accessed via a 16-bit index first and escape relocation's overflow.

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

llvm-svn: 284809
2016-10-21 07:22:30 +00:00
Rui Ueyama 34b411f077 Simplify. NFC.
llvm-svn: 284806
2016-10-21 04:52:13 +00:00
Rui Ueyama 865d98657e Add comments.
llvm-svn: 284805
2016-10-21 04:52:11 +00:00
Rui Ueyama 2795627509 Simplify by merging a lambda with addSymbol. NFC.
llvm-svn: 284804
2016-10-21 04:32:46 +00:00
Rui Ueyama a9a2adcf25 Do not create .shstrtab and use .strtab instead.
In-memory ELF object files created here are consumed immediately,
so as long as the generated files are syntactically correct, we don't
care about the details.

llvm-svn: 284803
2016-10-21 03:23:23 +00:00
Rui Ueyama b60d2cf435 Attempt to fix buildbots.
llvm-svn: 284790
2016-10-20 22:29:22 +00:00
Rui Ueyama 617d587432 Move code from InputFile to ELFCreator to decouple the two files.
Now that only one non-member function is exported from ELFCreator.h.
All the details are handled internally in ELFCreator.cpp file.

llvm-svn: 284786
2016-10-20 21:57:06 +00:00
Rui Ueyama 94dff2c0af llvm-dwarfdump is now used in a test, so add a depedency on the tool.
llvm-svn: 284776
2016-10-20 20:50:00 +00:00
Reid Kleckner 613c00db88 Add a space to work around a Windows CPython / MSys quoting bug
Summary:
The rules for quoting the command line that a subprocess receives are
user space conventions implemented by the C runtime. Python's quoting
rules are implemented here:
c30098c8c6/Lib/subprocess.py (L725)

The result is that the final command line C string computed by Python is
'echo \"'. Mingw doesn't appear to interpret that backslash as escaping
the quote because it is not already inside a quoted region. As a result,
our echo command prints a single backslash instead of a quote.

The whole issue can be sidestepped by adding a space a forcing Python to
put the argument to echo in double quotes.

Reviewers: inglorion, ruiu

Subscribers: llvm-commits

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

llvm-svn: 284768
2016-10-20 20:02:24 +00:00
Konstantin Zhuravlyov b625d17db8 [AMDGPU] Handle R_AMDGPU_ABS64 relocation
This is needed for the following case (OpenCL example):
  __global int Var = 0; 
  __global int* Ptr[] = {&Var}; 
  ...

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

llvm-svn: 284764
2016-10-20 18:34:58 +00:00
Rui Ueyama e329a9fad6 Remove unused #include.
llvm-svn: 284758
2016-10-20 18:07:11 +00:00
Simon Atanasyan badd5b31b7 [ELF][MIPS] Use getMipsLocalEntriesNum() everywhere we need number of `local` GOT entries. NFC
llvm-svn: 284751
2016-10-20 17:53:59 +00:00
Simon Atanasyan f4415a3d77 [ELF][MIPS] Separate calculation of MIPS GOT index and offset of the corresponding part of the GOT. NFC
MIPS GOT consists of some parts: local, global, TLS entries. This change
separates calculation of MIPS GOT index and offset of the corresponding
part of the GOT. That makes code a bit clear and allow to extend number
of parts in the future.

llvm-svn: 284750
2016-10-20 17:53:55 +00:00
Hans Wennborg 7314c48bcb Fix SectionPiece size when compiling with MSVC
Builds were failing with:

  InputSection.h(139): error C2338: SectionPiece is too big

because MSVC does record layout differently, probably not packing the
'OutputOff' and 'Live' bitfields because their types are of different
size. Using size_t for 'Live' seems to fix it.

llvm-svn: 284740
2016-10-20 15:59:08 +00:00
Benjamin Kramer 922b63b7f1 Remove a use of llvm::AlignOf that I missed.
llvm-svn: 284739
2016-10-20 15:55:41 +00:00
Benjamin Kramer 3ad3f5033d Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended.

llvm-svn: 284734
2016-10-20 15:30:02 +00:00
Rafael Espindola 113860b9ae Compact SectionPiece.
We allocate a lot of these when linking debug info. This speeds up the
link of debug programs by 1% to 2%.

llvm-svn: 284716
2016-10-20 10:55:58 +00:00
Peter Smith b663f1b407 [ELF] Add REQUIRES: arm to test to fix buildbot without ARM backend.
llvm-svn: 284711
2016-10-20 10:16:13 +00:00
Peter Smith d648603415 [ELF] Allow relative exceptions relocations in shared libraries
The R_ARM_PREL31 and R_ARM_NONE relocations should not be faulted in
shared libraries. In the case of R_ARM_NONE, we have moved the TLS
relaxation hint instruction to R_TLSDESC_CALL so that R_HINT can be used
without side-effects. In the case of R_ARM_PREL31 we permit it to be used
against PLT entries as the personality routines are imported when used in
shared libraries.

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

llvm-svn: 284710
2016-10-20 09:59:26 +00:00
Eugene Leviant db35fdf70f Don't include PHDRs if linker script doesn't want them
This script below shouldn't include file and program headers
to PT_LOAD segment, because it doesn't have PHDRS and FILEHDR
attributes:

PHDRS { all PT_LOAD; }
SECTIONS { /* list of sections here */ }

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

llvm-svn: 284709
2016-10-20 09:39:09 +00:00
George Rimar 58fa5243cc [ELF] - Partial support of --gdb-index command line option (Part 1).
In this patch partial gdb_index section is created. 
For costructing the .gdb_index section 6 steps should be performed (details are in
SplitDebugInfo.cpp file header), this patch do first 3:

Creates proper section header.
Fills list of compilation units.
Types CU list area is not supposed to be supported, so it is ignored and therefore
can be treated as implemented either.

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

llvm-svn: 284708
2016-10-20 09:19:48 +00:00
George Rimar a4c7e74d4b [ELF] - Applied clang format. NFC.
llvm-svn: 284705
2016-10-20 08:36:42 +00:00
George Rimar 6912147094 [ELF] - Testcase checking that we do not crash on invalid sh_info in SHT_GROUP sections. NFC.
Fix was landed as r284702 "[Object/ELF] - Check index argument in getSymbol()."

Patch contains LLD testcase only.

llvm-svn: 284703
2016-10-20 08:22:54 +00:00
Rui Ueyama 673c9d9018 Add a helper function to define symbols.
Also replace std::copy with memcpy because in other places we are
using memcpy.

llvm-svn: 284700
2016-10-20 06:44:58 +00:00
Rui Ueyama f2e78818e8 Rename variables so that they are more in line with rest of the code.
llvm-svn: 284699
2016-10-20 06:34:03 +00:00
Rui Ueyama 13146fce60 Update document.
llvm-svn: 284698
2016-10-20 05:35:25 +00:00
Rui Ueyama 388838ed23 Format. NFC.
llvm-svn: 284697
2016-10-20 05:23:23 +00:00
Rui Ueyama c3d15128de Remove Config::Binary.
This member is used only by LinkerDriver, so move it to LinkerDriver.

llvm-svn: 284696
2016-10-20 05:12:29 +00:00
Rui Ueyama d6877631d6 Remove an optional parameter from LinkerDriver::addFile to simplify.
llvm-svn: 284695
2016-10-20 05:03:49 +00:00
Rui Ueyama c185c0122f Split LinkerDriver::createFiles. NFC.
llvm-svn: 284694
2016-10-20 04:47:47 +00:00
Rui Ueyama d7c4454fb2 Fix error message for unknown -format argument.
-format=<foo>, -format <foo> and -b <foo> are all the same.
Previous code was intended to produce an error message with the
same spelling as given from the command line, but it actually
always printed out this string: "unknown -format= value:".
This is probably more confusing than "unknown -format value:".
So I changed the message.

llvm-svn: 284693
2016-10-20 04:47:45 +00:00
Rui Ueyama 0aeb1199ea Simplify. NFC.
llvm-svn: 284692
2016-10-20 04:36:36 +00:00
Rui Ueyama 837182ec1e Remove std:: from std::size_t.
llvm-svn: 284687
2016-10-20 01:33:09 +00:00
Reid Kleckner 2918d0b4b2 Fix narrowing conversion error in 32-bit MSVC builds
Use size_t instead of ELFT::uint for the string table offset. If the
linker is built 32-bit, it can't write an output file larger than 2GB.
Other code in this area uses size_t as well.

llvm-svn: 284680
2016-10-20 00:13:34 +00:00
Rui Ueyama 8da7aa0894 Allow linker-script-defined entry symbols.
Previously, we were checking the existence of an entry symbol
too early. It was done before the linker script processor creates
symbols defined in scripts. Fixes bug 30743.

llvm-svn: 284676
2016-10-20 00:07:36 +00:00
Rui Ueyama 40379746c8 Fix build failure.
llvm-svn: 284675
2016-10-20 00:05:46 +00:00
Reid Kleckner 89f3090d35 Use noexcept directly now that all compilers support it
llvm-svn: 284671
2016-10-19 23:50:50 +00:00
Michael J. Spencer f8a8148e1e [ELF] Replace std::pair with a struct so we have proper names. NFC.
llvm-svn: 284670
2016-10-19 23:49:27 +00:00
Rafael Espindola 116d83fbe0 Don't call markLiveAt for non alloc sections.
We don't gc them anyway, so just use an early return in Enqueue.

llvm-svn: 284663
2016-10-19 23:13:40 +00:00
Rui Ueyama 7c1381a099 Read an expression in the form of "ABSOLUTE(<expr>) op <expr> ...".
Fixes bug 30741.

llvm-svn: 284662
2016-10-19 23:11:21 +00:00
Rui Ueyama 90d12f44b7 Avoid using grep command in a test.
This test is failing on FreeBSD bots. This is an attempt to fix it
by not using grep command.

llvm-svn: 284645
2016-10-19 21:07:29 +00:00
Rui Ueyama 4ff3b5adc3 Move getVersionString to Core and simplify Version.cpp.
llvm-svn: 284641
2016-10-19 20:53:07 +00:00
Rui Ueyama 22646a80f4 Include ARGV[0] in error messages.
This is what other linkers and clang driver do.

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

llvm-svn: 284634
2016-10-19 20:05:43 +00:00
Rui Ueyama 8088ebe499 Remove ending "." from an error message.
Other error messages don't end with ".".

llvm-svn: 284625
2016-10-19 18:09:52 +00:00
Simon Atanasyan bc94693042 [ELF] Add `const` qualifier to functions. NFC
llvm-svn: 284614
2016-10-19 17:13:43 +00:00