Skip to content

Constants can't depend on globals #2622

@glguy

Description

@glguy

Constants need to be able to assume that globals are allocated.

I believe that we either need to stop assuming that constants can always be allocated or start assuming that globals are always allocated.

This statement is filtering out non-constant globals just before it tries to initialize all constants.

mem <- Crucible.populateConstGlobals bak (view Crucible.globalInitMap mtrans)
=<< Crucible.initializeMemoryConstGlobals bak ctx llvm_mod

Here's an example.

example.c

char gstuff[] = "stuff";
char* const p = &gstuff[2];
void noop() {}
clang -c example.c -emit-llvm

example.saw

m <- llvm_load_module "example.bc";
llvm_verify m "noop" [] false (llvm_execute_func []) rme;
AssertionFailure :1:0: error: in _start
Global symbol not allocated
Details:
  Global symbol "gstuff" has no associated allocation

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs designTechnical design work is needed for issue to progressneeds testIssues for which we should add a regression testsubsystem: crucible-llvmIssues related to LLVM bitcode verification with crucible-llvmsubsystem: crucible-mirIssues related to Rust verification with crucible-mir and/or mir-jsontech debtIssues that document or involve technical debttopics: memory modelIssues that relate to the LLVM and/or Crucible model of pointers and memory blockstype: bugIssues reporting bugs or unexpected/unwanted behaviorunsoundnessIssues that can lead to unsoundness or false verification

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions