mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[WebAssembly] Allow each data segment to specify its own alignment
Also, add a flags field as we will almost certainly be needing that soon too. Differential Revision: https://reviews.llvm.org/D38296 llvm-svn: 314534
This commit is contained in:
parent
470b0e3bed
commit
2aed7fe062
@ -98,6 +98,8 @@ struct WasmDataSegment {
|
|||||||
WasmInitExpr Offset;
|
WasmInitExpr Offset;
|
||||||
ArrayRef<uint8_t> Content;
|
ArrayRef<uint8_t> Content;
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
|
uint32_t Alignment;
|
||||||
|
uint32_t Flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WasmElemSegment {
|
struct WasmElemSegment {
|
||||||
@ -115,7 +117,6 @@ struct WasmRelocation {
|
|||||||
|
|
||||||
struct WasmLinkingData {
|
struct WasmLinkingData {
|
||||||
uint32_t DataSize;
|
uint32_t DataSize;
|
||||||
uint32_t DataAlignment;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum : unsigned {
|
enum : unsigned {
|
||||||
@ -185,7 +186,7 @@ enum : unsigned {
|
|||||||
WASM_SYMBOL_INFO = 0x2,
|
WASM_SYMBOL_INFO = 0x2,
|
||||||
WASM_DATA_SIZE = 0x3,
|
WASM_DATA_SIZE = 0x3,
|
||||||
WASM_DATA_ALIGNMENT = 0x4,
|
WASM_DATA_ALIGNMENT = 0x4,
|
||||||
WASM_SEGMENT_NAMES = 0x5,
|
WASM_SEGMENT_INFO = 0x5,
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
|
const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
|
||||||
|
@ -109,6 +109,13 @@ struct NameEntry {
|
|||||||
StringRef Name;
|
StringRef Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SegmentInfo {
|
||||||
|
uint32_t Index;
|
||||||
|
StringRef Name;
|
||||||
|
uint32_t Alignment;
|
||||||
|
uint32_t Flags;
|
||||||
|
};
|
||||||
|
|
||||||
struct Signature {
|
struct Signature {
|
||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
SignatureForm Form = wasm::WASM_TYPE_FUNC;
|
SignatureForm Form = wasm::WASM_TYPE_FUNC;
|
||||||
@ -161,9 +168,8 @@ struct LinkingSection : CustomSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DataSize;
|
uint32_t DataSize;
|
||||||
uint32_t DataAlignment;
|
|
||||||
std::vector<SymbolInfo> SymbolInfos;
|
std::vector<SymbolInfo> SymbolInfos;
|
||||||
std::vector<NameEntry> SegmentNames;
|
std::vector<SegmentInfo> SegmentInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TypeSection : Section {
|
struct TypeSection : Section {
|
||||||
@ -298,6 +304,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Function)
|
|||||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl)
|
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl)
|
||||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation)
|
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation)
|
||||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry)
|
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry)
|
||||||
|
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SegmentInfo)
|
||||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
|
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -355,6 +362,10 @@ template <> struct MappingTraits<WasmYAML::NameEntry> {
|
|||||||
static void mapping(IO &IO, WasmYAML::NameEntry &NameEntry);
|
static void mapping(IO &IO, WasmYAML::NameEntry &NameEntry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <> struct MappingTraits<WasmYAML::SegmentInfo> {
|
||||||
|
static void mapping(IO &IO, WasmYAML::SegmentInfo &SegmentInfo);
|
||||||
|
};
|
||||||
|
|
||||||
template <> struct MappingTraits<WasmYAML::LocalDecl> {
|
template <> struct MappingTraits<WasmYAML::LocalDecl> {
|
||||||
static void mapping(IO &IO, WasmYAML::LocalDecl &LocalDecl);
|
static void mapping(IO &IO, WasmYAML::LocalDecl &LocalDecl);
|
||||||
};
|
};
|
||||||
|
@ -104,6 +104,8 @@ struct WasmDataSegment {
|
|||||||
MCSectionWasm *Section;
|
MCSectionWasm *Section;
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
uint32_t Offset;
|
uint32_t Offset;
|
||||||
|
uint32_t Alignment;
|
||||||
|
uint32_t Flags;
|
||||||
SmallVector<char, 4> Data;
|
SmallVector<char, 4> Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -282,7 +284,6 @@ private:
|
|||||||
void writeDataRelocSection();
|
void writeDataRelocSection();
|
||||||
void writeLinkingMetaDataSection(
|
void writeLinkingMetaDataSection(
|
||||||
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
|
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
|
||||||
uint32_t DataAlignment,
|
|
||||||
SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
|
SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
|
||||||
bool HasStackPointer, uint32_t StackPointerGlobal);
|
bool HasStackPointer, uint32_t StackPointerGlobal);
|
||||||
|
|
||||||
@ -499,11 +500,11 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void addData(SmallVectorImpl<char> &DataBytes,
|
static void addData(SmallVectorImpl<char> &DataBytes,
|
||||||
MCSectionWasm &DataSection, uint32_t &DataAlignment) {
|
MCSectionWasm &DataSection) {
|
||||||
DataBytes.resize(alignTo(DataBytes.size(), DataSection.getAlignment()));
|
|
||||||
DataAlignment = std::max(DataAlignment, DataSection.getAlignment());
|
|
||||||
DEBUG(errs() << "addData: " << DataSection.getSectionName() << "\n");
|
DEBUG(errs() << "addData: " << DataSection.getSectionName() << "\n");
|
||||||
|
|
||||||
|
DataBytes.resize(alignTo(DataBytes.size(), DataSection.getAlignment()));
|
||||||
|
|
||||||
for (const MCFragment &Frag : DataSection) {
|
for (const MCFragment &Frag : DataSection) {
|
||||||
if (Frag.hasInstructions())
|
if (Frag.hasInstructions())
|
||||||
report_fatal_error("only data supported in data sections");
|
report_fatal_error("only data supported in data sections");
|
||||||
@ -914,7 +915,6 @@ void WasmObjectWriter::writeDataRelocSection() {
|
|||||||
|
|
||||||
void WasmObjectWriter::writeLinkingMetaDataSection(
|
void WasmObjectWriter::writeLinkingMetaDataSection(
|
||||||
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
|
ArrayRef<WasmDataSegment> Segments, uint32_t DataSize,
|
||||||
uint32_t DataAlignment,
|
|
||||||
SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
|
SmallVector<std::pair<StringRef, uint32_t>, 4> SymbolFlags,
|
||||||
bool HasStackPointer, uint32_t StackPointerGlobal) {
|
bool HasStackPointer, uint32_t StackPointerGlobal) {
|
||||||
SectionBookkeeping Section;
|
SectionBookkeeping Section;
|
||||||
@ -941,17 +941,16 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
|
|||||||
startSection(SubSection, wasm::WASM_DATA_SIZE);
|
startSection(SubSection, wasm::WASM_DATA_SIZE);
|
||||||
encodeULEB128(DataSize, getStream());
|
encodeULEB128(DataSize, getStream());
|
||||||
endSection(SubSection);
|
endSection(SubSection);
|
||||||
|
|
||||||
startSection(SubSection, wasm::WASM_DATA_ALIGNMENT);
|
|
||||||
encodeULEB128(DataAlignment, getStream());
|
|
||||||
endSection(SubSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Segments.size()) {
|
if (Segments.size()) {
|
||||||
startSection(SubSection, wasm::WASM_SEGMENT_NAMES);
|
startSection(SubSection, wasm::WASM_SEGMENT_INFO);
|
||||||
encodeULEB128(Segments.size(), getStream());
|
encodeULEB128(Segments.size(), getStream());
|
||||||
for (const WasmDataSegment &Segment : Segments)
|
for (const WasmDataSegment &Segment : Segments) {
|
||||||
writeString(Segment.Name);
|
writeString(Segment.Name);
|
||||||
|
encodeULEB128(Segment.Alignment, getStream());
|
||||||
|
encodeULEB128(Segment.Flags, getStream());
|
||||||
|
}
|
||||||
endSection(SubSection);
|
endSection(SubSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,7 +997,6 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
|
|||||||
SmallPtrSet<const MCSymbolWasm *, 4> IsAddressTaken;
|
SmallPtrSet<const MCSymbolWasm *, 4> IsAddressTaken;
|
||||||
unsigned NumFuncImports = 0;
|
unsigned NumFuncImports = 0;
|
||||||
SmallVector<WasmDataSegment, 4> DataSegments;
|
SmallVector<WasmDataSegment, 4> DataSegments;
|
||||||
uint32_t DataAlignment = 1;
|
|
||||||
uint32_t StackPointerGlobal = 0;
|
uint32_t StackPointerGlobal = 0;
|
||||||
uint32_t DataSize = 0;
|
uint32_t DataSize = 0;
|
||||||
bool HasStackPointer = false;
|
bool HasStackPointer = false;
|
||||||
@ -1144,7 +1142,9 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
|
|||||||
Segment.Name = Section.getSectionName();
|
Segment.Name = Section.getSectionName();
|
||||||
Segment.Offset = DataSize;
|
Segment.Offset = DataSize;
|
||||||
Segment.Section = &Section;
|
Segment.Section = &Section;
|
||||||
addData(Segment.Data, Section, DataAlignment);
|
addData(Segment.Data, Section);
|
||||||
|
Segment.Alignment = Section.getAlignment();
|
||||||
|
Segment.Flags = 0;
|
||||||
DataSize += Segment.Data.size();
|
DataSize += Segment.Data.size();
|
||||||
Section.setMemoryOffset(Segment.Offset);
|
Section.setMemoryOffset(Segment.Offset);
|
||||||
}
|
}
|
||||||
@ -1308,8 +1308,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
|
|||||||
writeNameSection(Functions, Imports, NumFuncImports);
|
writeNameSection(Functions, Imports, NumFuncImports);
|
||||||
writeCodeRelocSection();
|
writeCodeRelocSection();
|
||||||
writeDataRelocSection();
|
writeDataRelocSection();
|
||||||
writeLinkingMetaDataSection(DataSegments, DataSize, DataAlignment,
|
writeLinkingMetaDataSection(DataSegments, DataSize, SymbolFlags,
|
||||||
SymbolFlags, HasStackPointer, StackPointerGlobal);
|
HasStackPointer, StackPointerGlobal);
|
||||||
|
|
||||||
// TODO: Translate the .comment section to the output.
|
// TODO: Translate the .comment section to the output.
|
||||||
// TODO: Translate debug sections to the output.
|
// TODO: Translate debug sections to the output.
|
||||||
|
@ -193,7 +193,6 @@ static Error readSection(WasmSection &Section, const uint8_t *&Ptr,
|
|||||||
|
|
||||||
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
|
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
|
||||||
: ObjectFile(Binary::ID_Wasm, Buffer) {
|
: ObjectFile(Binary::ID_Wasm, Buffer) {
|
||||||
LinkingData.DataAlignment = 0;
|
|
||||||
LinkingData.DataSize = 0;
|
LinkingData.DataSize = 0;
|
||||||
|
|
||||||
ErrorAsOutParameter ErrAsOutParam(&Err);
|
ErrorAsOutParameter ErrAsOutParam(&Err);
|
||||||
@ -385,16 +384,16 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
|
|||||||
case wasm::WASM_DATA_SIZE:
|
case wasm::WASM_DATA_SIZE:
|
||||||
LinkingData.DataSize = readVaruint32(Ptr);
|
LinkingData.DataSize = readVaruint32(Ptr);
|
||||||
break;
|
break;
|
||||||
case wasm::WASM_DATA_ALIGNMENT:
|
case wasm::WASM_SEGMENT_INFO: {
|
||||||
LinkingData.DataAlignment = readVaruint32(Ptr);
|
|
||||||
break;
|
|
||||||
case wasm::WASM_SEGMENT_NAMES: {
|
|
||||||
uint32_t Count = readVaruint32(Ptr);
|
uint32_t Count = readVaruint32(Ptr);
|
||||||
if (Count > DataSegments.size())
|
if (Count > DataSegments.size())
|
||||||
return make_error<GenericBinaryError>("Too many segment names",
|
return make_error<GenericBinaryError>("Too many segment names",
|
||||||
object_error::parse_failed);
|
object_error::parse_failed);
|
||||||
for (uint32_t i = 0; i < Count; i++)
|
for (uint32_t i = 0; i < Count; i++) {
|
||||||
DataSegments[i].Data.Name = readString(Ptr);
|
DataSegments[i].Data.Name = readString(Ptr);
|
||||||
|
DataSegments[i].Data.Alignment = readVaruint32(Ptr);
|
||||||
|
DataSegments[i].Data.Flags = readVaruint32(Ptr);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wasm::WASM_STACK_POINTER:
|
case wasm::WASM_STACK_POINTER:
|
||||||
@ -734,6 +733,8 @@ Error WasmObjectFile::parseDataSection(const uint8_t *Ptr, const uint8_t *End) {
|
|||||||
return Err;
|
return Err;
|
||||||
uint32_t Size = readVaruint32(Ptr);
|
uint32_t Size = readVaruint32(Ptr);
|
||||||
Segment.Data.Content = ArrayRef<uint8_t>(Ptr, Size);
|
Segment.Data.Content = ArrayRef<uint8_t>(Ptr, Size);
|
||||||
|
Segment.Data.Alignment = 0;
|
||||||
|
Segment.Data.Flags = 0;
|
||||||
Segment.SectionOffset = Ptr - Start;
|
Segment.SectionOffset = Ptr - Start;
|
||||||
Ptr += Size;
|
Ptr += Size;
|
||||||
DataSegments.push_back(Segment);
|
DataSegments.push_back(Segment);
|
||||||
|
@ -58,9 +58,8 @@ static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
|
|||||||
commonSectionMapping(IO, Section);
|
commonSectionMapping(IO, Section);
|
||||||
IO.mapRequired("Name", Section.Name);
|
IO.mapRequired("Name", Section.Name);
|
||||||
IO.mapRequired("DataSize", Section.DataSize);
|
IO.mapRequired("DataSize", Section.DataSize);
|
||||||
IO.mapRequired("DataAlignment", Section.DataAlignment);
|
|
||||||
IO.mapOptional("SymbolInfo", Section.SymbolInfos);
|
IO.mapOptional("SymbolInfo", Section.SymbolInfos);
|
||||||
IO.mapOptional("SegmentNames", Section.SegmentNames);
|
IO.mapOptional("SegmentInfo", Section.SegmentInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
|
static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
|
||||||
@ -266,6 +265,14 @@ void MappingTraits<WasmYAML::NameEntry>::mapping(
|
|||||||
IO.mapRequired("Name", NameEntry.Name);
|
IO.mapRequired("Name", NameEntry.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MappingTraits<WasmYAML::SegmentInfo>::mapping(
|
||||||
|
IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
|
||||||
|
IO.mapRequired("Index", SegmentInfo.Index);
|
||||||
|
IO.mapRequired("Name", SegmentInfo.Name);
|
||||||
|
IO.mapRequired("Alignment", SegmentInfo.Alignment);
|
||||||
|
IO.mapRequired("Flags", SegmentInfo.Flags);
|
||||||
|
}
|
||||||
|
|
||||||
void MappingTraits<WasmYAML::LocalDecl>::mapping(
|
void MappingTraits<WasmYAML::LocalDecl>::mapping(
|
||||||
IO &IO, WasmYAML::LocalDecl &LocalDecl) {
|
IO &IO, WasmYAML::LocalDecl &LocalDecl) {
|
||||||
IO.mapRequired("Type", LocalDecl.Type);
|
IO.mapRequired("Type", LocalDecl.Type);
|
||||||
|
@ -15,8 +15,9 @@ target triple = "wasm32-unknown-unknown-wasm"
|
|||||||
; CHECK: - Type: CUSTOM
|
; CHECK: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 2
|
; CHECK-NEXT: DataSize: 2
|
||||||
; CHECK-NEXT: DataAlignment: 1
|
; CHECK-NEXT: SegmentInfo:
|
||||||
; CHECK-NEXT: SegmentNames:
|
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: .data
|
; CHECK-NEXT: Name: .data
|
||||||
|
; CHECK-NEXT: Alignment: 1
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: ...
|
; CHECK-NEXT: ...
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
; CHECK-NEXT: - Type: CUSTOM
|
; CHECK-NEXT: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 4
|
; CHECK-NEXT: DataSize: 4
|
||||||
; CHECK-NEXT: DataAlignment: 4
|
; CHECK-NEXT: SegmentInfo:
|
||||||
; CHECK-NEXT: SegmentNames:
|
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: .bss.g0
|
; CHECK-NEXT: Name: .bss.g0
|
||||||
|
; CHECK-NEXT: Alignment: 4
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: ...
|
; CHECK-NEXT: ...
|
||||||
|
@ -67,12 +67,17 @@
|
|||||||
; CHECK: - Type: CUSTOM
|
; CHECK: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 28
|
; CHECK-NEXT: DataSize: 28
|
||||||
; CHECK-NEXT: DataAlignment: 8
|
; CHECK-NEXT: SegmentInfo:
|
||||||
; CHECK-NEXT: SegmentNames:
|
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: .data.global0
|
; CHECK-NEXT: Name: .data.global0
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 1
|
; CHECK-NEXT: - Index: 1
|
||||||
; CHECK-NEXT: Name: .sec1
|
; CHECK-NEXT: Name: .sec1
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 2
|
; CHECK-NEXT: - Index: 2
|
||||||
; CHECK-NEXT: Name: .sec2
|
; CHECK-NEXT: Name: .sec2
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: ...
|
; CHECK-NEXT: ...
|
||||||
|
@ -79,19 +79,26 @@
|
|||||||
; CHECK-NEXT: - Type: CUSTOM
|
; CHECK-NEXT: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 28
|
; CHECK-NEXT: DataSize: 28
|
||||||
; CHECK-NEXT: DataAlignment: 8
|
|
||||||
; CHECK-NEXT: SymbolInfo:
|
; CHECK-NEXT: SymbolInfo:
|
||||||
; CHECK-NEXT: - Name: .L.str1
|
; CHECK-NEXT: - Name: .L.str1
|
||||||
; CHECK-NEXT: Flags: 2
|
; CHECK-NEXT: Flags: 2
|
||||||
; CHECK-NEXT: - Name: .L.str2
|
; CHECK-NEXT: - Name: .L.str2
|
||||||
; CHECK-NEXT: Flags: 2
|
; CHECK-NEXT: Flags: 2
|
||||||
; CHECK-NEXT: SegmentNames:
|
; CHECK-NEXT: SegmentInfo:
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: .rodata..L.str1
|
; CHECK-NEXT: Name: .rodata..L.str1
|
||||||
|
; CHECK-NEXT: Alignment: 1
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 1
|
; CHECK-NEXT: - Index: 1
|
||||||
; CHECK-NEXT: Name: .rodata..L.str2
|
; CHECK-NEXT: Name: .rodata..L.str2
|
||||||
|
; CHECK-NEXT: Alignment: 1
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 2
|
; CHECK-NEXT: - Index: 2
|
||||||
; CHECK-NEXT: Name: .data.a
|
; CHECK-NEXT: Name: .data.a
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 3
|
; CHECK-NEXT: - Index: 3
|
||||||
; CHECK-NEXT: Name: .data.b
|
; CHECK-NEXT: Name: .data.b
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK_NEXT: ...
|
; CHECK_NEXT: ...
|
||||||
|
@ -101,17 +101,20 @@ entry:
|
|||||||
; CHECK-NEXT: - Type: CUSTOM
|
; CHECK-NEXT: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 12
|
; CHECK-NEXT: DataSize: 12
|
||||||
; CHECK-NEXT: DataAlignment: 8
|
|
||||||
; CHECK-NEXT: SymbolInfo:
|
; CHECK-NEXT: SymbolInfo:
|
||||||
; CHECK-NEXT: - Name: foo_alias
|
; CHECK-NEXT: - Name: foo_alias
|
||||||
; CHECK-NEXT: Flags: 1
|
; CHECK-NEXT: Flags: 1
|
||||||
; CHECK-NEXT: - Name: bar_alias
|
; CHECK-NEXT: - Name: bar_alias
|
||||||
; CHECK-NEXT: Flags: 1
|
; CHECK-NEXT: Flags: 1
|
||||||
; CHECK-NEXT: SegmentNames:
|
; CHECK-NEXT: SegmentInfo:
|
||||||
; CHECK-NEXT: - Index: 0
|
; CHECK-NEXT: - Index: 0
|
||||||
; CHECK-NEXT: Name: .data.bar
|
; CHECK-NEXT: Name: .data.bar
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: - Index: 1
|
; CHECK-NEXT: - Index: 1
|
||||||
; CHECK-NEXT: Name: .data.bar_alias_address
|
; CHECK-NEXT: Name: .data.bar_alias_address
|
||||||
|
; CHECK-NEXT: Alignment: 8
|
||||||
|
; CHECK-NEXT: Flags: 0
|
||||||
; CHECK-NEXT: ...
|
; CHECK-NEXT: ...
|
||||||
|
|
||||||
; CHECK-SYMS: SYMBOL TABLE:
|
; CHECK-SYMS: SYMBOL TABLE:
|
||||||
|
@ -27,7 +27,6 @@ entry:
|
|||||||
; CHECK-NEXT: - Type: CUSTOM
|
; CHECK-NEXT: - Type: CUSTOM
|
||||||
; CHECK-NEXT: Name: linking
|
; CHECK-NEXT: Name: linking
|
||||||
; CHECK-NEXT: DataSize: 0
|
; CHECK-NEXT: DataSize: 0
|
||||||
; CHECK-NEXT: DataAlignment: 0
|
|
||||||
; CHECK-NEXT: SymbolInfo:
|
; CHECK-NEXT: SymbolInfo:
|
||||||
; CHECK-NEXT: - Name: weak_external_data
|
; CHECK-NEXT: - Name: weak_external_data
|
||||||
; CHECK-NEXT: Flags: 1
|
; CHECK-NEXT: Flags: 1
|
||||||
|
@ -27,7 +27,6 @@ Sections:
|
|||||||
- Type: CUSTOM
|
- Type: CUSTOM
|
||||||
Name: linking
|
Name: linking
|
||||||
DataSize: 10
|
DataSize: 10
|
||||||
DataAlignment: 2
|
|
||||||
SymbolInfo:
|
SymbolInfo:
|
||||||
- Name: function_export
|
- Name: function_export
|
||||||
Flags: 1
|
Flags: 1
|
||||||
@ -49,7 +48,6 @@ Sections:
|
|||||||
# CHECK: - Type: CUSTOM
|
# CHECK: - Type: CUSTOM
|
||||||
# CHECK: Name: linking
|
# CHECK: Name: linking
|
||||||
# CHECK: DataSize: 10
|
# CHECK: DataSize: 10
|
||||||
# CHECK: DataAlignment: 2
|
|
||||||
# CHECK: SymbolInfo:
|
# CHECK: SymbolInfo:
|
||||||
# CHECK: - Name: function_export
|
# CHECK: - Name: function_export
|
||||||
# CHECK: Flags: 1
|
# CHECK: Flags: 1
|
||||||
|
@ -53,7 +53,6 @@ Sections:
|
|||||||
- Type: CUSTOM
|
- Type: CUSTOM
|
||||||
Name: "linking"
|
Name: "linking"
|
||||||
DataSize: 0
|
DataSize: 0
|
||||||
DataAlignment: 0
|
|
||||||
|
|
||||||
# CHECK: 00000400 D bar
|
# CHECK: 00000400 D bar
|
||||||
# CHECK-NEXT: U fimport
|
# CHECK-NEXT: U fimport
|
||||||
|
@ -23,7 +23,6 @@ Sections:
|
|||||||
- Type: CUSTOM
|
- Type: CUSTOM
|
||||||
Name: "linking"
|
Name: "linking"
|
||||||
DataSize: 0
|
DataSize: 0
|
||||||
DataAlignment: 0
|
|
||||||
|
|
||||||
# CHECK: U bar
|
# CHECK: U bar
|
||||||
# CHECK: U foo
|
# CHECK: U foo
|
||||||
|
@ -53,7 +53,6 @@ Sections:
|
|||||||
- Type: CUSTOM
|
- Type: CUSTOM
|
||||||
Name: linking
|
Name: linking
|
||||||
DataSize: 0
|
DataSize: 0
|
||||||
DataAlignment: 2
|
|
||||||
SymbolInfo:
|
SymbolInfo:
|
||||||
- Name: weak_global_func
|
- Name: weak_global_func
|
||||||
Flags: 1
|
Flags: 1
|
||||||
|
@ -568,6 +568,5 @@ WASM-NEXT: Size: 22
|
|||||||
WASM-NEXT: Offset: 257
|
WASM-NEXT: Offset: 257
|
||||||
WASM-NEXT: Name: linking
|
WASM-NEXT: Name: linking
|
||||||
WASM-NEXT: DataSize: 13
|
WASM-NEXT: DataSize: 13
|
||||||
WASM-NEXT: DataAlignment: 1
|
|
||||||
WASM-NEXT: }
|
WASM-NEXT: }
|
||||||
WASM-NEXT: ]
|
WASM-NEXT: ]
|
||||||
|
@ -156,8 +156,6 @@ void WasmDumper::printSections() {
|
|||||||
if (WasmSec.Name == "linking") {
|
if (WasmSec.Name == "linking") {
|
||||||
const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
|
const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
|
||||||
W.printNumber("DataSize", LinkingData.DataSize);
|
W.printNumber("DataSize", LinkingData.DataSize);
|
||||||
if (LinkingData.DataAlignment)
|
|
||||||
W.printNumber("DataAlignment", LinkingData.DataAlignment);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case wasm::WASM_SEC_DATA: {
|
case wasm::WASM_SEC_DATA: {
|
||||||
|
@ -68,10 +68,12 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
|
|||||||
size_t Index = 0;
|
size_t Index = 0;
|
||||||
for (const object::WasmSegment &Segment : Obj.dataSegments()) {
|
for (const object::WasmSegment &Segment : Obj.dataSegments()) {
|
||||||
if (!Segment.Data.Name.empty()) {
|
if (!Segment.Data.Name.empty()) {
|
||||||
WasmYAML::NameEntry NameEntry;
|
WasmYAML::SegmentInfo SegmentInfo;
|
||||||
NameEntry.Name = Segment.Data.Name;
|
SegmentInfo.Name = Segment.Data.Name;
|
||||||
NameEntry.Index = Index;
|
SegmentInfo.Index = Index;
|
||||||
LinkingSec->SegmentNames.push_back(NameEntry);
|
SegmentInfo.Alignment = Segment.Data.Alignment;
|
||||||
|
SegmentInfo.Flags = Segment.Data.Flags;
|
||||||
|
LinkingSec->SegmentInfos.push_back(SegmentInfo);
|
||||||
}
|
}
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
@ -83,7 +85,6 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LinkingSec->DataSize = Obj.linkingData().DataSize;
|
LinkingSec->DataSize = Obj.linkingData().DataSize;
|
||||||
LinkingSec->DataAlignment = Obj.linkingData().DataAlignment;
|
|
||||||
CustomSec = std::move(LinkingSec);
|
CustomSec = std::move(LinkingSec);
|
||||||
} else {
|
} else {
|
||||||
CustomSec = make_unique<WasmYAML::CustomSection>(WasmSec.Name);
|
CustomSec = make_unique<WasmYAML::CustomSection>(WasmSec.Name);
|
||||||
|
@ -140,11 +140,6 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S
|
|||||||
encodeULEB128(Section.DataSize, SubSection.GetStream());
|
encodeULEB128(Section.DataSize, SubSection.GetStream());
|
||||||
SubSection.Done();
|
SubSection.Done();
|
||||||
|
|
||||||
// DATA_ALIGNMENT subsection
|
|
||||||
encodeULEB128(wasm::WASM_DATA_ALIGNMENT, OS);
|
|
||||||
encodeULEB128(Section.DataAlignment, SubSection.GetStream());
|
|
||||||
SubSection.Done();
|
|
||||||
|
|
||||||
// SYMBOL_INFO subsection
|
// SYMBOL_INFO subsection
|
||||||
if (Section.SymbolInfos.size()) {
|
if (Section.SymbolInfos.size()) {
|
||||||
encodeULEB128(wasm::WASM_SYMBOL_INFO, OS);
|
encodeULEB128(wasm::WASM_SYMBOL_INFO, OS);
|
||||||
@ -159,12 +154,14 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SEGMENT_NAMES subsection
|
// SEGMENT_NAMES subsection
|
||||||
if (Section.SegmentNames.size()) {
|
if (Section.SegmentInfos.size()) {
|
||||||
encodeULEB128(wasm::WASM_SEGMENT_NAMES, OS);
|
encodeULEB128(wasm::WASM_SEGMENT_INFO, OS);
|
||||||
encodeULEB128(Section.SegmentNames.size(), SubSection.GetStream());
|
encodeULEB128(Section.SegmentInfos.size(), SubSection.GetStream());
|
||||||
for (const WasmYAML::NameEntry &NameEntry : Section.SegmentNames) {
|
for (const WasmYAML::SegmentInfo &SegmentInfo : Section.SegmentInfos) {
|
||||||
encodeULEB128(NameEntry.Index, SubSection.GetStream());
|
encodeULEB128(SegmentInfo.Index, SubSection.GetStream());
|
||||||
writeStringRef(NameEntry.Name, SubSection.GetStream());
|
writeStringRef(SegmentInfo.Name, SubSection.GetStream());
|
||||||
|
encodeULEB128(SegmentInfo.Alignment, SubSection.GetStream());
|
||||||
|
encodeULEB128(SegmentInfo.Flags, SubSection.GetStream());
|
||||||
}
|
}
|
||||||
SubSection.Done();
|
SubSection.Done();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user