aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-04-14 21:41:27 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-06-22 18:20:56 +0000
commitbdd1243df58e60e85101c09001d9812a789b6bc4 (patch)
treea1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp
parent781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff)
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp b/contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp
index 7cc11d24f286..a4cb4149f036 100644
--- a/contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/contrib/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp
@@ -72,7 +72,7 @@ struct WasmDataSegment {
// A wasm function to be written into the function section.
struct WasmFunction {
uint32_t SigIndex;
- const MCSymbolWasm *Sym;
+ MCSection *Section;
};
// A wasm global to be written into the global section.
@@ -716,7 +716,7 @@ static void addData(SmallVectorImpl<char> &DataBytes,
MCSectionWasm &DataSection) {
LLVM_DEBUG(errs() << "addData: " << DataSection.getName() << "\n");
- DataBytes.resize(alignTo(DataBytes.size(), DataSection.getAlignment()));
+ DataBytes.resize(alignTo(DataBytes.size(), DataSection.getAlign()));
for (const MCFragment &Frag : DataSection) {
if (Frag.hasInstructions())
@@ -1058,15 +1058,12 @@ uint32_t WasmObjectWriter::writeCodeSection(const MCAssembler &Asm,
encodeULEB128(Functions.size(), W->OS);
for (const WasmFunction &Func : Functions) {
- auto &FuncSection = static_cast<MCSectionWasm &>(Func.Sym->getSection());
-
- int64_t Size = 0;
- if (!Func.Sym->getSize()->evaluateAsAbsolute(Size, Layout))
- report_fatal_error(".size expression must be evaluatable");
+ auto *FuncSection = static_cast<MCSectionWasm *>(Func.Section);
+ int64_t Size = Layout.getSectionAddressSize(FuncSection);
encodeULEB128(Size, W->OS);
- FuncSection.setSectionOffset(W->OS.tell() - Section.ContentsOffset);
- Asm.writeSectionData(W->OS, &FuncSection, Layout);
+ FuncSection->setSectionOffset(W->OS.tell() - Section.ContentsOffset);
+ Asm.writeSectionData(W->OS, FuncSection, Layout);
}
// Apply fixups.
@@ -1501,7 +1498,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
if (Section.isWasmData()) {
uint32_t SegmentIndex = DataSegments.size();
- DataSize = alignTo(DataSize, Section.getAlignment());
+ DataSize = alignTo(DataSize, Section.getAlign());
DataSegments.emplace_back();
WasmDataSegment &Segment = DataSegments.back();
Segment.Name = SectionName;
@@ -1511,7 +1508,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
Segment.Offset = DataSize;
Segment.Section = &Section;
addData(Segment.Data, Section);
- Segment.Alignment = Log2_32(Section.getAlignment());
+ Segment.Alignment = Log2(Section.getAlign());
Segment.LinkingFlags = Section.getSegmentFlags();
DataSize += Segment.Data.size();
Section.setSegmentIndex(SegmentIndex);
@@ -1591,15 +1588,11 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
report_fatal_error(
"function sections must contain one function each");
- if (WS.getSize() == nullptr)
- report_fatal_error(
- "function symbols must have a size set with .size");
-
// A definition. Write out the function body.
Index = NumFunctionImports + Functions.size();
WasmFunction Func;
Func.SigIndex = getFunctionType(WS);
- Func.Sym = &WS;
+ Func.Section = &WS.getSection();
assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = Index;
Functions.push_back(Func);