[PATCH] D95163: [WebAssembly] Test that invalid symbol/relocation types generate errors
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 28 20:53:10 PST 2021
MaskRay added a comment.
In D95163#2515437 <https://reviews.llvm.org/D95163#2515437>, @sbc100 wrote:
> In D95163#2514514 <https://reviews.llvm.org/D95163#2514514>, @MaskRay wrote:
>
>> In ELF, we usually use yaml2obj to generate invalid object files, instead of checking in precanned binaries. You can find lots of grimar's changes migrating away from binaries.
>
> I generally prefer that method too, however I didn't think it was possible for this kind of case. How would I generate an invalid relocation type? Currently relocations are specified with a string:
>
> For example here is the yaml I used as a starting point for this invalid binary:
>
> --- !WASM
> FileHeader:
> Version: 0x1
> Sections:
> - Type: TYPE
> Signatures:
> - Index: 0
> ParamTypes: []
> ReturnTypes:
> - I32
> - Type: FUNCTION
> FunctionTypes: [ 0 ]
> - Type: CODE
> Relocations:
> - Type: R_WASM_TABLE_INDEX_SLEB
> Index: 0
> Offset: 0x4
> Functions:
> - Index: 0
> Locals: []
> Body: 4181808080000B
> - Type: CUSTOM
> Name: linking
> Version: 2
> SymbolTable:
> - Index: 0
> Kind: FUNCTION
> Name: foo
> Flags: [ VISIBILITY_HIDDEN ]
> Function: 0
>
> In this case I modified the binary to change the `R_WASM_TABLE_INDEX_SLEB` value to 63 (an invalid value). If I try to do that in the yaml I get:
>
> yaml2obj out.yaml > obj.o
> YAML:15:26: error: unknown enumerated scalar
> - Type: 63
> ^~
> yaml2obj: error: failed to parse YAML input: Invalid argument
>
> Also, I see a lot of ELF files (and very few yaml files) checked in directly to `llvm/test/Object/Inputs/`. Is that just because there is ongoing work to covert them?
Maybe D95661 <https://reviews.llvm.org/D95661>:)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95163/new/
https://reviews.llvm.org/D95163
More information about the llvm-commits
mailing list