Index: devel/llvm80/files/patch-include_llvm_ADT_Triple.h =================================================================== --- /dev/null +++ devel/llvm80/files/patch-include_llvm_ADT_Triple.h @@ -0,0 +1,11 @@ +--- include/llvm/ADT/Triple.h.orig 2019-01-16 05:23:52 UTC ++++ include/llvm/ADT/Triple.h +@@ -201,6 +201,8 @@ class Triple { (public) + CODE16, + EABI, + EABIHF, ++ ELFv1, ++ ELFv2, + Android, + Musl, + MuslEABI, Index: devel/llvm80/files/patch-lib_MC_ELFObjectWriter.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-lib_MC_ELFObjectWriter.cpp @@ -0,0 +1,10 @@ +--- lib/MC/ELFObjectWriter.cpp.orig 2019-02-18 10:39:35 UTC ++++ lib/MC/ELFObjectWriter.cpp +@@ -1271,6 +1271,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssem + // This is the first place we are able to copy this information. + Alias->setExternal(Symbol.isExternal()); + Alias->setBinding(Symbol.getBinding()); ++ Alias->setOther(Symbol.getOther()); + + if (!Symbol.isUndefined() && !Rest.startswith("@@@")) + continue; Index: devel/llvm80/files/patch-lib_Support_Triple.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-lib_Support_Triple.cpp @@ -0,0 +1,20 @@ +--- lib/Support/Triple.cpp.orig 2019-01-16 05:23:52 UTC ++++ lib/Support/Triple.cpp +@@ -226,6 +226,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentTy + case CODE16: return "code16"; + case EABI: return "eabi"; + case EABIHF: return "eabihf"; ++ case ELFv1: return "elfv1"; ++ case ELFv2: return "elfv2"; + case Android: return "android"; + case Musl: return "musl"; + case MuslEABI: return "musleabi"; +@@ -514,6 +516,8 @@ static Triple::EnvironmentType parseEnvironment(String + return StringSwitch(EnvironmentName) + .StartsWith("eabihf", Triple::EABIHF) + .StartsWith("eabi", Triple::EABI) ++ .StartsWith("elfv1", Triple::ELFv1) ++ .StartsWith("elfv2", Triple::ELFv2) + .StartsWith("gnuabin32", Triple::GNUABIN32) + .StartsWith("gnuabi64", Triple::GNUABI64) + .StartsWith("gnueabihf", Triple::GNUEABIHF) Index: devel/llvm80/files/patch-lib_Target_PowerPC_MCTargetDesc_PPCMCTargetDesc.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-lib_Target_PowerPC_MCTargetDesc_PPCMCTargetDesc.cpp @@ -0,0 +1,50 @@ +--- lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp.orig 2017-11-29 23:05:56 UTC ++++ lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +@@ -15,6 +15,7 @@ + #include "InstPrinter/PPCInstPrinter.h" + #include "MCTargetDesc/PPCMCAsmInfo.h" + #include "PPCTargetStreamer.h" ++#include "llvm/ADT/SmallPtrSet.h" + #include "llvm/ADT/StringRef.h" + #include "llvm/ADT/Triple.h" + #include "llvm/BinaryFormat/ELF.h" +@@ -182,16 +183,33 @@ class PPCTargetELFStreamer : public PPCTargetStreamer + + void emitAssignment(MCSymbol *S, const MCExpr *Value) override { + auto *Symbol = cast(S); ++ + // When encoding an assignment to set symbol A to symbol B, also copy + // the st_other bits encoding the local entry point offset. +- if (Value->getKind() != MCExpr::SymbolRef) +- return; +- const auto &RhsSym = cast( +- static_cast(Value)->getSymbol()); +- unsigned Other = Symbol->getOther(); ++ if (copyLocalEntry(Symbol, Value)) ++ UpdateOther.insert(Symbol); ++ else ++ UpdateOther.erase(Symbol); ++ } ++ ++ void finish() override { ++ for (auto *Sym : UpdateOther) ++ copyLocalEntry(Sym, Sym->getVariableValue()); ++ } ++ ++private: ++ SmallPtrSet UpdateOther; ++ ++ bool copyLocalEntry(MCSymbolELF *D, const MCExpr *S) { ++ auto *Ref = dyn_cast(S); ++ if (!Ref) ++ return false; ++ const auto &RhsSym = cast(Ref->getSymbol()); ++ unsigned Other = D->getOther(); + Other &= ~ELF::STO_PPC64_LOCAL_MASK; + Other |= RhsSym.getOther() & ELF::STO_PPC64_LOCAL_MASK; +- Symbol->setOther(Other); ++ D->setOther(Other); ++ return true; + } + }; + Index: devel/llvm80/files/patch-lib_Target_PowerPC_PPCTargetMachine.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-lib_Target_PowerPC_PPCTargetMachine.cpp @@ -0,0 +1,11 @@ +--- lib/Target/PowerPC/PPCTargetMachine.cpp.orig 2018-12-07 12:10:23 UTC ++++ lib/Target/PowerPC/PPCTargetMachine.cpp +@@ -199,6 +199,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const + case Triple::ppc64le: + return PPCTargetMachine::PPC_ABI_ELFv2; + case Triple::ppc64: ++ if (TT.getEnvironment() == llvm::Triple::ELFv2) ++ return PPCTargetMachine::PPC_ABI_ELFv2; + return PPCTargetMachine::PPC_ABI_ELFv1; + default: + return PPCTargetMachine::PPC_ABI_UNKNOWN; Index: devel/llvm80/files/patch-tools_clang_lib_Basic_Targets_PPC.h =================================================================== --- /dev/null +++ devel/llvm80/files/patch-tools_clang_lib_Basic_Targets_PPC.h @@ -0,0 +1,17 @@ +--- tools/clang/lib/Basic/Targets/PPC.h.orig 2019-02-12 11:19:21 UTC ++++ tools/clang/lib/Basic/Targets/PPC.h +@@ -364,13 +364,11 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public + + if ((Triple.getArch() == llvm::Triple::ppc64le)) { + resetDataLayout("e-m:e-i64:64-n32:64"); +- ABI = "elfv2"; + } else { + resetDataLayout("E-m:e-i64:64-n32:64"); +- ABI = "elfv1"; + } + +- switch (getTriple().getOS()) { ++ switch (Triple.getOS()) { + case llvm::Triple::FreeBSD: + LongDoubleWidth = LongDoubleAlign = 64; + LongDoubleFormat = &llvm::APFloat::IEEEdouble(); Index: devel/llvm80/files/patch-tools_lld_ELF_Arch_PPC64.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-tools_lld_ELF_Arch_PPC64.cpp @@ -0,0 +1,25 @@ +--- tools/lld/ELF/Arch/PPC64.cpp.orig 2019-01-10 15:08:02 UTC ++++ tools/lld/ELF/Arch/PPC64.cpp +@@ -113,6 +113,7 @@ class PPC64 final : public TargetInfo { (public) + void writeGotHeader(uint8_t *Buf) const override; + bool needsThunk(RelExpr Expr, RelType Type, const InputFile *File, + uint64_t BranchAddr, const Symbol &S) const override; ++ uint32_t getThunkSectionSpacing() const override; + bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const override; + RelExpr adjustRelaxExpr(RelType Type, const uint8_t *Data, + RelExpr Expr) const override; +@@ -757,6 +758,14 @@ bool PPC64::needsThunk(RelExpr Expr, RelType Type, con + // If the offset exceeds the range of the branch type then it will need + // a range-extending thunk. + return !inBranchRange(Type, BranchAddr, S.getVA()); ++} ++ ++uint32_t PPC64::getThunkSectionSpacing() const { ++ // See comment in Arch/ARM.cpp for a more detailed explanation of ++ // getThunkSectionSpacing(). For PPC64 we pick the constant here based on ++ // R_PPC64_REL24, which is used by unconditional branch instructions. ++ // 0x2000000 = (1 << 24-1) * 4 ++ return 0x2000000; + } + + bool PPC64::inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const { Index: devel/llvm80/files/patch-tools_lld_ELF_SyntheticSections.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-tools_lld_ELF_SyntheticSections.cpp @@ -0,0 +1,14 @@ +--- tools/lld/ELF/SyntheticSections.cpp.orig 2019-01-29 13:22:08 UTC ++++ tools/lld/ELF/SyntheticSections.cpp +@@ -2001,6 +2001,11 @@ template void SymbolTableSection::w + ESym->setVisibility(Sym->Visibility); + } + ++ // The 3 most significant bits of st_other are used by OpenPOWER ABI. ++ // See getPPC64GlobalEntryToLocalEntryOffset() for more details. ++ if (Config->EMachine == EM_PPC64) ++ ESym->st_other |= Sym->StOther & 0xe0; ++ + ESym->st_name = Ent.StrTabOffset; + ESym->st_shndx = getSymSectionIndex(Ent.Sym); + Index: devel/llvm80/files/patch-tools_llvm-objdump_llvm-objdump.cpp =================================================================== --- /dev/null +++ devel/llvm80/files/patch-tools_llvm-objdump_llvm-objdump.cpp @@ -0,0 +1,47 @@ +--- tools/llvm-objdump/llvm-objdump.cpp.orig 2019-01-15 14:03:50 UTC ++++ tools/llvm-objdump/llvm-objdump.cpp +@@ -2087,20 +2087,38 @@ void llvm::printSymbolTable(const ObjectFile *O, Strin + outs() << SectionName; + } + +- outs() << '\t'; + if (Common || isa(O)) { + uint64_t Val = + Common ? Symbol.getAlignment() : ELFSymbolRef(Symbol).getSize(); +- outs() << format("\t %08" PRIx64 " ", Val); ++ outs() << format("\t%08" PRIx64, Val); + } + +- if (Hidden) +- outs() << ".hidden "; ++ if (isa(O)) { ++ uint8_t Other = ELFSymbolRef(Symbol).getOther(); ++ switch (Other) { ++ case ELF::STV_DEFAULT: ++ break; ++ case ELF::STV_INTERNAL: ++ outs() << " .internal"; ++ break; ++ case ELF::STV_HIDDEN: ++ outs() << " .hidden"; ++ break; ++ case ELF::STV_PROTECTED: ++ outs() << " .protected"; ++ break; ++ default: ++ outs() << format(" 0x%02x", Other); ++ break; ++ } ++ } else if (Hidden) { ++ outs() << " .hidden"; ++ } + + if (Demangle) +- outs() << demangle(Name) << '\n'; ++ outs() << ' ' << demangle(Name) << '\n'; + else +- outs() << Name << '\n'; ++ outs() << ' ' << Name << '\n'; + } + } +