[PATCH] D54618: [MSP430] Add support for .refsym directive
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 15 23:45:16 PST 2018
krisb created this revision.
krisb added a reviewer: asl.
Herald added a subscriber: llvm-commits.
Introduces support for '.refsym' assembler directive.
>From GCC docs:
'.refsym' - This directive instructs assembler to add an undefined reference
to the symbol following the directive. No relocation is created for this symbol;
it will exist purely for pulling in object files from archives.
Repository:
rL LLVM
https://reviews.llvm.org/D54618
Files:
lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
test/MC/MSP430/refsym.s
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: }
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,14 +408,26 @@
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") {
ParseLiteralValues(4, DirectiveID.getLoc());
} else if (IDVal.lower() == ".word" || IDVal.lower() == ".short") {
ParseLiteralValues(2, DirectiveID.getLoc());
} else if (IDVal.lower() == ".byte") {
ParseLiteralValues(1, DirectiveID.getLoc());
+ } else if (IDVal.lower() == ".refsym") {
+ return ParseDirectiveRefSym(DirectiveID);
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54618.174334.patch
Type: text/x-patch
Size: 2011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181116/bcbd89a2/attachment.bin>
More information about the llvm-commits
mailing list