diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-16 16:17:21 +0000 | 
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-16 16:17:21 +0000 | 
| commit | e90c1cb22181b42741053e27d90bced53bea3273 (patch) | |
| tree | c7128b3e75c7ff1aaf3e59749781b93c48a392f9 /llvm/lib/Target | |
| parent | 71f8b08a808b12cdfc86113f6c206a8f03d130e5 (diff) | |
| download | bcm5719-llvm-e90c1cb22181b42741053e27d90bced53bea3273.tar.gz bcm5719-llvm-e90c1cb22181b42741053e27d90bced53bea3273.zip | |
sets bit 0 of the function address of thumb function in .symtab
("T is 1 if the target symbol S has type STT_FUNC and the
symbol addresses a Thumb instruction ;it is 0 otherwise."
from "ELF for the ARM Architecture" 4.7.1.2)
Patch by Koan-Sin Tan!
llvm-svn: 131406
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 25 | 
2 files changed, 21 insertions, 6 deletions
| diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index f90d3756b37..93282701d85 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -274,7 +274,7 @@ void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const {  void ARMAsmPrinter::EmitFunctionEntryLabel() {    if (AFI->isThumbFunction()) {      OutStreamer.EmitAssemblerFlag(MCAF_Code16); -    OutStreamer.EmitThumbFunc(Subtarget->isTargetDarwin()? CurrentFnSym : 0); +    OutStreamer.EmitThumbFunc(CurrentFnSym);    }    OutStreamer.EmitLabel(CurrentFnSym); diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 29ecc182d31..401894e75e1 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -15,6 +15,7 @@  #include "llvm/MC/MCParser/MCAsmLexer.h"  #include "llvm/MC/MCParser/MCAsmParser.h"  #include "llvm/MC/MCParser/MCParsedAsmOperand.h" +#include "llvm/MC/MCAsmInfo.h"  #include "llvm/MC/MCContext.h"  #include "llvm/MC/MCStreamer.h"  #include "llvm/MC/MCExpr.h" @@ -2099,15 +2100,29 @@ bool ARMAsmParser::ParseDirectiveThumb(SMLoc L) {  /// ParseDirectiveThumbFunc  ///  ::= .thumbfunc symbol_name  bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) { -  const AsmToken &Tok = Parser.getTok(); -  if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) -    return Error(L, "unexpected token in .thumb_func directive"); -  StringRef Name = Tok.getString(); -  Parser.Lex(); // Consume the identifier token. +  const MCAsmInfo &MAI = getParser().getStreamer().getContext().getAsmInfo(); +  bool isMachO = MAI.hasSubsectionsViaSymbols(); +  StringRef Name; + +  // Darwin asm has function name after .thumb_func direction +  // ELF doesn't +  if (isMachO) { +    const AsmToken &Tok = Parser.getTok(); +    if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) +      return Error(L, "unexpected token in .thumb_func directive"); +    Name = Tok.getString(); +    Parser.Lex(); // Consume the identifier token. +  } +    if (getLexer().isNot(AsmToken::EndOfStatement))      return Error(L, "unexpected token in directive");    Parser.Lex(); +  // FIXME: assuming function name will be the line following .thumb_func +  if (!isMachO) { +    Name = Parser.getTok().getString(); +  } +    // Mark symbol as a thumb symbol.    MCSymbol *Func = getParser().getContext().GetOrCreateSymbol(Name);    getParser().getStreamer().EmitThumbFunc(Func); | 

