Skip to content
  1. Feb 16, 2017
    • Rui Ueyama's avatar
      Split a function and add comments. · 750c11c0
      Rui Ueyama authored
      This is slightly inefficient than the previous code, but that is really
      negligible as this function is usually called at most only a few times.
      
      llvm-svn: 295282
      750c11c0
    • Rui Ueyama's avatar
      Add CopyRelSection instances to BSS in the regular way. · da5cc846
      Rui Ueyama authored
      Previously, space in a BSS section for copy relocations are reserved
      in a special way. We directly manipulated size of the BSS section.
      r294577 changed the way of doing it. Now, we create an instance of
      CopyRelSection (which is a synthetic input section) for each copy
      relocation.
      
      This patch removes the remains of the old way and add CopyRelSections
      to BSS sections using `addSections` function, which is the usual
      way to add an input section to an output section.
      
      llvm-svn: 295278
      da5cc846
    • Rafael Espindola's avatar
      Addends should always be signed. · 7386ceac
      Rafael Espindola authored
      In the target dependent code we already always return a int64_t. In
      the target independent code we carefully use uintX_t, which has the
      same result given 2 complement rules.
      
      This just simplifies the code to use int64_t everywhere.
      
      llvm-svn: 295263
      7386ceac
  2. Feb 14, 2017
  3. Feb 09, 2017
    • Peter Smith's avatar
      [ELF] Use synthetic section to hold copy relocation · ebfe9941
      Peter Smith authored
          
      When we need a copy relocation we create a synthetic SHT_NOBITS
      section that contains the right amount of ZI and assign it to either
      .bss or .rel.ro.bss as appropriate. This allows the dynamic relocation
      to be placed on the InputSection, removing the last case where a
      dynamic relocation is stored as an offset from the OutputSection. This
      has the side effect that we can run assignOffsets() after scanRelocs()
      without losing the additional ZI needed for the copy relocations.
      
      Differential Revision: https://reviews.llvm.org/D29637
      
      llvm-svn: 294577
      ebfe9941
  4. Feb 01, 2017
    • Peter Smith's avatar
      [ELF] Use SyntheticSections for Thunks · 3a52eb00
      Peter Smith authored
          
      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.
      
      This is a recommit of r293283 with a fixed comparison predicate as
      std::merge requires a strict weak ordering.
      
      Differential revision: https://reviews.llvm.org/D29327
      
      llvm-svn: 293757
      3a52eb00
  5. Jan 28, 2017
  6. Jan 27, 2017
    • Rafael Espindola's avatar
      Fix and simplify the reporting of undefined symbols. · 403b093e
      Rafael Espindola authored
      Now reportUndefined only has to look at Config->UnresolvedSymbols and
      the symbol. getUnresolvedSymbolOption does all the hard work of
      mapping options like -shared and -z defs to one of the
      UnresolvedPolicy enum entries.
      
      The critical fix is that now "-z defs --warn-unresolved-symbols" only
      warns.
      
      llvm-svn: 293290
      403b093e
    • Peter Smith's avatar
      [ELF][ARM] Use SyntheticSections for Thunks · 5191c6f9
      Peter Smith authored
          
      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
      
      llvm-svn: 293283
      5191c6f9
  7. Jan 20, 2017
    • Peter Smith's avatar
      [ELF] Cleanup createThunks() NFC. · 94b999b9
      Peter Smith authored
          
      Include removal of call to getThunkExpr() as it has already been
      called and recorded by scanRelocs()
          
      Cleanup suggestions by Rafael.
      
      llvm-svn: 292614
      94b999b9
  8. Jan 18, 2017
    • Peter Smith's avatar
      [ELF] Move createThunks() after scanRelocations() · ee6d7186
      Peter Smith authored
          
      A necessary first step towards range extension thunks is to delay
      the creation of thunks until the layout of InputSections within
      OutputSections has been done.
          
      The change scans the relocations directly from InputSections rather
      than looking in the ELF File the InputSection came from. This will
      allow a future change to redirect the relocations to symbols defined
      by Thunks rather than indirect when resolving relocations.
          
      A side-effect of moving ThunkCreation is that the OutSecOff of
      InputSections may change in an OutputSection that contains Thunks.
      In well behaved programs thunks are not in OutputSections with
      dynamic relocations.
          
      Differential Revision: https://reviews.llvm.org/D28811
      
      llvm-svn: 292359
      ee6d7186
  9. Jan 10, 2017
  10. Dec 19, 2016
    • Rafael Espindola's avatar
      Use existing variable. NFC. · 29982b0f
      Rafael Espindola authored
      llvm-svn: 290112
      29982b0f
    • Adhemerval Zanella's avatar
      ELF/AArch64: Fix dynamic relocation against local symbol in shared objects · 86513f06
      Adhemerval Zanella authored
      AArch64 TLSDESC for local symbol in shared objects are implemented in a
      arch specific manner where the TLSDESC dynamic relocation addend is the
      symbol VM inside the TLS block. For instance, with a shared library
      created from the code:
      
      --
      static __thread int32_t x1;
      static __thread int64_t x2;
      
      int32_t foo1 (int32_t x)
      {
        x1 += x;
        return x;
      }
      
      int64_t foo2 (int64_t x)
      {
        x2 += x;
        return x;
      }
      --
      
      The dynamic relocation should be create as:
      
      Relocations [
        Section (N) .rela.dyn {
          <Address1> R_AARCH64_TLSDESC - 0x0
          <Address2> R_AARCH64_TLSDESC - 0x8
        }
      ]
      
      Where 0x0 addend in first dynamic relocation is the address of 'x1'
      in TLS block and '0x8' is the address of 'x2'.
      
      Checked against test-suite on aarch64-linux-gnu.
      
      llvm-svn: 290099
      86513f06
  11. Dec 13, 2016
  12. Dec 08, 2016
    • Peter Smith's avatar
      [ELF] ifunc implementation using synthetic sections · baffdb8b
      Peter Smith authored
      This change introduces new synthetic sections IpltSection, IgotPltSection
      that represent the ifunc entries that would previously have been put in
      the PltSection and the GotPltSection. The separation makes sure that
      the R_*_IRELATIVE relocations are placed after the non R_*_IRELATIVE
      relocations, which permits ifunc resolvers to know that the .got.plt
      slots will be initialized prior to the resolver being called.
      
      A secondary benefit is that for ARM we can move the IgotPltSection and its
      dynamic relocations to the .got and .rel.dyn as the ARM glibc expects all
      the R_*_IRELATIVE relocations to be in the .rel.dyn
      
      Differential revision: https://reviews.llvm.org/D27406
      
      llvm-svn: 289045
      baffdb8b
    • Simon Atanasyan's avatar
      [ELF][MIPS] Make _gp, _gp_disp, __gnu_local_gp global symbols · 6a4eb75c
      Simon Atanasyan authored
      These MIPS specific symbols should be global because in general they can
      have an arbitrary value. By default this value is a fixed offset from .got
      section.
      
      This patch adds more checks to the mips-gp-local.s test case but marks
      it as XFAIL because LLD does not allow redefinition of absolute symbols
      value by a linker script. This should be fixed by D27276.
      
      Differential revision: https://reviews.llvm.org/D27524
      
      llvm-svn: 289025
      6a4eb75c
  13. Dec 06, 2016
    • Rafael Espindola's avatar
      Don't crash trying to write an 0 addend. · e004d4bf
      Rafael Espindola authored
      For preemptable symbols the dynamic linker does all the work. Trying
      to compute the addend is at best wasteful and can also lead to crashes
      in cases of programs that uses tls but doesn't define any tls
      variables.
      
      llvm-svn: 288803
      e004d4bf
  14. Dec 02, 2016
  15. Dec 01, 2016
    • Sean Silva's avatar
      Add `isRelExprOneOf` helper · 2eed7592
      Sean Silva authored
      In various places in LLD's hot loops, we have expressions of the form
      "E == R_FOO || E == R_BAR || ..." (E is a RelExpr).
      
      Some of these expressions are quite long, and even though they usually go just
      a very small number of ways and so should be well predicted, they can still
      occupy branch predictor resources harming other parts of the code, or they
      won't be predicted well if they overflow branch predictor resources or if the
      branches are too dense and the branch predictor can't track them all (the
      compiler can in theory avoid this, at a cost in text size). And some of these
      expressions are so large and executed so frequently that even when
      well-predicted they probably still have a nontrivial cost.
      
      This speedup should be pretty portable. The cost of these simple bit tests is
      independent of:
      
      - the target we are linking for
      - the distribution of RelExpr's for a given link (which can depend on how the
        input files were compiled)
      - what compiler was used to compile LLD (it is just a simple bit test;
        hopefully the compiler gets it right!)
      - adding new target-dependent relocations (e.g. needsPlt doesn't pay any extra
        cost checking R_PPC_PLT_OPD on x86-64 builds)
      
      I did some rough measurements on clang-fsds and this patch gives over about 4%
      speedup for a regular -O1 link, about 2.5% for -O3 --gc-sections and over 5%
      for -O0. Sorry, I don't have my current machine set up for doing really
      accurate measurements right now.
      
      This also is just a bit cleaner. Thanks for Joerg for suggesting for
      this approach.
      
      Differential Revision: https://reviews.llvm.org/D27156
      
      llvm-svn: 288314
      2eed7592
  16. Nov 29, 2016
    • Peter Smith's avatar
      [ELF] Add support for static TLS to ARM · de3e7388
      Peter Smith authored
      The module index dynamic relocation R_ARM_DTPMOD32 is always 1 for an
      executable. When static linking and when we know that we are not a shared
      object we can resolve the module index relocation statically.
          
      The logic in handleNoRelaxTlsRelocation remains the same for Mips as it
      has its own custom GOT writing code. For ARM we add the module index
      relocation to the GOT when it can be resolved statically.
          
      In addition the type of the RelExpr for the static resolution of TlsGotRel
      should be R_TLS and not R_ABS as we need to include the size of
      the thread control block in the calculation.
          
      Addresses the TLS part of PR30218.
      
      Differential revision: https://reviews.llvm.org/D27213
      
      llvm-svn: 288153
      de3e7388
    • Rafael Espindola's avatar
      Use relocations to fill statically known got entries. · f1e24531
      Rafael Espindola authored
      Right now we just remember a SymbolBody for each got entry and
      duplicate a bit of logic to decide what value, if any, should be
      written for that SymbolBody.
      
      With ARM there will be more complicated values, and it seems better to
      just use the relocation code to fill the got entries. This makes it
      clear that each entry is filled by the dynamic linker or by the static
      linker.
      
      llvm-svn: 288107
      f1e24531
  17. Nov 25, 2016
  18. Nov 24, 2016
  19. Nov 23, 2016
  20. Nov 21, 2016
    • Rui Ueyama's avatar
      Change the way how we print out line numbers. · e8785ba4
      Rui Ueyama authored
      LLD's error messages contain line numbers, function names or section names.
      Currently they are formatter as follows.
      
        foo.c (32): symbol 'foo' not found
        foo.c (function bar): symbol 'foo' not found
        foo.c (.text+0x1234): symbol 'foo' not found
      
      This patch changes them so that they are consistent with Clang's output.
      
        foo.c:32: symbol 'foo' not found
        foo.c:(function bar): symbol 'foo' not found
        foo.c:(.text+0x1234): symbol 'foo' not found
      
      Differential Revision: https://reviews.llvm.org/D26901
      
      llvm-svn: 287537
      e8785ba4
  21. Nov 18, 2016
  22. Nov 16, 2016
  23. Nov 15, 2016
  24. Nov 11, 2016
  25. Nov 10, 2016
    • Rafael Espindola's avatar
      Parse relocations only once. · 9f0c4bb7
      Rafael Espindola authored
      Relocations are the last thing that we wore storing a raw section
      pointer to and parsing on demand.
      
      With this patch we parse it only once and store a pointer to the
      actual data.
      
      The patch also changes where we store it. It is now in
      InputSectionBase. Not all sections have relocations, but most do and
      this simplifies the logic. It also means that we now only support one
      relocation section per section. Given that that constraint is
      maintained even with -r with gold bfd and lld, I think it is OK.
      
      llvm-svn: 286459
      9f0c4bb7
Loading