73 Commits

Author SHA1 Message Date
Davide Italiano 81c5c0ff00 [Core] Retire yet another unused member function.
The code in lib/ could use a lot of love :(


git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@278506 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 12:37:23 +00:00
Davide Italiano 89bbaccda3 [Core] Simplify a bit. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@278505 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 12:34:39 +00:00
Davide Italiano e8eb665c11 [Core] Retire addReplacement() member function.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@278327 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 10:50:01 +00:00
Davide Italiano e324c5fe12 [Core] tentativeDefinition() is now unused.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@278181 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 00:01:13 +00:00
Rui Ueyama ef97618b4a Remove dead code for ELF.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@262195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-28 21:59:02 +00:00
Rafael Espindola 50f9db6ab6 Delete more COFF and ELF bits from the old linker.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@262184 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-28 16:27:08 +00:00
Rafael Espindola da338b7d42 Delete more ELF bits from the old linker.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@262181 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-28 16:03:37 +00:00
Rui Ueyama 26aead0dc4 Do s/_context/_ctx/g globally.
I believe this patch eliminates all remaining uses of _context
or _linkingContext variable names. Consistent naming improves
readability.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@234645 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10 21:40:59 +00:00
Rui Ueyama 93e4ba9fec Remove unused function.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@231444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-06 01:44:07 +00:00
Rui Ueyama db7c8cb4e3 Remove dead code.
This hook is called from one of the hottest loops in LLD and does nothing.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@231345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 02:58:13 +00:00
Rui Ueyama 46839cad4b Define DefinedAtom::sectionSize.
Merge::mergeByLargestSection is half-baked since it's defined
in terms of section size, there's no way to get the section size
of an atom.

Currently we work around the issue by traversing the layout edges
to both directions and calculate the sum of all atoms reachable.
I wrote that code but I knew it's hacky. It's even not guaranteed
to work. If you add layout edges before the core linking, it
miscalculates a size.

Also it's of course slow. It's basically a linked list traversal.

In this patch I added DefinedAtom::sectionSize so that we can use
that for mergeByLargestSection. I'm not very happy to add a new
field to DefinedAtom base class, but I think it's legitimate since
mergeByLargestSection is defined for section size, and the section
size is currently just missing.

http://reviews.llvm.org/D7966

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@231290 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 21:40:46 +00:00
Simon Atanasyan dd657e257a Follow-up to r221913. Fix some -Wcast-qual warning reasons.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@221974 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 07:15:43 +00:00
Shankar Easwaran 66605ff243 Sort include files according to convention.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@220131 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-18 05:33:55 +00:00
Rui Ueyama 7b9b248778 Use isa<> and cast<> instead of definition().
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@219727 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14 21:42:08 +00:00
Nick Kledzik fa23a797d7 Preserve custom section names when coalescing.
The mergeByContent attribute on DefinedAtoms triggers the symbol table to
coalesce atoms with the exact same content. The problem is that atoms can also
have a required custom section. The coalescing should never change the custom
section of an atom.

The fix is to only consider to atoms to have the same content if their
sectionChoice() and customSectionName() attributes match.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@218893 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 17:22:05 +00:00
Simon Atanasyan 4d7c5e0bb5 [ELF] Export strong defined symbol if it coalesces away a weak symbol
defined in a shared library.

Now LLD does not export a strong defined symbol if it coalesces away a
weak symbol defined in a shared library. This bug affects all ELF
architectures and leads to segfault:

  % cat foo.c
  extern int __attribute__((weak)) flag;
  int foo() { return flag; }

  % cat main.c
  int flag = 1;
  int foo();
  int main() { return foo() == 1 ? 0 : -1; }

  % clang -c -fPIC foo.c main.c
  % lld -flavor gnu -target x86_64 -shared -o libfoo.so ... foo.o
  % lld -flavor gnu -target x86_64 -o a.out ... main.o libfoo.so
  % ./a.out
  Segmentation fault

The problem is caused by the fact that we lose all information about
coalesced symbols after the `Resolver::resolve()` method is finished.

The patch solves the problem by overriding the
`LinkingContext::notifySymbolTableCoalesce()` method and saving names
of coalesced symbols. Later in the `buildDynamicSymbolTable()` routine
we use this information to export these symbols.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@217363 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-08 09:43:38 +00:00
Rui Ueyama 7cbea48a33 Simplify. No functionality changes.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 02:00:58 +00:00
Nick Kledzik 60d5bd75e8 Add notifier hooks to symbol table.
This is the one interesting aspect from:
   http://reviews.llvm.org/D4965

These hooks are useful for flavor specific processing, such as recording that
a DefinedAtom replaced a weak SharedLibraryAtom.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@216122 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-20 20:46:28 +00:00
Rui Ueyama 624a34aed0 Add SymbolTable::isCoalescedAway
isCoalescedAway(x) is faster than replacement(x) != x as the former
does not follow the replacement atom chain. Also it's easier to use.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@210242 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-05 07:37:29 +00:00
Nick Kledzik 3bf6c8d1d1 [mach-o] Support parsing of non-lazy-pointer sections
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@209704 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-28 01:16:35 +00:00
Rui Ueyama ec71f4c103 Fix regression introduced in r205566.
In r205566, I made a change to Resolver so that Resolver revisit
only archive files in --start-group and --end-group pair. That's
not correct, as it also has to revisit DSO files.

This patch is to fix the issue.

Added a test to demonstrate the fix. I confirmed that it succeeded
before r205566, failed after r205566, and is ok with this patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@208797 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-14 17:29:27 +00:00
Rui Ueyama 1767849f3d Split a utility function not to use goto statement.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@205643 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04 18:34:40 +00:00
Rui Ueyama d6173383b3 useNew is set to false in all branches, so set it to false outside the if-else.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@205642 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04 18:21:53 +00:00
Rui Ueyama 838c453e5b Replace dyn_cast<T>s immediately followed by asserts with cast<T>s.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@205641 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04 18:21:51 +00:00
Rui Ueyama 505b2d5055 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@205639 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04 18:12:27 +00:00