[PATCH] D112862: [lld/mac] Fix mislink with ICF

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 19:32:54 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

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.


https://reviews.llvm.org/D112862

Files:
  lld/MachO/ICF.cpp
  lld/test/MachO/icf-literals.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112862.383550.patch
Type: text/x-patch
Size: 3046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211030/064bc9de/attachment.bin>


More information about the llvm-commits mailing list