[all-commits] [llvm/llvm-project] b5c850: [lld-macho] Mark local personality functions as `I...

Daniel Bertalan via All-commits all-commits at lists.llvm.org
Thu Jun 13 06:17:18 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b5c850f718e1bc4d1aa0588f65ae53086f978e1a
      https://github.com/llvm/llvm-project/commit/b5c850f718e1bc4d1aa0588f65ae53086f978e1a
  Author: Daniel Bertalan <dani at danielbertalan.dev>
  Date:   2024-06-13 (Thu, 13 Jun 2024)

  Changed paths:
    M lld/MachO/SyntheticSections.cpp
    M lld/test/MachO/arm64-reloc-pointer-to-got.s
    M lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
    M lld/test/MachO/compact-unwind.s
    M lld/test/MachO/dead-strip.s
    M lld/test/MachO/invalid/compact-unwind-personalities.s

  Log Message:
  -----------
  [lld-macho] Mark local personality functions as `INDIRECT_SYMBOL_LOCAL` (#95171)

This expands on the fix in 4e572db. The issue is pretty similar: we
might put symbols in the GOT which don't need run-time binding, locally
defined personality symbols in this case. We should set their indirect
symbol table entries to `INDIRECT_SYMBOL_LOCAL` to help `strip` remove
these local names from the symbol table.

Checking if the symbol is private-extern doesn't cover all cases; it can
also be a non-weak extern function too, for instance; use the
`needsBinding()` helper to determine it. This was the case for the
personality function in statically linked Rust executables.

The extra non-`LOCAL` symbols triggered a bug in Apple's `strip`
implementation. As the indirect value for the personality function was
not set to the flag, but the symbol didn't require binding, it tried to
make the symbol local, overwriting the GOT entry with the function's
address in the process. This normally wouldn't be a problem, but if
chained fixups are used, the fixup also encodes the offset to the next
fixup, and it effectively zeroed this offset out, causing the remaining
relocations on the page to not be performed by dyld.

This caused the crash in https://issues.chromium.org/issues/325410295

The change in tests is a bit ugly, as a lot of symbol information is now
removed by turning more symbols `LOCAL`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list