[llvm] [MachO] Preserve weak linkage for aliases (PR #198148)
Folkert de Vries via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 18 12:07:41 PDT 2026
================
@@ -443,7 +443,10 @@ void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) {
// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
// value.
bool EncodeAsAltEntry = IsAlias && OrigSymbol.isAltEntry();
- W.write<uint16_t>(Symbol->getEncodedFlags(EncodeAsAltEntry));
+ uint16_t Flags = Symbol->getEncodedFlags(EncodeAsAltEntry);
+ if (IsAlias)
+ Flags |= OrigSymbol.getEncodedFlags(EncodeAsAltEntry);
----------------
folkertdev wrote:
Can you put this in a comment here, it's not obvious.
> When writing aliased symbols, keep the aliasee flags and include the alias symbol's own flags so N_WEAK_DEF is preserved in the Mach-O n_desc field.
https://github.com/llvm/llvm-project/pull/198148
More information about the llvm-commits
mailing list