[PATCH] D112584: [lld/mac] Don't assert when ICFing arm64 code

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 17:34:50 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added subscribers: pengfei, kristof.beyls.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

WordLiteralSection dedupes literals by content.
WordLiteralInputSection::getOffset() used to read a literal at the passed-in
offset and look up this value in the deduping map to find the offset of the
deduped value.

But it's possible that (e.g.) a 16-byte literal's value is accessed 4 bytes in.
To get the offset at that address, we have to get the deduped value at offset 0
and then apply the offset 4 to the result.

(See also WordLiteralSection::finalizeContents() which fills in those maps.)

Only a problem on arm64 because in x86_64 the offset is part of the instruction
instead of a separate ARM64_RELOC_ADDEND relocation. (See bug for more details.)

Fixes PR51999.


https://reviews.llvm.org/D112584

Files:
  lld/MachO/InputSection.cpp
  lld/MachO/SyntheticSections.h
  lld/test/MachO/icf-arm64.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112584.382490.patch
Type: text/x-patch
Size: 4158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/431c2ff4/attachment.bin>


More information about the llvm-commits mailing list