Commit Graph

1965 Commits

Author SHA1 Message Date
Rui Ueyama ec4220d70f Instantiate Thunk classes instead of the class member functions.
llvm-svn: 274994
2016-07-09 22:06:47 +00:00
Rui Ueyama 5e3d604688 Split addThunkARM. NFC.
llvm-svn: 274993
2016-07-09 22:03:51 +00:00
Rui Ueyama 8c8db476f1 Attempt to fix buildbots.
llvm-svn: 274917
2016-07-08 19:59:11 +00:00
Rafael Espindola 6091492e2c fix use of uninitialized.
llvm-svn: 274909
2016-07-08 19:28:55 +00:00
Rui Ueyama 8b8d0055fe Fix memory leak.
Symbol's dtors are not called because they are allocated using
BumpPtrAllocators. So, members of std::unique_ptr type are not
freed when symbols are deallocated.

This patch is to allocate Thunks using BumpPtrAllocators.

llvm-svn: 274896
2016-07-08 17:58:54 +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
Davide Italiano 3f36781dec [ELF] Ignore --demangle. We already demangle symbols by default.
llvm-svn: 274806
2016-07-07 23:32:36 +00:00
Rui Ueyama f4d9338dfb Move demangle() from Symbols.cpp to Strings.cpp.
Symbols.cpp contains functions to handle ELF symbols.
demangle() function is essentially a function to work on a
string rather than on an ELF symbol. So Strings.cpp is a
better place to put that function.

This change also make demangle to demangle symbols unconditionally.
Previously, it demangled symbols only when Config->Demangle is true.

llvm-svn: 274804
2016-07-07 23:04:15 +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 64c32d6f02 Fix formating. NFC.
llvm-svn: 274757
2016-07-07 14:28:47 +00:00
Rafael Espindola d10f0b1eae Use "using namespace llvm" like the rest of ELF lld.
llvm-svn: 274755
2016-07-07 14:06:38 +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 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 523744dd2b Fix formatting.
llvm-svn: 274724
2016-07-07 02:46:30 +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
Rui Ueyama a027d33949 Fix indentation.
llvm-svn: 274719
2016-07-07 01:21:14 +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
Davide Italiano f8591cf249 [gardening] Switch back to auto. NFCI.
Pointed out by: Rui Ueyama.

llvm-svn: 274643
2016-07-06 17:41:55 +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
Davide Italiano b4b68b64fd [OutputSection] Work around GCC not being able to deduce auto.
The build otherwise fails with:
[ 39%] Building CXX object
tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In
member function ‘void
lld:🧝:GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld:🧝:SymbolBody*,
long unsigned int> >&)’:
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8:
error: inconsistent deduction for ‘auto’: ‘auto’ and then
‘__gnu_cxx::__normal_iterator<std::pair<lld:🧝:SymbolBody*, long
unsigned int>*, std::vector<std::pair<lld:🧝:SymbolBody*, long
unsigned int> > >’

Reported by:  H. J. Liu

llvm-svn: 274518
2016-07-04 19:49:55 +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
George Rimar 5e37aeaf6a Fixed check-lld msan after r274504 "[ELF] - Implemented --fatal-warnings option."
Bot failed:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14361/steps/check-lld%20msan/logs/stdio

Fix:
Initialize Config->FatalWarnings with false. As it might be used once a bit earlier than its
initialization from command line arguments.

llvm-svn: 274507
2016-07-04 14:54:23 +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
Rui Ueyama 03e1cc6322 Remove duplicate declaration.
llvm-svn: 274429
2016-07-02 08:50:05 +00:00
Rui Ueyama c98e4d8167 Move getAddend to Relocations.h.
Because the function works on relocations, it should be in
Relocations.h instead of OutputSections.h.

llvm-svn: 274428
2016-07-02 08:50:03 +00:00
Rui Ueyama d573844a1f Fix formatting. NFC.
llvm-svn: 274426
2016-07-02 06:08:44 +00:00
Davide Italiano e929f424a4 [BitcodeFile] Simplify shouldSkip(). NFCI.
llvm-svn: 274383
2016-07-01 20:43:28 +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
Rui Ueyama 52c4e17f8a Remove trailing whitespaces.
llvm-svn: 274343
2016-07-01 10:42:25 +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
Rui Ueyama 1df56894f8 Do not allow "--" with single-letter options.
In general, we accept both -foo and --foo as command line options,
but if an option is a single letter option, we don't want to allow
double dashes because GNU linkers don't accept such combination.

llvm-svn: 274219
2016-06-30 08:43:23 +00:00
Kevin Enderby b9e053cfd7 Matching change for lld for the llvm change of Archive::create() from ErrorOr<...> to Expected<...> in r274160.
llvm-svn: 274161
2016-06-29 20:36:11 +00:00
Davide Italiano e3fa8f64da [ELF] More self-explanatory error message when e_machine can't be inferred.
Thanks to Sean Silva for the suggestion!

llvm-svn: 274134
2016-06-29 15:58:37 +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
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
Rui Ueyama fbbde548cf Move isValidCIdentifier to Strings.cpp.
llvm-svn: 274112
2016-06-29 09:08:02 +00:00
George Rimar 9fc1d4ed75 [ELF] - Updated comments. NFC.
As was suggested by Rafael Espíndola.

llvm-svn: 274111
2016-06-29 08:36:36 +00:00
Rui Ueyama 93c9af425e Create Strings.cpp and move string manipulation functions to that file.
llvm-svn: 274109
2016-06-29 08:01:32 +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
Rui Ueyama 722830a51b Rename matchStr -> globMatch.
llvm-svn: 274103
2016-06-29 05:32:09 +00:00
Rui Ueyama 48e4251e1d Make SymbolTable::findAll to return only defined symbols.
We allowed the function to return a vector that contains nullptrs
which is weird. This change makes the function to return only
defined symbols.

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

llvm-svn: 274099
2016-06-29 04:47: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
Rui Ueyama 5e64d3fb94 Refactor ELF type inference functions.
Previously, we initialized Config->EKind and Config->EMachine when
we instantiate ELF objects. That was not an ideal location to do that
because the logic was buried too deep inside a concrete logic.

This patch moves the code to the driver so that the initialization
becomes explicit.

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

llvm-svn: 274089
2016-06-29 01:30:50 +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