[all-commits] [llvm/llvm-project] 416707: Fix issues with GlobalMerge on Mach-O. (#110046)
James Y Knight via All-commits
all-commits at lists.llvm.org
Fri Sep 27 09:19:32 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 416707754fa5aafd2a6fd73d5d577f9745928d6a
https://github.com/llvm/llvm-project/commit/416707754fa5aafd2a6fd73d5d577f9745928d6a
Author: James Y Knight <jyknight at google.com>
Date: 2024-09-27 (Fri, 27 Sep 2024)
Changed paths:
M llvm/lib/CodeGen/GlobalMerge.cpp
A llvm/test/Transforms/GlobalMerge/macho-sections.ll
A llvm/test/Transforms/GlobalMerge/macho-symbols.ll
Log Message:
-----------
Fix issues with GlobalMerge on Mach-O. (#110046)
As a side-effect of PR #101222, GlobalMerge started making transforms
which are unsafe on Mach-O platforms.
Two issues, in particular, are fixed here:
1. We must never merge symbols in the `__cfstring` section, as the
linker assumes each object in this section is only ever referenced
directly, and that it can split the section as it likes.
Previously, we avoided this problem because CFString literals are
identified by private-linkage symbols. This patch adds a list of
section-names with special behavior, to avoid merging under Mach-O.
2. When GlobalMerge code was originally written, it had to be careful
about emitting symbol aliases, due to issues with Mach-O's subsection
splitting in the linker with `-dead_strip` enabled. The underlying cause
of this problem was fixed in 2016, via creation of the `.alt_entry`
assembler directive, which allows a symbol to not also imply the start
of a new subsection. GlobalMerge's workaround for that issue was never
removed.
In the meantime, Apple's new ld-prime linker was written, and has a bug
in `.alt_entry` handling. Therefore, even though the original issue was
fixed, we must _continue_ to be careful not to emit any such symbol
aliases. The existing workaround avoided it for InternalLinkage symbols,
but after the above-mentioned PR, we also must avoid emitting aliases
for PrivateLinkage symbols.
I will file an Apple bug-report about this issue, so that it can be
fixed in a future version of ld-prime. But, in the meantime, the
workaround is sufficient for GlobalMerge, unless
`-global-merge-on-externals` is enabled (which it is already not by
default, on MachO platforms, due to the original issue).
Fixes #104625
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