[Lldb-commits] [PATCH] D127164: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]

Derek Schuff via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 7 11:57:54 PDT 2022


dschuff added inline comments.


================
Comment at: llvm/lib/ObjCopy/wasm/WasmReader.cpp:32-35
-    // If the section type is CUSTOM, it has a name already. If it's a new type
-    // of section that we don't explicitly handle here, it will have an empty
-    // name and objcopy won't be able to select it by name (e.g. for removal
-    // or dumping) but it will still be valid and able to be copied.
----------------
aheejin wrote:
> dschuff wrote:
> > aheejin wrote:
> > > dschuff wrote:
> > > > aheejin wrote:
> > > > > Why was this removed? It doesn't look like it's related to the last section thing.. It's just explaning custom sections have names already.
> > > > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a new type of section that we don't explicitly handle here (because no types of known sections are explicitly handled or mentioned); any section known to `sectionTypeToString` will work.
> > > I'm not sure if I understand. Is this related to `WASM_SEC_TAG` -> `WASM_LAST_SEC_KNOWN` change in this PR? Or it's just an unrelated drive-by fix?
> > > 
> > > > Checking against `WASM_SEC_LAST_KNOWN` ensures that there can't be a new type of section that we don't explicitly handle here (because no types of known sections are explicitly handled or mentioned);
> > > 
> > > I'm not sure what this means..
> > > 
> > > > If the section type is CUSTOM, it has a name already.
> > > 
> > > Why is this deleted too? How is the custom section related to `WASM_SEC_LAST_KNOWN`?
> > It is indirectly related.
> > The purpose of this block of code is to fill in the `Name` field of the `WasmSection` object for known sections (as the comment on line 27 explains). Suppose we add a new type of known section, WASM_SEC_NEW, and we update `sectionTypeToString` but forget to update this file.  Before this CL, the behavior would be as described in the comment I'm deleting; this code would silently fail to give that section a name, which would mean it couldn't be selected by llvm-objdump. After this CL, everything would work, without needing any updates to this file (and if we forgot to update `sectionTypeToString` it would assert when encountering an unknown section type). So this comment was just to describe the somewhat surprising failure mode, and isn't necessary anymore.
> I see.  My original question was why
> > If the section type is CUSTOM, it has a name already. 
> is related to this CL, but I see you moved that comment to elsewhere, so it hasn't really changed..
Ah yeah that bit of explanation is still valuable. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127164/new/

https://reviews.llvm.org/D127164



More information about the lldb-commits mailing list