Commit Graph

333 Commits

Author SHA1 Message Date
Peter Smith 1a0ca791ab [ELF][ARM] Use SyntheticSections for Thunks
Thunks are now implemented by redirecting the relocation to the
symbol S, to a symbol TS in a Thunk. The Thunk will transfer control
to S. This has the following implications:
- All the side-effects of Thunks happen within createThunks()
- Thunks are no longer stored in InputSections and Symbols no longer
  need to hold a pointer to a Thunk
- The synthetic Thunk sections need to be merged into OutputSections
    
This implementation is almost a direct conversion of the existing
Thunks with the following exceptions:
- Mips LA25 Thunks are placed before the InputSection that defines
  the symbol that needs a Thunk.
- All ARM Thunks are placed at the end of the OutputSection of the
  first caller to the Thunk.
    
Range extension Thunks are not supported yet so it is optimistically
assumed that all Thunks can be reused.

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



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293283 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27 13:10:16 +00:00
Rafael Espindola 6e46026938 Create _end symbol even if a .so defines it.
The freebsd sbrk implementation uses _end to find the initial value of
brk, so it has to be defined in the main binary.

This should fix the emacs build.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 19:43:34 +00:00
Rafael Espindola 3e23324851 Add a isInCurrentDSO helper. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292228 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 16:08:06 +00:00
Rafael Espindola 0e7b69f810 Give priority to linker scripts over preemption.
LLD exports symbols that are also present in used shared libraries to
make sure they are preempted at runtime. That is a reasonable default,
but we must allow for it to be overwritten with linker script. If we
don't, libraries that expect to be able to hide a c++ delete operator
will fail.

This should fix the firebird build.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292146 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 17:35:23 +00:00
Rafael Espindola 9353fa250a Don't add DT_INIT/DT_FINI for undef and shared symbols.
The freebsd dynamic linker doesn't check if the value is null (and it
is reasonable for it to do that). That means that producing a .so with
a null DT_INIT/DT_FINI causes the base address to be called.

This should fix the libreoffice build.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291944 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 19:18:11 +00:00
Rafael Espindola 6c95c4c55a Add support for anonymous local symbols.
This actually simplifies the code a bit as now all local symbols are
handled uniformly.

This should fix the build of www/webkit2-gtk3.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291569 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-10 16:37:24 +00:00
Peter Smith 5e37fda1d7 [ELF] Add support for thunks to undefined non-weak symbols
In a shared library an undefined symbol is implicitly imported. If the
symbol is called as a function a PLT entry is generated for it. When the
caller is a Thumb b.w a thunk to the PLT entry is needed as all PLT
entries are in ARM state.
    
This change allows undefined symbols to have thunks in the same way that
shared symbols may have thunks.



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290951 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 09:45:45 +00:00
Rui Ueyama ff50d1d3a5 Do not return null or Undefined from find{All,}ByVersion.
Vectors returned form that function contained nullptrs or Undefined symbols.
This patch filter them out. This makes use of the function a bit easier.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22 09:54:32 +00:00
Rui Ueyama 88ef826658 Define a getter function for a lazily-created object.
Previously, you had to call initDemangledSyms() before accessing DemangledSyms.
Now getDemangledSyms() initializes it and then returns it. So it is now less easy
to use it in a wrong way.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290323 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22 05:31:52 +00:00
Rui Ueyama b70d9c01f5 Simplify. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22 05:22:29 +00:00
Rui Ueyama 7505ae3585 Define a function to avoid a magic variable 0x3.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290320 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22 05:11:12 +00:00
Rui Ueyama 3f9c889ebd De-template DefinedSynthetic.
DefinedSynthetic is not created for a real ELF object, so it doesn't
have to be a template function. It has a virtual st_value, which is
either 32 bit or 64 bit, but we can simply use 64 bit.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290241 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-21 08:40:09 +00:00
Vitaly Buka 6ef044db0b Fix build broken by changes in StringMatcher interface r290213
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290231 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-21 02:27:14 +00:00
Rui Ueyama 54b01a52e8 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-18 14:06:06 +00:00
Rui Ueyama 4657aff9b8 Rename find(SymbolVersion) to avoid overloading with find(StringRef).
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289293 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-10 00:34:06 +00:00
Rafael Espindola 470648e5c6 Fix a bogus warning.
We first decide that the symbol is global, than that it should have
version foo. Since it was already not the default version, we were
producing a bogus warning.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289284 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09 22:40:49 +00:00
Rafael Espindola 60f7e32fbe Don't crash on an extra symbol in a version script.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289217 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09 15:08:40 +00:00
Rafael Espindola 54758106cb Give preempting symbols precedence over linker script.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289212 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09 14:12:02 +00:00
Rui Ueyama ca7af8d122 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 18:31:13 +00:00
Rafael Espindola f2534ab7f2 Change the implementation of --dynamic-list to use linker script parsing.
The feature is documented as
-----------------------------
The format of the dynamic list is the same as the version node
without scope and node name.  See *note VERSION:: for more
information.
--------------------------------

And indeed qt uses a dynamic list with an 'extern "C++"' in it. With
this patch we support that

The change to gc-sections-shared makes us match bfd. Just because we
kept bar doesn't mean it has to be in the dynamic symbol table.

The changes to invalid-dynamic-list.test and reproduce.s are because
of the new parser.

The changes to version-script.s are the only case where we change
behavior with regards to bfd, but I would like to see a mix of
--version-script and --dynamic-list used in the wild before
complicating the code.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289082 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 17:54:26 +00:00
Rafael Espindola b280b788cc Inline function called only once.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289067 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 16:26:20 +00:00
Rafael Espindola 4947fe16b3 Handle C++ names in anon scripts.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289066 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 16:20:29 +00:00
Rafael Espindola 3d08227959 Inline two functions called only once. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289065 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 16:02:48 +00:00
Rafael Espindola 52a222b780 Add two helper functions. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289064 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 15:56:33 +00:00
Rafael Espindola 21f75b413f Simplify. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 15:36:58 +00:00