From 1b640e05ba57e805ed00831771b75cd2e617f656 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 15 Mar 2016 01:43:05 +0000 Subject: [MachO] Add MachO alt-entry directive support. This patch adds support for the MachO .alt_entry assembly directive, and uses it for global aliases with non-zero GEP offsets. The alt_entry flag indicates that a symbol should be layed out immediately after the preceding symbol. Conceptually it introduces an alternate entry point for a function or data structure. E.g.: safe_foo: // check preconditions for foo .alt_entry fast_foo fast_foo: // body of foo, can assume preconditions. The .alt_entry flag is also implicitly set on assembly aliases of the form: a = b + C where C is a non-zero constant, since these have the same effect as an alt_entry symbol: they introduce a label that cannot be moved relative to the preceding one. Setting the alt_entry flag on aliases of this form fixes http://llvm.org/PR25381. llvm-svn: 263521 --- llvm/lib/MC/MachObjectWriter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/MC/MachObjectWriter.cpp') diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 8ebd7031c65..2013c253d2d 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -334,7 +334,7 @@ void MachObjectWriter::writeNlist(MachSymbolData &MSD, if (AliaseeInfo) SectionIndex = AliaseeInfo->SectionIndex; Symbol = AliasedSymbol; - // FIXME: Should this update Data as well? Do we need OrigSymbol at all? + // FIXME: Should this update Data as well? } // Set the N_TYPE bits. See . @@ -377,7 +377,9 @@ void MachObjectWriter::writeNlist(MachSymbolData &MSD, // The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc' // value. - write16(cast(Symbol)->getEncodedFlags()); + bool EncodeAsAltEntry = + IsAlias && cast(OrigSymbol).isAltEntry(); + write16(cast(Symbol)->getEncodedFlags(EncodeAsAltEntry)); if (is64Bit()) write64(Address); else -- cgit v1.2.3