add symbol attribute support for the ELF .type directive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94435 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-25 18:30:45 +00:00
parent 032742972f
commit ed0ab15170
3 changed files with 48 additions and 14 deletions

View File

@ -20,19 +20,25 @@ enum MCSymbolAttr {
MCSA_Invalid = 0, /// Not a valid directive.
// Various directives in alphabetical order.
MCSA_Global, /// .globl
MCSA_Hidden, /// .hidden (ELF)
MCSA_IndirectSymbol, /// .indirect_symbol (MachO)
MCSA_Internal, /// .internal (ELF)
MCSA_LazyReference, /// .lazy_reference (MachO)
MCSA_Local, /// .local (ELF)
MCSA_NoDeadStrip, /// .no_dead_strip (MachO)
MCSA_PrivateExtern, /// .private_extern (MachO)
MCSA_Protected, /// .protected (ELF)
MCSA_Reference, /// .reference (MachO)
MCSA_Weak, /// .weak
MCSA_WeakDefinition, /// .weak_definition (MachO)
MCSA_WeakReference /// .weak_reference (MachO)
MCSA_ELF_TypeFunction, /// .type _foo, STT_FUNC # aka @function
MCSA_ELF_TypeIndFunction, /// .type _foo, STT_GNU_IFUNC
MCSA_ELF_TypeObject, /// .type _foo, STT_OBJECT # aka @object
MCSA_ELF_TypeTLS, /// .type _foo, STT_TLS # aka @tls_object
MCSA_ELF_TypeCommon, /// .type _foo, STT_COMMON # aka @common
MCSA_ELF_TypeNoType, /// .type _foo, STT_NOTYPE # aka @notype
MCSA_Global, /// .globl
MCSA_Hidden, /// .hidden (ELF)
MCSA_IndirectSymbol, /// .indirect_symbol (MachO)
MCSA_Internal, /// .internal (ELF)
MCSA_LazyReference, /// .lazy_reference (MachO)
MCSA_Local, /// .local (ELF)
MCSA_NoDeadStrip, /// .no_dead_strip (MachO)
MCSA_PrivateExtern, /// .private_extern (MachO)
MCSA_Protected, /// .protected (ELF)
MCSA_Reference, /// .reference (MachO)
MCSA_Weak, /// .weak
MCSA_WeakDefinition, /// .weak_definition (MachO)
MCSA_WeakReference /// .weak_reference (MachO)
};
enum MCAssemblerFlag {

View File

@ -227,7 +227,29 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
MCSymbolAttr Attribute) {
switch (Attribute) {
case MCSA_Invalid: assert(0 && "Invalid symbol attribute");
case MCSA_Global: OS << MAI.getGlobalDirective(); break; // .globl
case MCSA_ELF_TypeFunction: /// .type _foo, STT_FUNC # aka @function
case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC
case MCSA_ELF_TypeObject: /// .type _foo, STT_OBJECT # aka @object
case MCSA_ELF_TypeTLS: /// .type _foo, STT_TLS # aka @tls_object
case MCSA_ELF_TypeCommon: /// .type _foo, STT_COMMON # aka @common
case MCSA_ELF_TypeNoType: /// .type _foo, STT_NOTYPE # aka @notype
assert(MAI.hasDotTypeDotSizeDirective() && "Symbol Attr not supported");
OS << ".type " << *Symbol << ','
<< ((MAI.getCommentString()[0] != '@') ? '@' : '%');
switch (Attribute) {
default: assert(0 && "Unknown ELF .type");
case MCSA_ELF_TypeFunction: OS << "function"; break;
case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break;
case MCSA_ELF_TypeObject: OS << "object"; break;
case MCSA_ELF_TypeTLS: OS << "tls_object"; break;
case MCSA_ELF_TypeCommon: OS << "common"; break;
case MCSA_ELF_TypeNoType: OS << "no_type"; break;
}
EmitEOL();
return;
case MCSA_Global: // .globl/.global
OS << MAI.getGlobalDirective();
break;
case MCSA_Hidden: OS << ".hidden "; break;
case MCSA_IndirectSymbol: OS << ".indirect_symbol "; break;
case MCSA_Internal: OS << ".internal "; break;

View File

@ -223,6 +223,12 @@ void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
// defined.
switch (Attribute) {
case MCSA_Invalid:
case MCSA_ELF_TypeFunction:
case MCSA_ELF_TypeIndFunction:
case MCSA_ELF_TypeObject:
case MCSA_ELF_TypeTLS:
case MCSA_ELF_TypeCommon:
case MCSA_ELF_TypeNoType:
case MCSA_IndirectSymbol:
case MCSA_Hidden:
case MCSA_Internal: