Skip to content

Commit

Permalink
More fixes (#437)
Browse files Browse the repository at this point in the history
* Merge pull request #429 from VSadov/tls1

Changes to support TLS access emitted in ILC (x64 win/linux)

* Fix DWARF debug information emitted for empty enum (#433)

(cherry picked from commit 167a9c5)

---------

Co-authored-by: Filip Navara <filip.navara@gmail.com>
  • Loading branch information
2 people authored and radekdoulik committed Sep 2, 2024
1 parent 119ff01 commit eef505b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCObjectFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,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; }
Expand Down
7 changes: 7 additions & 0 deletions llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPoin
dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
0, 0,

EnumerationTypeNoChildren,
dwarf::DW_TAG_enumeration_type, dwarf::DW_CHILDREN_no,
dwarf::DW_AT_name, dwarf::DW_FORM_strp,
dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
0, 0,

Enumerator1,
dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no,
dwarf::DW_AT_name, dwarf::DW_FORM_strp,
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum DwarfAbbrev : uint16_t
CompileUnit = 0x1,
BaseType,
EnumerationType,
EnumerationTypeNoChildren,
Enumerator1,
Enumerator2,
Enumerator4,
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void DwarfEnumTypeInfo::DumpStrings(MCObjectStreamer *Streamer) {

void DwarfEnumTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) {
// Abbrev Number
Streamer->emitULEB128IntValue(DwarfAbbrev::EnumerationType);
Streamer->emitULEB128IntValue(HasChildren() ? DwarfAbbrev::EnumerationType : DwarfAbbrev::EnumerationTypeNoChildren);

// DW_AT_name
EmitSectionOffset(Streamer, StrSymbol, 4);
Expand Down
16 changes: 16 additions & 0 deletions llvm/tools/objwriter/objwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,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();
Expand Down Expand Up @@ -458,6 +462,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) {
Expand Down
3 changes: 3 additions & 0 deletions llvm/tools/objwriter/objwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eef505b

Please sign in to comment.