[all-commits] [llvm/llvm-project] 6afbda: [lld-macho] Fix duplicate GOT entries for personal...

Daniel Bertalan via All-commits all-commits at lists.llvm.org
Tue Jun 11 12:51:49 PDT 2024


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

  Changed paths:
    M lld/MachO/UnwindInfoSection.cpp
    M lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
    M lld/test/MachO/compact-unwind.s

  Log Message:
  -----------
  [lld-macho] Fix duplicate GOT entries for personality functions (#95054)

As stated in `UnwindInfoSectionImpl::prepareRelocations`'s comments, the
unwind info uses section+addend relocations for personality functions
defined in the same file as the function itself. As personality
functions are always accessed via the GOT, we need to resolve those to a
symbol. Previously, we did this by keeping a map which resolves these to
symbols, creating a synthetic symbol if we didn't find it in the map.

This approach has an issue: if we process the object file containing the
personality function before any external uses, the entry in the map
remains unpopulated, so we create a synthetic symbol and a corresponding
GOT entry. If we encounter a relocation to it in a later file which
requires GOT (such as in `__eh_frame`), we add that symbol to the GOT,
too, effectively creating two entries which point to the same piece of
code.

This commit fixes that by searching the personality function's section
for a symbol at that offset which already has a GOT entry, and only
creating a synthetic symbol if there is none. As all non-unwind sections
are already processed by this point, it ensures no duplication.

This should only really affect our tests (and make them clearer), as
personality functions are usually defined in platform runtime libraries.
Or even if they are local, they are likely not in the first object file
to be linked.



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