diff options
| -rw-r--r-- | llvm/include/llvm/MC/MCContext.h | 1 | ||||
| -rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 42 | ||||
| -rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp | 8 |
6 files changed, 36 insertions, 27 deletions
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 3b39377..d96609c 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -392,6 +392,7 @@ public: Environment getObjectFileType() const { return Env; } bool isELF() const { return Env == IsELF; } bool isMachO() const { return Env == IsMachO; } + bool isXCOFF() const { return Env == IsXCOFF; } const StringRef &getSwift5ReflectionSegmentName() const { return Swift5ReflectionSegmentName; diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 393eed1..4ac73ab 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -1135,9 +1135,10 @@ MCObjectFileInfo::getCallGraphSection(const MCSection &TextSec) const { Flags |= ELF::SHF_GROUP; } - return Ctx->getELFSection(".callgraph", ELF::SHT_PROGBITS, Flags, 0, - GroupName, true, ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); + return Ctx->getELFSection( + ".callgraph", ELF::SHT_PROGBITS, Flags, 0, GroupName, true, + ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); } MCSection * @@ -1154,9 +1155,10 @@ MCObjectFileInfo::getStackSizesSection(const MCSection &TextSec) const { Flags |= ELF::SHF_GROUP; } - return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0, - GroupName, true, ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); + return Ctx->getELFSection( + ".stack_sizes", ELF::SHT_PROGBITS, Flags, 0, GroupName, true, + ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); } MCSection * @@ -1174,9 +1176,10 @@ MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const { // Use the text section's begin symbol and unique ID to create a separate // .llvm_bb_addr_map section associated with every unique text section. - return Ctx->getELFSection(".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP, - Flags, 0, GroupName, true, ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); + return Ctx->getELFSection( + ".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP, Flags, 0, GroupName, true, + ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); } MCSection * @@ -1192,10 +1195,10 @@ MCObjectFileInfo::getKCFITrapSection(const MCSection &TextSec) const { Flags |= ELF::SHF_GROUP; } - return Ctx->getELFSection(".kcfi_traps", ELF::SHT_PROGBITS, Flags, 0, - GroupName, - /*IsComdat=*/true, ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); + return Ctx->getELFSection( + ".kcfi_traps", ELF::SHT_PROGBITS, Flags, 0, GroupName, + /*IsComdat=*/true, ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); } MCSection * @@ -1211,9 +1214,10 @@ MCObjectFileInfo::getPseudoProbeSection(const MCSection &TextSec) const { Flags |= ELF::SHF_GROUP; } - return Ctx->getELFSection(PseudoProbeSection->getName(), ELF::SHT_PROGBITS, - Flags, 0, GroupName, true, ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); + return Ctx->getELFSection( + PseudoProbeSection->getName(), ELF::SHT_PROGBITS, Flags, 0, GroupName, + true, ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol())); } MCSection * @@ -1261,7 +1265,7 @@ MCSection *MCObjectFileInfo::getPCSection(StringRef Name, GroupName = Group->getName(); Flags |= ELF::SHF_GROUP; } - return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, Flags, 0, GroupName, true, - ElfSec.getUniqueID(), - cast<MCSymbolELF>(TextSec->getBeginSymbol())); + return Ctx->getELFSection( + Name, ELF::SHT_PROGBITS, Flags, 0, GroupName, true, ElfSec.getUniqueID(), + static_cast<const MCSymbolELF *>(TextSec->getBeginSymbol())); } diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 2e251cc..6782c4b 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -200,7 +200,7 @@ bool ELFAsmParser::parseDirectiveSize(StringRef, SMLoc) { StringRef Name; if (getParser().parseIdentifier(Name)) return TokError("expected identifier"); - MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name)); + auto *Sym = static_cast<MCSymbolELF *>(getContext().getOrCreateSymbol(Name)); if (getLexer().isNot(AsmToken::Comma)) return TokError("expected comma"); @@ -466,7 +466,7 @@ bool ELFAsmParser::parseLinkedToSym(MCSymbolELF *&LinkedToSym) { } return TokError("invalid linked-to symbol"); } - LinkedToSym = dyn_cast_or_null<MCSymbolELF>(getContext().lookupSymbol(Name)); + LinkedToSym = static_cast<MCSymbolELF *>(getContext().lookupSymbol(Name)); if (!LinkedToSym || !LinkedToSym->isInSection()) return Error(StartLoc, "linked-to symbol is not in a section: " + Name); return false; diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp index 08f8be7..45ac023 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp @@ -488,7 +488,8 @@ bool AArch64ELFObjectWriter::needsRelocateWithSymbol(const MCValue &Val, // this global needs to be tagged. In addition, the linker needs to know // whether to emit a special addend when relocating `end` symbols, and this // can only be determined by the attributes of the symbol itself. - if (Val.getAddSym() && cast<MCSymbolELF>(Val.getAddSym())->isMemtag()) + if (Val.getAddSym() && + static_cast<const MCSymbolELF *>(Val.getAddSym())->isMemtag()) return true; if ((Val.getSpecifier() & AArch64::S_GOT) == AArch64::S_GOT) diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp index 11c62f5..16247bd 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -450,6 +450,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, needsRelocateWithSymbol(V, (Type >> 8) & 0xff) || needsRelocateWithSymbol(V, (Type >> 16) & 0xff); + auto *Sym = static_cast<const MCSymbolELF *>(V.getAddSym()); switch (Type) { default: errs() << Type << "\n"; @@ -481,7 +482,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, // FIXME: It should be safe to return false for the STO_MIPS_MICROMIPS but // we neglect to handle the adjustment to the LSB of the addend that // it causes in applyFixup() and similar. - if (cast<MCSymbolELF>(V.getAddSym())->getOther() & ELF::STO_MIPS_MICROMIPS) + if (Sym->getOther() & ELF::STO_MIPS_MICROMIPS) return true; return false; @@ -492,7 +493,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCValue &V, case ELF::R_MIPS_16: case ELF::R_MIPS_32: case ELF::R_MIPS_GPREL32: - if (cast<MCSymbolELF>(V.getAddSym())->getOther() & ELF::STO_MIPS_MICROMIPS) + if (Sym->getOther() & ELF::STO_MIPS_MICROMIPS) return true; [[fallthrough]]; case ELF::R_MIPS_26: diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp index ec97e2e..04b886a 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp @@ -13,6 +13,7 @@ #include "llvm/BinaryFormat/MachO.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCMachObjectWriter.h" #include "llvm/MC/MCObjectWriter.h" @@ -112,14 +113,15 @@ public: // to resolve the fixup directly. Emit a relocation and leave // resolution of the final target address to the linker. if (const auto *A = Target.getAddSym()) { - if (const auto *S = dyn_cast<MCSymbolELF>(A)) { + if (getContext().isELF()) { // The "other" values are stored in the last 6 bits of the second // byte. The traditional defines for STO values assume the full byte // and thus the shift to pack it. - unsigned Other = S->getOther() << 2; + unsigned Other = static_cast<const MCSymbolELF *>(A)->getOther() << 2; if ((Other & ELF::STO_PPC64_LOCAL_MASK) != 0) return true; - } else if (const auto *S = dyn_cast<MCSymbolXCOFF>(A)) { + } else if (getContext().isXCOFF()) { + auto *S = static_cast<const MCSymbolXCOFF *>(A); return !Target.isAbsolute() && S->isExternal() && S->getStorageClass() == XCOFF::C_WEAKEXT; } |
