summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml/wasm2yaml.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-09-19 23:00:57 +0000
committerSam Clegg <sbc@chromium.org>2017-09-19 23:00:57 +0000
commitb292c259665df700442f47f430d0e4b4edd818cb (patch)
tree9f1cdf736c1460806311eca8b11e7bd436192b4a /llvm/tools/obj2yaml/wasm2yaml.cpp
parent15fccf00097dd5b07710539fb4e3ff68c50f44de (diff)
downloadbcm5719-llvm-b292c259665df700442f47f430d0e4b4edd818cb.tar.gz
bcm5719-llvm-b292c259665df700442f47f430d0e4b4edd818cb.zip
[WebAssembly] Add support for naming wasm data segments
Add adds support for naming data segments. This is useful useful linkers so that they can merge similar sections. Differential Revision: https://reviews.llvm.org/D37886 llvm-svn: 313692
Diffstat (limited to 'llvm/tools/obj2yaml/wasm2yaml.cpp')
-rw-r--r--llvm/tools/obj2yaml/wasm2yaml.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index a1da4b6a748..8b2a0adf73f 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -70,6 +70,16 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
CustomSec = std::move(NameSec);
} else if (WasmSec.Name == "linking") {
std::unique_ptr<WasmYAML::LinkingSection> LinkingSec = make_unique<WasmYAML::LinkingSection>();
+ size_t Index = 0;
+ for (const object::WasmSegment &Segment : Obj.dataSegments()) {
+ if (!Segment.Data.Name.empty()) {
+ WasmYAML::NameEntry NameEntry;
+ NameEntry.Name = Segment.Data.Name;
+ NameEntry.Index = Index;
+ LinkingSec->SegmentNames.push_back(NameEntry);
+ }
+ Index++;
+ }
for (const object::SymbolRef& Sym: Obj.symbols()) {
const object::WasmSymbol Symbol = Obj.getWasmSymbol(Sym);
if (Symbol.Flags != 0) {
@@ -234,7 +244,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
}
case wasm::WASM_SEC_DATA: {
auto DataSec = make_unique<WasmYAML::DataSection>();
- for (auto &Segment : Obj.dataSegments()) {
+ for (const object::WasmSegment &Segment : Obj.dataSegments()) {
WasmYAML::DataSegment Seg;
Seg.SectionOffset = Segment.SectionOffset;
Seg.MemoryIndex = Segment.Data.MemoryIndex;
OpenPOWER on IntegriCloud