Commit Graph

2345 Commits

Author SHA1 Message Date
Rui Ueyama cafc0f2e03 Set DT_MIPS_BASE_ADDRESS correctly if -image-base is given.
Differential Revision: http://reviews.llvm.org/D22323

llvm-svn: 275446
2016-07-14 17:40:18 +00:00
Eugene Leviant b030411414 [ELF] r275383 reverted due to buildbot failure
llvm-svn: 275385
2016-07-14 09:21:24 +00:00
Eugene Leviant 219d9b2b18 [ELF] Allow overriding reserved symbols in linker scripts
llvm-svn: 275383
2016-07-14 08:26:41 +00:00
Rui Ueyama 3b04d833c4 Set sh_addralign to 1 instead of 0.
ELF spec says that alignment of 0 is equivalent to 1.
Previously, we arbitrary set to 0 or 1, but always setting to 1
makes our program simpler.

llvm-svn: 275374
2016-07-14 05:46:24 +00:00
Petr Hosek 1ddcacb949 [ELF] Rename the test to reflect the option name
This is to follow the convention of naming the test after the name
of the option.

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

llvm-svn: 275295
2016-07-13 18:31:44 +00:00
George Rimar dd64bb38bd Reverted r275257 "[ELF] - Implement extern "c++" version script tag"
It broke build bots:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/8204
http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/19432

llvm-svn: 275258
2016-07-13 08:19:04 +00:00
George Rimar e05103ea11 [ELF] - Implement extern "c++" version script tag
Patch implements 'extern' version script tag.
Currently only values in quotes(") are supported.

Matching of externs is performed in the same pass as exact match of globals.

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

llvm-svn: 275257
2016-07-13 07:46:00 +00:00
Rui Ueyama 1e52f25d46 Add -m elf32_x86_64.
Patch by H.J. Lu.

This patch adds -m elf32_x86_64 to lld. But it doesn't generate working
x32 binaries.

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

llvm-svn: 275236
2016-07-12 23:28:33 +00:00
Petr Hosek d7bd2389ce [ELF] Support for setting the base address
The -image-base option allows for overriding the base address.

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

llvm-svn: 275206
2016-07-12 19:37:53 +00:00
Eugene Leviant eda81a1b86 [ELF] Support for symbol assignment in linker scripts within SECTIONS {} block
llvm-svn: 275158
2016-07-12 06:39:48 +00:00
Peter Smith fb05cd997c Recommit R274836 Add Thunk support framework for ARM and Mips
The TinyPtrVector of const Thunk<ELFT>* in InputSections.h can cause 
build failures on certain compiler/library combinations when Thunk<ELFT> 
is not a complete type or is an abstract class. Fixed by making Thunk<ELFT>
non Abstract.

type or is an abstract class 

llvm-svn: 274863
2016-07-08 16:10:27 +00:00
Peter Smith eeb827447e Revert R274836 Add Thunk support framework for ARM and Mips
This seems to be causing a buildbot failure on lld-x86_64-freebsd. Will
reproduce locally and fix. 

llvm-svn: 274841
2016-07-08 12:25:50 +00:00
Peter Smith de01b98a26 Add Thunk support framework for ARM and Mips
Generalise the Mips LA25 Thunk code and implement ARM and Thumb
    interworking Thunks.
    
    - Introduce a new module Thunks.cpp to store the Target Specific Thunk
      implementations.
    - DefinedRegular and Shared have a ThunkData field to record Thunk.
    - A Target can have more than one type of Thunk.
    - Support PC-relative calls to Thunks.
    - Support Thunks to PLT entries.
    - Existing Mips LA25 Thunk code integrated.
    - Support for ARMv7A interworking Thunks.
    
    Limitations:
    - Only one Thunk per SymbolBody, this is sufficient for all currently
      implemented Thunks.
    - ARM thunks assume presence of V6T2 MOVT and MOVW instructions.

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

llvm-svn: 274836
2016-07-08 11:13:40 +00:00
George Rimar c61bcd80af [ELF] - Do not error out when version declaration not found when building executable.
When building executable usually version script is absent.
Before this patch error was shown in the case when
symbol name contained version and there was no script to match it.
  Instead of error out patch allows
to create new version declaration in this case and use it.
gnu linkers do the same.

That is PR28359.

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

llvm-svn: 274828
2016-07-08 06:47:28 +00:00
Rui Ueyama f731d0afed Test --demangle feature.
Previously, it was not tested because the test was written in
a way that it passed on a platform that does not support
abi::__cxa_demangle. Now we restrict this test to Unix (by adding
"REQUIRES: shell") and assume that it always demangle symbols.
Thanks to Davide to find out the issue.

llvm-svn: 274808
2016-07-07 23:43:09 +00:00
Rafael Espindola 580d7a1b1e -Bsymbolic should not make symbols more preemptable.
But it was doing that for protected undefined symbols.

llvm-svn: 274803
2016-07-07 22:50:54 +00:00
Rafael Espindola 4225342e95 This now works on unix too.
With this there are no unsupported tests on linux in test/ELF :-)

