[Objcopy][Wasm] Allow selecting known sections by name
authorDerek Schuff <dschuff@chromium.org>
Mon, 6 Jun 2022 20:40:43 +0000 (13:40 -0700)
committerDerek Schuff <dschuff@chromium.org>
Mon, 6 Jun 2022 20:54:01 +0000 (13:54 -0700)
commitc9dd1cc6f0536c6547f322107cd27cd953913f5c
treed4deea5571ba00abe73c3f515de1766dcfef2af6
parent3204272f0f1ac64a62357620210d565de17739d7
[Objcopy][Wasm] Allow selecting known sections by name

Currently, only custom sections can be selected by operations that use section
names, because only custom sections have explicit names (whereas known sections
have names defined by the spec and only use their indices in the binary format).
This CL makes objdopy use the spec-defined names for these sections, allowing
them to be used in operations such as dumping and removal.

This is a prerequisite for fixing
https://github.com/emscripten-core/emscripten/issues/13084

Differential Revision: https://reviews.llvm.org/D126509
llvm/lib/ObjCopy/wasm/WasmReader.cpp
llvm/test/tools/llvm-objcopy/wasm/dump-section.test
llvm/test/tools/llvm-objcopy/wasm/only-keep-debug.test
llvm/test/tools/llvm-objcopy/wasm/remove-section.test