Index: lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp =================================================================== --- lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp +++ lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp @@ -51,6 +51,7 @@ SMLoc NameLoc, OperandVector &Operands) override; bool ParseDirective(AsmToken DirectiveID) override; + bool ParseDirectiveRefSym(AsmToken DirectiveID); unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, unsigned Kind) override; @@ -407,6 +408,16 @@ return false; } +bool MSP430AsmParser::ParseDirectiveRefSym(AsmToken DirectiveID) { + StringRef Name; + if (getParser().parseIdentifier(Name)) + return TokError("expected identifier in directive"); + + MCSymbol *Sym = getContext().getOrCreateSymbol(Name); + getStreamer().EmitSymbolAttribute(Sym, MCSA_Global); + return false; +} + bool MSP430AsmParser::ParseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); if (IDVal.lower() == ".long") { @@ -415,6 +426,8 @@ ParseLiteralValues(2, DirectiveID.getLoc()); } else if (IDVal.lower() == ".byte") { ParseLiteralValues(1, DirectiveID.getLoc()); + } else if (IDVal.lower() == ".refsym") { + return ParseDirectiveRefSym(DirectiveID); } return true; } Index: test/MC/MSP430/refsym.s =================================================================== --- /dev/null +++ test/MC/MSP430/refsym.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc -filetype=obj -triple=msp430 %s | llvm-readobj -t - | FileCheck %s + +foo: + .refsym __hook + +; CHECK: Symbol { +; CHECK: Name: __hook (30) +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 0 +; CHECK-NEXT: Binding: Global (0x1) +; CHECK-NEXT: Type: None (0x0) +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: Undefined (0x0) +; CHECK-NEXT: }