llvm-svn: 274752
2016-07-07 13:52:04 +00:00
George Rimar f73a25812f [ELF] - Fixed incorrect logic of version assignments when mixing wildcards with values matching.
Previously we had incorrect logic here. Imagine we would have the next script:

LIBSAMPLE_1.0
{
  global:
   a_2;
 local:
  *;
};

LIBSAMPLE_2.0
{
  global:
   a*;
};
According to previous logic it would assign version 1 to a_2 and then
would try to reassign it to version 2 because of applying wildcard a*.
And show a warning about that.

Generally Ian Lance Tailor wrote about next rules that should be applied:
(http://www.airs.com/blog/archives/300)

Here are the current rules for gold:

"If there is an exact match for the mangled name, we use it. If there is more than one exact match, we give a warning, and we use the first tag in the script which matches. If a symbol has an exact match as both global and local for the same version tag, we give an error.
Otherwise, we look for an extern C++ or an extern Java exact match. If we find an exact match, we use it. If there is more than one exact match, we give a warning, and we use the first tag in the script which matches. If a symbol has an exact match as both global and local for the same version tag, we give an error.
Otherwise, we look through the wildcard patterns, ignoring “*” patterns. We look through the version tags in reverse order. For each version tag, we look through the global patterns and then the local patterns. We use the first match we find (i.e., the last matching version tag in the file).
Otherwise, we use the “*” pattern if there is one. We give a warning if there are multiple “*” patterns."

Patch makes wildcard matching to be in revered order and to follow after the regular naming matching.

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

llvm-svn: 274739
2016-07-07 07:45:27 +00:00
Rui Ueyama 287956f72b Correctly define "zlib" feature.
We have "REQUIRES: zlib" in our test, but zlib was not defined,
so the test did not run on any platform.

llvm-svn: 274730
2016-07-07 03:55:57 +00:00
Rui Ueyama 1d12ac1d11 Fix endianness issue.
Previously, ch_size was read in host byte order, so if a host and
a target are different in byte order, we would produce a corrupted
output.

llvm-svn: 274729
2016-07-07 03:55:55 +00:00
Rui Ueyama 0f282a593f Do not call warning() from ELFOptTable::parse().
warning() depends on Config->FatalWarnings, so we don't want to call
that function before we initialize that member.

llvm-svn: 274723
2016-07-07 01:58:04 +00:00
Rafael Espindola 9639ec1e66 Read the implicit addend of R_386_GOT32X.
llvm-svn: 274690
2016-07-06 21:48:50 +00:00
Rafael Espindola d03e659140 Recognize R_386_GOT32X.
We don't relax it, but we at least recognize it.

llvm-svn: 274687
2016-07-06 21:41:39 +00:00
Davide Italiano f296a7eeae [ELF] Introduce a flag to parse response files according to windows rules.
Differential Revision:  http://reviews.llvm/org/D22015

llvm-svn: 274684
2016-07-06 21:24:34 +00:00
Rafael Espindola 1f6929bff6 Use / instead of \ on windows created cpio files
Otherwise when extracting these files on a unix system one
ends up with files named like "repro\bar\foo.o".

llvm-svn: 274622
2016-07-06 12:09:51 +00:00
Davide Italiano c03d610cff [ELF] Support --entry= option variant. Update tests while I'm there.
llvm-svn: 274524
2016-07-04 21:50:50 +00:00
Tom Stellard 391e3a873e ELF/AMDGPU: Add support for GOT relocations
Reviewers: arsenm, rafael, tony-tye, kzhuravl, ruiu

Subscribers: llvm-commits, kzhuravl

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

llvm-svn: 274514
2016-07-04 19:19:07 +00:00
Rafael Espindola 8e51e67eb7 Add a test for accessing __tls_get_addr with a GOT.
This was already passing, but missing a test.

llvm-svn: 274513
2016-07-04 17:34:53 +00:00
George Rimar 857644cef8 [ELF] - Implemented --fatal-warnings option.
--fatal-warnings: Treat warnings as errors

DIfferential revision: http://reviews.llvm.org/D21969

llvm-svn: 274504
2016-07-04 13:43:12 +00:00
George Rimar 33b9de4b32 [ELF] - Depricate version references.
This is PR28358

According to
https://www.akkadia.org/drepper/dsohowto.pdf

"The fourth point, the VERS 1.0 version being referred to in the VERS 2.0 definition, is not really important in symbol versioning. It marks the predecessor relationship of the two versions and it is done to maintain the similar- ities with Solaris’ internal versioning. It does not cause any problem it might in fact be useful to a human reader so predecessors should always be mentioned."

Patch partially reverts 273423 "[ELF] - Implemented version script hierarchies.",
version references are just ignored now.

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

llvm-svn: 274345
2016-07-01 11:45:10 +00:00
Eugene Leviant 467c4d5538 [ELF] Fix first PT_LOAD segment VA calculation, when linker script is used
llvm-svn: 274342
2016-07-01 10:27:36 +00:00
George Rimar e86dcd0cbd [ELF] - Added support for --unresolved-symbols option.
Option has next description (http://linux.die.net/man/1/ld):
"--unresolved-symbols=method
Determine how to handle unresolved symbols. There are four possible values for method
according to documentation:

ignore-all: Do not report any unresolved symbols.
report-all: Report all unresolved symbols. This is the default.
ignore-in-object-files: Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files.
ignore-in-shared-libs: Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries."

Since report-all is default and we traditionally do not report about undefined symbols in lld,
report-all does not report about undefines from DSO. 
ignore-in-object-files also does not do that. Handling of that option differs from what gnu linkers do.

Option works in next way in lld:
ignore-all: Do not report any unresolved symbols.
report-all: Report all unresolved symbols except symbols from DSOs. This is the default.
ignore-in-object-files: The same as ignore-all.
gnore-in-shared-libs: The same as report-all.

This is PR24524.

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

llvm-svn: 274123
2016-06-29 12:35:04 +00:00
Rui Ueyama 94f3a731e5 Convert DOS-style newlines.
llvm-svn: 274118
2016-06-29 10:39:00 +00:00
George Rimar dbbf60e590 [ELF] - Check the input bitcode files for compatibility.
Previously BC files were not checked for the same platform etc,
That lead to confusing error "Invalid section header entry size (e_shentsize) in ELF header" when
mixing files for different architectures.

Patch fixes PR28324.

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

llvm-svn: 274113
2016-06-29 09:46:00 +00:00
Davide Italiano 60976ba86d [LTO] Infer ELFKind/EMachine from Bitcode files
So that users are not forced to pass `-m` on the command line
when the inputs are all bitcode.

PR:   28268
Differential Revision:  http://reviews.llvm.org/D21779

llvm-svn: 274107
2016-06-29 06:12:39 +00:00
Davide Italiano 8e1131dc46 [ELF] Support for wildcard in version scripts.
Example:

VERSION_1.0 {
  global: foo*;
  local: *; }

now correctly matches all the symbols which name starts with
`foo`.

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

llvm-svn: 274091
2016-06-29 02:46:51 +00:00
Rafael Espindola 857d7c5dd0 Handle empty versions.
They are significant now that we support @ in symbol names.

llvm-svn: 274071
2016-06-28 21:48:33 +00:00
Rafael Espindola 2100aa08b7 Don't check the section index, it is not relevant for this test.
llvm-svn: 274070
2016-06-28 21:47:17 +00:00
George Rimar 4365158689 [ELF] - Implemented support of default/non-default symbols versions
t is possible to create new version of symbol instead of depricated one
using combination of version script and asm commands. For example:

__asm__(".symver b_1,b@LIBSAMPLE_1.0");
int b_1() { return 10; }
__asm__(".symver b_2,b@@LIBSAMPLE_2.0");
int b_2() { return 20; }

This code makes b_2() to be default implementation for b().
b_1() is used for compatibility with binaries compiled against
library of older version LIBSAMPLE_1.0.

This patch implements support for above functionality in lld.

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

llvm-svn: 274002
2016-06-28 08:21:10 +00:00
George Rimar 36b2c0a683 [ELF] - Implemented --no-undefined-version flag
Option checks for cases where a version script explicitly lists
a symbol, but the symbol is not defined and errors out such
cases if any.

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

llvm-svn: 273998
2016-06-28 08:07:26 +00:00
Davide Italiano 4fdc648592 [ELF] Warn for duplicate symbols in version scripts instead of erroring out.
Emitting an error in this case breaks real-world application (e.g. libreoffice).
See http://reviews.llvm.org/D21555 for context.

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

llvm-svn: 273989
2016-06-28 03:40:49 +00:00
Chris Bieneman 677c6e4173 [yaml2obj] Hopefully the last test case update from r273915
Should fix the last LLD bots.

llvm-svn: 273942
2016-06-27 21:06:40 +00:00
Chris Bieneman 4e5bdaaca4 [yaml2obj] One more missing test case update from r273915
Should fix the last LLD bots.

llvm-svn: 273939
2016-06-27 20:47:00 +00:00
Chris Bieneman ca5170e3e4 [yaml2obj] Updating LLD tests to account for LLVM r273915
This removed the -format flag from yaml2obj in favor of YAML tags.

llvm-svn: 273920
2016-06-27 20:17:08 +00:00
Rui Ueyama 20d8d55b05 Fix library search order.
Previously, we searched for a .so file from all library paths and
then searched for a .a file. That logic is wrong. What we need to
do is to look for a .so and a .a for each library path.

llvm-svn: 273846
2016-06-27 07:26:28 +00:00
Lang Hames 3b3b4d792f [lld][MachO] Add support for x86-64 negDelta64 references and fix negDelta32.
These references are used to implement MachO/x64-64 subtractor relocations
where the minuend is being fixed up, rather than the subtrahend. The 64-bit
version was not previously supported, the 32-bit version was partially
implemented but contained bugs not caught by existing test cases. This
patch fixes both functionality and test coverage.

llvm-svn: 273759
2016-06-25 00:29:54 +00:00
Davide Italiano e160f0d0d6 [ELF] Allow --reproduce to be specified as an environment variable.
PR: 28257
Differential Revision:   http://reviews.llvm.org/D21628

llvm-svn: 273698
2016-06-24 18:02:50 +00:00
George Rimar 6a7cfd039e [ELF] - Fix incorrect logic in VersionScriptParser::parseVersion()
Previously the next sample script would generate 2 entries in 
Config->SymbolVersions with the same version name.

VERSION {
 global: c;
};
That happened because parseVersionSymbols() was called twice.
At first for "global:" and since there is no local tag, it was called again.
Patch fixes the issue, testcase was updated to demonstrate.

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

llvm-svn: 273663
2016-06-24 11:23:55 +00:00
George Rimar 602fbee9fc [ELF] - Support of compressed input sections implemented.
Patch implements support of zlib style compressed sections.
SHF_COMPRESSED flag is used to recognize that decompression is required.
After that decompression is performed and flag is removed from output.

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

llvm-svn: 273661
2016-06-24 11:18:44 +00:00
Simon Atanasyan 002e244717 [ELF][MIPS] Support MIPS TLS relocations
The patch adds one more partition to the MIPS GOT. This time it is for
TLS related GOT entries. Such entries are located after 'local' and 'global'
ones. We cannot get a final offset for these entries at the time of
creation because we do not know size of 'local' and 'global' partitions.
So we have to adjust the offset later using `getMipsTlsOffset()` method.

All MIPS TLS relocations which need GOT entries operates MIPS style GOT
offset - 'offset from the GOT's beginning' - MipsGPOffset constant. That
is why I add new types of relocation expressions.

One more difference from othe ABIs is that the MIPS ABI does not support
any TLS relocation relaxations. I decided to make a separate function
`handleMipsTlsRelocation` and put MIPS TLS relocation handling code
there. It is similar to `handleTlsRelocation` routine and duplicates its
code. But it allows to make the code cleaner and prevent pollution of
the `handleTlsRelocation` by MIPS 'if' statements.

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

llvm-svn: 273569
2016-06-23 15:26:31 +00:00