Commit Graph

6194 Commits

Author SHA1 Message Date
George Rimar 7899d48dff [ELF] - Add Id field to Version struct.
That helps to avoid expressions like I + 2 in code
that assigns version number to symbols.

Change was suggested by Rui Ueyama.

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

llvm-svn: 275159
2016-07-12 07:44:40 +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
Rui Ueyama ec1b80fd11 Remove unused parameters.
llvm-svn: 275153
2016-07-12 03:49:41 +00:00
Rui Ueyama 89c3762a7a Update comments.
llvm-svn: 275003
2016-07-09 23:16:00 +00:00
Rui Ueyama 0d410c265c Attempt to fix buildbots.
llvm-svn: 275001
2016-07-09 23:02:37 +00:00
Rui Ueyama 95d2a9f91a Remove unused forward declarations.
llvm-svn: 274998
2016-07-09 22:54:27 +00:00
Rui Ueyama e2efadced7 Remove Target::writeThunk.
Only MipsThunk were using the function, and the way how it wrote
thunk contents was different from ARM thunks. This patch makes
them consistent.

llvm-svn: 274997
2016-07-09 22:52:32 +00:00
Rui Ueyama 3d2bbb13d0 Make ARM thunks consistent with MIPS in coding style.
Although they are in the same .cpp file, the way they were written
were slightly different, so they looked more different than they were.
This patch makes their styles consistent.

llvm-svn: 274996
2016-07-09 22:52:30 +00:00
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
Saleem Abdulrasool 0561bd5b47 COFF: remove unused function (touchFile)
Remove some dead code.  NFC.

llvm-svn: 274900
2016-07-08 18:36:56 +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
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
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
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 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
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 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