[all-commits] [llvm/llvm-project] 2d48b1: [lld/mac] Fix mislink with ICF

Nico Weber via All-commits all-commits at lists.llvm.org
Sat Oct 30 15:59:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d48b19136722f76e467c5e72d36208455f63953
      https://github.com/llvm/llvm-project/commit/2d48b19136722f76e467c5e72d36208455f63953
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-10-30 (Sat, 30 Oct 2021)

  Changed paths:
    M lld/MachO/ICF.cpp
    M lld/test/MachO/icf-literals.s

  Log Message:
  -----------
  [lld/mac] Fix mislink with ICF

When comparing relocations against two symbols, ICF's equalsConstant() did not
look at the value of the two symbols. With subsections_via_symbols, the value
is usually 0 but not always: In particular, it isn't 0 for constants in string
and literal sections. Since we ignored the value, comparing two constant string
symbols or two literal symbols always compared the 0th's element, so functions
in the same TU always compared as equal.

This can cause mislinks, and, with -dead_strip, crashes.

Fixes PR52349, see that bug for lots of details and examples of mislinks.

While here, make the existing assembly in icf-literals.s a bit more realistic
(use leaq instead of movq with strings, and use foo(%rip) instead of
foo at gotpcrel(%rip)). This has no interesting effect, it just maybe makes the
test look a bit less surprising.

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




More information about the All-commits mailing list