Commit c49eeae4 by Karl Schimpf

Don't allow multiple symbol tables in the module block.

Fix handling of module value symbol tables. Also deals with case where the module doesn't have a global variables block. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4320 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1345293002 .
parent 00741a00
......@@ -3010,6 +3010,8 @@ private:
// True if we have already installed names for unnamed global declarations,
// and have generated global constant initializers.
bool GlobalDeclarationNamesAndInitializersInstalled = false;
// True if we have already processed the symbol table for the module.
bool FoundValuesymtab = false;
// Generates names for unnamed global addresses (i.e. functions and global
// variables). Then lowers global variable declaration initializers to the
......@@ -3019,7 +3021,10 @@ private:
if (!GlobalDeclarationNamesAndInitializersInstalled) {
Context->installGlobalNames();
Context->createValueIDs();
getTranslator().lowerGlobals(Context->getGlobalVariables());
std::unique_ptr<Ice::VariableDeclarationList> Globals =
Context->getGlobalVariables();
if (Globals)
getTranslator().lowerGlobals(std::move(Globals));
GlobalDeclarationNamesAndInitializersInstalled = true;
}
}
......@@ -3074,6 +3079,10 @@ bool ModuleParser::ParseBlock(unsigned BlockID) {
return Parser.ParseThisBlock();
}
case naclbitc::VALUE_SYMTAB_BLOCK_ID: {
if (FoundValuesymtab)
Fatal("Duplicate valuesymtab in module");
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,14,2;
1,0,102;
65534;
65535,14,2;
1,0,102;
65534;
65535,12,2;
1,1;
10;
65534;
65534;
; Test if we detect multiple module-level symbol tables in bitcode.
; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/dup-module-vst.tbc \
; RUN: -bitcode-format=pnacl -notranslate -build-on-read 2>&1 \
; RUN: | FileCheck %s
; CHECK: Duplicate valuesymtab in module
; RUN: pnacl-bcfuzz -bitcode-as-text %p/Inputs/dup-module-vst.tbc \
; RUN: -output - | pnacl-bcdis -no-records | FileCheck -check-prefix=ASM %s
; ASM: module { // BlockID = 8
; ASM: valuesymtab { // BlockID = 14
; ASM: @f0 : "f";
; ASM: }
; ASM: valuesymtab { // BlockID = 14
; ASM: @f0 : "f";
; 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