diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h b/llvm/include/llvm/MC/MCObjectFileInfo.h index 3c1d10c4e62f10..be5c768cf0a542 100644 --- a/llvm/include/llvm/MC/MCObjectFileInfo.h +++ b/llvm/include/llvm/MC/MCObjectFileInfo.h @@ -344,7 +344,7 @@ class MCObjectFileInfo { } MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; } - const MCSection *getTLSDataSection() const { return TLSDataSection; } + MCSection *getTLSDataSection() const { return TLSDataSection; } MCSection *getTLSBSSSection() const { return TLSBSSSection; } MCSection *getStackMapSection() const { return StackMapSection; } diff --git a/llvm/tools/objwriter/objwriter.cpp b/llvm/tools/objwriter/objwriter.cpp index 27ac94aa0e88d4..beea87c043af7a 100644 --- a/llvm/tools/objwriter/objwriter.cpp +++ b/llvm/tools/objwriter/objwriter.cpp @@ -222,6 +222,10 @@ MCSection *ObjectWriter::GetSection(const char *SectionName, Section = ObjFileInfo->getReadOnlySection(); } else if (strcmp(SectionName, "xdata") == 0) { Section = ObjFileInfo->getXDataSection(); + } else if (strcmp(SectionName, "tdata") == 0) { + Section = ObjFileInfo->getTLSDataSection(); + } else if (strcmp(SectionName, "tbss") == 0) { + Section = ObjFileInfo->getTLSBSSSection(); } else if (strcmp(SectionName, "bss") == 0) { if (OutContext->getObjectFileType() == MCContext::IsMachO) { Section = ObjFileInfo->getDataBSSSection(); @@ -457,6 +461,18 @@ int ObjectWriter::EmitSymbolRef(const char *SymbolName, case RelocType::IMAGE_REL_BASED_DIR64: Size = 8; break; + case RelocType::IMAGE_REL_SECREL: + Kind = MCSymbolRefExpr::VK_SECREL; + Size = 4; + break; + case RelocType::IMAGE_REL_TLSGD: + Kind = MCSymbolRefExpr::VK_TLSGD; + Size = 4; + break; + case RelocType::IMAGE_REL_TPOFF: + Kind = MCSymbolRefExpr::VK_TPOFF; + Size = 4; + break; case RelocType::IMAGE_REL_BASED_REL32: if (OutContext->getObjectFileType() == MCContext::IsMachO && OutContext->getTargetTriple().getArch() == Triple::aarch64) { diff --git a/llvm/tools/objwriter/objwriter.h b/llvm/tools/objwriter/objwriter.h index 860312f92a13e2..80aa61703b6cf5 100644 --- a/llvm/tools/objwriter/objwriter.h +++ b/llvm/tools/objwriter/objwriter.h @@ -59,6 +59,9 @@ enum class RelocType { IMAGE_REL_BASED_RELPTR32 = 0x7C, IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 = 0x81, IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A = 0x82, + IMAGE_REL_SECREL = 0x104, + IMAGE_REL_TLSGD = 0x105, + IMAGE_REL_TPOFF = 0x106, }; enum class SymbolRefFlags