[all-commits] [llvm/llvm-project] 6b6aef: [ELF] Support copy relocation on non-default versi...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Aug 5 10:41:36 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 6b6aef5dbacef31a3c7b3a54f7f1ba54cafc7077
      https://github.com/llvm/llvm-project/commit/6b6aef5dbacef31a3c7b3a54f7f1ba54cafc7077
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-08-05 (Thu, 05 Aug 2021)

  Changed paths:
    M lld/ELF/Relocations.cpp
    M lld/test/ELF/Inputs/copy-rel-version.s
    M lld/test/ELF/copy-rel-version.s

  Log Message:
  -----------
  [ELF] Support copy relocation on non-default version symbols

Copy relocation on a non-default version symbol is unsupported and can crash at
runtime. Fortunately there is a one-line fix which works for most cases:
ensure `getSymbolsAt` unconditionally returns `ss`.

If two non-default version symbols are defined at the same place and both
are copy relocated, our implementation will copy relocated them into different
addresses. The pointer inequality is very unlikely an issue. In GNU ld, copy
relocating version aliases seems to create more pointer inequality problems than
us.

(
In glibc, sys_errlist at GLIBC_2.2.5 sys_errlist at GLIBC_2.3 sys_errlist at GLIBC_2.4
are defined at the same place, but it is unlikely they are all copy relocated in
one executable. Even if so, the variables are read-only and pointer inequality
should not be a problem.
)

Reviewed By: peter.smith

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

(cherry picked from commit 72d070b4db2da7216f63f09407bd96f49dc90bd1)




More information about the All-commits mailing list