Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change handling of global variables #97

Merged
merged 4 commits into from
Oct 4, 2018

Conversation

langston-barrett
Copy link
Contributor

@langston-barrett langston-barrett commented Sep 27, 2018

Note: This is highly backwards-incompatible. SAW scripts that used to run will no longer with this change! Should we make a release note, or something similar? I've bumped the version so that library clients can select which behavior they need.

Instead of providing a CFG that initializes all global variables, the result of translating a module now contains a map from symbols (the name of the global) to their initializers (represented as a constant LLVM value).

Clients to this API (e.g. saw-script) can now initialize globals at will by turning them into LLVM expressions.

Enables progress on GaloisInc/saw-script#203.

Instead of providing a CFG that initializes all global variables,
the result of translating a module now contains a map from
symbols (the name of the global) to their initializers (represented
as a constant LLVM value).

Clients to this API (e.g. saw-script) can now initialize globals at
will by turning them into LLVM expressions.
@langston-barrett
Copy link
Contributor Author

This isn't quite ready to merge, I want to find a better home for the constToLLVMVal function. Please make suggestions!

, _transContext :: LLVMContext arch
, globalMap :: GlobalInitializerMap
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to globalInitMap, it conflicts with Lang.Crucible.Simulator.SymGlobalState.globalMap.

--
-- To actually initialize globals, saw-script translates them into
-- instances of @MemModel.LLVMVal@.
type GlobalInitializerMap = Map L.Symbol (Either String LLVMConst)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This map should probably contain more information than it does (optimally, anything someone down the road would want to know about a given global). The least "lossy" way of doing this is probably

type GlobalInitializerMap = Map L.Global (Either String LLVMConst)

It now retains the entire L.Global.

Additionally, fix a bug in zeroExpand'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants