Commit 28fc2d7d by Karl Schimpf

Require that the module symbol table can't appear after function.

The bitcode parser assumes that the module symbol table, if it exists, must appear before the first function block (i.e. defininition). However, the parser did not check this constraint. This patch fixes that omission. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4320 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1359923002 .
parent 0b8763ea
......@@ -3158,6 +3158,12 @@ bool ModuleParser::ParseBlock(unsigned BlockID) {
if (FoundValuesymtab)
Fatal("Duplicate valuesymtab in module");
// If we have already processed a function block (i.e. we have already
// installed global names and variable initializers) we can no longer accept
// the value symbol table. Names have already been generated.
if (GlobalDeclarationNamesAndInitializersInstalled)
Fatal("Module valuesymtab not allowed after function blocks");
FoundValuesymtab = true;
ModuleValuesymtabParser Parser(BlockID, this);
return Parser.ParseThisBlock();
......
65535,8,2;
1,1;
65535,17,2;
1,2;
2;
21,0,0;
65534;
8,1,0,0,0;
65535,19,2;
5,0;
65534;
65535,12,2;
1,1;
10;
65534;
65535,14,2;
1,0,102;
65534;
65534;
; Test if we detect if the value symbol table appears after a function block.
; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/symtab-after-fcn.tbc \
; RUN: -bitcode-format=pnacl -notranslate -build-on-read 2>&1 \
; RUN: | FileCheck %s
; CHECK: Module valuesymtab not allowed after function blocks
; RUN: pnacl-bcfuzz -bitcode-as-text %p/Inputs/symtab-after-fcn.tbc \
; RUN: -output - | pnacl-bcdis -no-records | FileCheck -check-prefix=ASM %s
; ASM: module { // BlockID = 8
; ASM: function void @f0() { // BlockID = 12
; ASM: }
; ASM: valuesymtab { // BlockID = 14
; ASM: }
; ASM: }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment