From 082d0fd7ad4f75542a2330764b035ce805d38166 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 8 Jul 2010 17:22:42 +0000 Subject: [PATCH] Added the darwin .weak_def_can_be_hidden directive. llvm-svn: 107886 --- llvm/include/llvm/MC/MCAsmInfo.h | 8 ++++++++ llvm/include/llvm/MC/MCDirectives.h | 3 ++- llvm/lib/MC/MCAsmInfo.cpp | 1 + llvm/lib/MC/MCAsmInfoDarwin.cpp | 1 + llvm/lib/MC/MCAsmStreamer.cpp | 1 + llvm/lib/MC/MCMachOStreamer.cpp | 4 ++++ llvm/lib/MC/MCParser/AsmParser.cpp | 2 ++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h index 8516de0188d6..5d7967311438 100644 --- a/llvm/include/llvm/MC/MCAsmInfo.h +++ b/llvm/include/llvm/MC/MCAsmInfo.h @@ -217,6 +217,11 @@ namespace llvm { /// global as being a weak defined symbol. const char *WeakDefDirective; // Defaults to NULL. + /// WeakDefAutoPrivateDirective - This directive, if non-null, is used to + /// declare a global as being a weak defined symbol that is automatically + /// made private by the static linker. + const char *WeakDefAutoPrivateDirective; // Defaults to NULL. + /// LinkOnceDirective - This directive, if non-null is used to declare a /// global as being a weak defined symbol. This is used on cygwin/mingw. const char *LinkOnceDirective; // Defaults to NULL. @@ -387,6 +392,9 @@ namespace llvm { bool hasNoDeadStrip() const { return HasNoDeadStrip; } const char *getWeakRefDirective() const { return WeakRefDirective; } const char *getWeakDefDirective() const { return WeakDefDirective; } + const char *getWeakDefAutoPrivateDirective() const { + return WeakDefAutoPrivateDirective; + } const char *getLinkOnceDirective() const { return LinkOnceDirective; } MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr;} diff --git a/llvm/include/llvm/MC/MCDirectives.h b/llvm/include/llvm/MC/MCDirectives.h index 1f7364d8124e..223b09ef7aee 100644 --- a/llvm/include/llvm/MC/MCDirectives.h +++ b/llvm/include/llvm/MC/MCDirectives.h @@ -38,7 +38,8 @@ enum MCSymbolAttr { MCSA_Reference, ///< .reference (MachO) MCSA_Weak, ///< .weak MCSA_WeakDefinition, ///< .weak_definition (MachO) - MCSA_WeakReference ///< .weak_reference (MachO) + MCSA_WeakReference, ///< .weak_reference (MachO) + MCSA_WeakDefAutoPrivate ///< .weak_def_can_be_hidden (MachO) }; enum MCAssemblerFlag { diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index a275be2c53c5..b726b3d93594 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -59,6 +59,7 @@ MCAsmInfo::MCAsmInfo() { HasNoDeadStrip = false; WeakRefDirective = 0; WeakDefDirective = 0; + WeakDefAutoPrivateDirective = 0; LinkOnceDirective = 0; HiddenVisibilityAttr = MCSA_Hidden; ProtectedVisibilityAttr = MCSA_Protected; diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp index 0bd3b2d001e8..4f5075f50ef9 100644 --- a/llvm/lib/MC/MCAsmInfoDarwin.cpp +++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp @@ -33,6 +33,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { // Directives: WeakDefDirective = "\t.weak_definition "; WeakRefDirective = "\t.weak_reference "; + WeakDefAutoPrivateDirective = "\t.weak_def_can_be_hidden "; ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. HasMachoZeroFillDirective = true; // Uses .zerofill HasMachoTBSSDirective = true; // Uses .tbss diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 530c89b0759c..e272b60c4475 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -288,6 +288,7 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, case MCSA_WeakDefinition: OS << "\t.weak_definition\t"; break; // .weak_reference case MCSA_WeakReference: OS << MAI.getWeakRefDirective(); break; + case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break; } OS << *Symbol; diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 3febda0e86da..44bc267c11c2 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -273,6 +273,10 @@ void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, // it has to be in a coalesced section, but this isn't enforced. SD.setFlags(SD.getFlags() | SF_WeakDefinition); break; + + case MCSA_WeakDefAutoPrivate: + SD.setFlags(SD.getFlags() | SF_WeakDefinition | SF_WeakReference); + break; } } diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 94b545a20592..181b69ffc095 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -755,6 +755,8 @@ bool AsmParser::ParseStatement() { return ParseDirectiveSymbolAttribute(MCSA_WeakDefinition); if (IDVal == ".weak_reference") return ParseDirectiveSymbolAttribute(MCSA_WeakReference); + if (IDVal == ".weak_def_can_be_hidden") + return ParseDirectiveSymbolAttribute(MCSA_WeakDefAutoPrivate); if (IDVal == ".comm") return ParseDirectiveComm(/*IsLocal=*/false);