Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/include/llvm/BinaryFormat/Wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ enum : unsigned {
WASM_DYLINK_NEEDED = 0x2,
WASM_DYLINK_EXPORT_INFO = 0x3,
WASM_DYLINK_IMPORT_INFO = 0x4,
WASM_DYLINK_RUNTIME_PATH = 0x5,
};

// Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO
Expand Down Expand Up @@ -294,6 +295,7 @@ struct WasmDylinkInfo {
std::vector<StringRef> Needed; // Shared library dependencies
std::vector<WasmDylinkImportInfo> ImportInfo;
std::vector<WasmDylinkExportInfo> ExportInfo;
StringRef RuntimePath;
};

struct WasmProducerInfo {
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/ObjectYAML/WasmYAML.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ struct DylinkSection : CustomSection {
std::vector<StringRef> Needed;
std::vector<DylinkImportInfo> ImportInfo;
std::vector<DylinkExportInfo> ExportInfo;
StringRef RuntimePath;
};

struct NameSection : CustomSection {
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Object/WasmObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ Error WasmObjectFile::parseDylink0Section(ReadContext &Ctx) {
}
break;
}
case wasm::WASM_DYLINK_RUNTIME_PATH: {
DylinkInfo.RuntimePath = readString(Ctx);
break;
}
default:
LLVM_DEBUG(dbgs() << "unknown dylink.0 sub-section: " << Type << "\n");
Ctx.Ptr += Size;
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/ObjectYAML/WasmEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
writeStringRef(Needed, SubOS);
SubSection.done();
}
if (Section.RuntimePath.size()) {
writeUint8(OS, wasm::WASM_DYLINK_RUNTIME_PATH);
raw_ostream &SubOS = SubSection.getStream();
writeStringRef(Section.RuntimePath, SubOS);
SubSection.done();
}
}

void WasmWriter::writeSectionContent(raw_ostream &OS,
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjectYAML/WasmYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static void sectionMapping(IO &IO, WasmYAML::DylinkSection &Section) {
IO.mapRequired("Needed", Section.Needed);
IO.mapOptional("ImportInfo", Section.ImportInfo);
IO.mapOptional("ExportInfo", Section.ExportInfo);
IO.mapOptional("RuntimePath", Section.RuntimePath);
}

static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/ObjectYAML/wasm/dylink_section.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Sections:
TableSize: 1
TableAlignment: 0
Needed: [ libfoo.so, libbar.so ]
RuntimePath: $ORIGIN/../lib:$ORIGIN/../../.libs
...
# CHECK: --- !WASM
# CHECK: FileHeader:
Expand All @@ -25,4 +26,5 @@ Sections:
# CHECK: Needed:
# CHECK: - libfoo.so
# CHECK: - libbar.so
# CHECK: RuntimePath: '$ORIGIN/../lib:$ORIGIN/../../.libs'
# CHECK: ...
1 change: 1 addition & 0 deletions llvm/tools/obj2yaml/wasm2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
DylinkSec->TableSize = Info.TableSize;
DylinkSec->TableAlignment = Info.TableAlignment;
DylinkSec->Needed = Info.Needed;
DylinkSec->RuntimePath = Info.RuntimePath;
for (const auto &Imp : Info.ImportInfo)
DylinkSec->ImportInfo.push_back({Imp.Module, Imp.Field, Imp.Flags});
for (const auto &Exp : Info.ExportInfo)
Expand Down