[PATCH] D74531: [WebAssembly] Emit PCH __clang_ast in custom section

Patrick Cheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 16 19:05:16 PDT 2020


patcheng added inline comments.


================
Comment at: llvm/lib/MC/WasmObjectWriter.cpp:383
+    uint64_t RoundedUpLength = (MinLength + 3ULL) & ~3ULL;
+    encodeULEB128(Name.size(), W.OS, 5 + (RoundedUpLength - MinLength));
+    W.OS << Name;
----------------
sbc100 wrote:
> kateinoigakukun wrote:
> > sbc100 wrote:
> > > I general this seems like trick that could work.   However, I think this value is encoded as an LEB32 which means its max length is technically 5.  I don't think a 6 byte LEB is valid .
> > Thanks. I see, I confirmed that you are right https://webassembly.github.io/spec/core/binary/values.html#integers
> > 
> > Then how should I pad section start? Should I pad with empty data segment or something else?
> I think the problem is that the wasm file itself doesn't have the concept of alignment of sections, since its not designed to memory mapped in that way.    Its designed to be parsed.    Is the loading code expecting the file offset of the section to be aligned?  I'm not sure how we can work around this.
BTW, here was an implementation I did way back: https://reviews.llvm.org/D42233

If I remember correct, you could spread the extra padding across multiple integer fields.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74531





More information about the llvm-commits mailing list