{"action":"created","comment":{"url":"https://api.github.com/repos/trailofbits/mcsema/pulls/comments/178852438","pull_request_review_id":108977546,"id":178852438,"diff_hunk":"@@ -260,6 +303,123 @@ static llvm::BasicBlock *GetOrCreateBlock(TranslationContext &ctx,\n   return block;\n }\n \n+static void LiftExceptionFrameLP(TranslationContext &ctx,\n+                                 const NativeFunction *cfg_func) {\n+\n+  if (cfg_func->eh_frame.size() > 0) {\n+\n+    // The personality function `__gxx_personality_v0` is lifted as global variable. Erase the\n+    // variable before declaring it as the function.\n+    if (auto personality_func_var = gModule->getGlobalVariable(PERSONALITY_FUNCTION)) {\n+      personality_func_var->eraseFromParent();\n+    }\n+\n+    auto personality = gModule->getFunction(PERSONALITY_FUNCTION);\n+\n+    if (personality == nullptr) {\n+      personality = llvm::Function::Create(\n+          llvm::FunctionType::get(llvm::Type::getInt32Ty(*gContext), true),\n+          llvm::Function::ExternalLinkage, PERSONALITY_FUNCTION, gModule);\n+    }\n+\n+    auto lifted_func = gModule->getFunction(cfg_func->lifted_name);\n+    lifted_func->addFnAttr(llvm::Attribute::UWTable);\n+    lifted_func->addFnAttr(llvm::Attribute::OptimizeNone);\n+    lifted_func->removeFnAttr(llvm::Attribute::NoUnwind);\n+#if LLVM_VERSION_NUMBER > LLVM_VERSION(3, 6)\n+    lifted_func->setPersonalityFn(personality);\n+#endif\n+  }\n+\n+  for (auto &entry : cfg_func->eh_frame) {\n+    if (!entry->lp_ea) {\n+      continue;\n+    }\n+\n+    if (!entry->action_index) {\n+      std::stringstream ss;\n+      ss << \"cleanup_landingpad_\" << std::hex << entry->lp_ea;\n+      auto landing_bb = llvm::BasicBlock::Create(*gContext, ss.str(), ctx.lifted_func);\n+      llvm::IRBuilder<> ir(landing_bb);\n+      auto exn_type = llvm::StructType::get(llvm::Type::getInt8PtrTy(*gContext),\n+                                            llvm::Type::getInt32Ty(*gContext), nullptr);\n+#if LLVM_VERSION_NUMBER > LLVM_VERSION(3, 6)\n+      auto lpad = ir.CreateLandingPad(exn_type, 1, \"cleanup.lpad\");\n+#else\n+      auto personality = gModule->getFunction(PERSONALITY_FUNCTION);\n+      auto lpad = ir.CreateLandingPad(exn_type, personality, 1, \"cleanup.lpad\");\n+#endif\n+      lpad->setCleanup(true);\n+\n+      auto exct_value_0  = ir.CreateExtractValue(lpad, 0);\n+      auto store_loc_0 = ir.CreateAlloca(exct_value_0->getType());\n+      ir.CreateStore(exct_value_0, store_loc_0);\n+\n+      auto exct_value_1 = ir.CreateExtractValue(lpad, 1);\n+      auto store_loc_1 = ir.CreateAlloca(exct_value_1->getType());\n+      ir.CreateStore(exct_value_1, store_loc_1);\n+\n+      // if `ctx.ea_to_block.count(entry->lp_ea) == 0`, the landing pad basic block\n+      // might not be recovered. Throw a warning in such case.\n+      LOG_IF(ERROR, !ctx.ea_to_block.count(entry->lp_ea))\n+          << \"Missing block at \" << std::hex << entry->lp_ea\n+          << \" for exception landing pad from \" << entry->start_ea << std::dec;\n+\n+      auto lp_entry = GetOrCreateBlock(ctx, entry->lp_ea);\n+      ir.CreateBr(lp_entry);\n+      ctx.lp_to_block[entry->lp_ea] = landing_bb;\n+\n+    } else {\n+      std::stringstream ss;\n+      ss << \"catch_landingpad_\" << std::hex << entry->lp_ea;\n+      auto landing_bb = llvm::BasicBlock::Create(*gContext, ss.str(), ctx.lifted_func);\n+      llvm::IRBuilder<> ir(landing_bb);\n+      auto num_clauses = entry->type_var.size();\n+      auto exn_type = llvm::StructType::get(llvm::Type::getInt8PtrTy(*gContext),\n+                                            llvm::Type::getInt32Ty(*gContext), nullptr);\n+#if LLVM_VERSION_NUMBER > LLVM_VERSION(3, 6)\n+      auto lpad = ir.CreateLandingPad(exn_type, static_cast<unsigned int>(num_clauses), \"catch.lpad\");\n+#else\n+      auto personality = gModule->getFunction(PERSONALITY_FUNCTION);\n+      auto lpad = ir.CreateLandingPad(exn_type, personality, static_cast<unsigned int>(num_clauses), \"catch.lpad\");\n+#endif\n+      auto catch_all = false;\n+\n+      // The type indices in exception table are reversed for some of the binaries. In such case, the","path":"mcsema/BC/Function.cpp","position":162,"original_position":162,"commit_id":"1e1299d80346b357d8c1b85a1eb2ef2027a0d136","original_commit_id":"1e1299d80346b357d8c1b85a1eb2ef2027a0d136","user":{"login":"pgoodman","id":43664,"avatar_url":"https://avatars2.githubusercontent.com/u/43664?v=4","gravatar_id":"","url":"https://api.github.com/users/pgoodman","html_url":"https://github.com/pgoodman","followers_url":"https://api.github.com/users/pgoodman/followers","following_url":"https://api.github.com/users/pgoodman/following{/other_user}","gists_url":"https://api.github.com/users/pgoodman/gists{/gist_id}","starred_url":"https://api.github.com/users/pgoodman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgoodman/subscriptions","organizations_url":"https://api.github.com/users/pgoodman/orgs","repos_url":"https://api.github.com/users/pgoodman/repos","events_url":"https://api.github.com/users/pgoodman/events{/privacy}","received_events_url":"https://api.github.com/users/pgoodman/received_events","type":"User","site_admin":false},"body":"Add an issue to track this and update the comment to reference the issue number.","created_at":"2018-04-03T14:52:54Z","updated_at":"2018-04-03T15:00:07Z","html_url":"https://github.com/trailofbits/mcsema/pull/391#discussion_r178852438","pull_request_url":"https://api.github.com/repos/trailofbits/mcsema/pulls/391","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/comments/178852438"},"html":{"href":"https://github.com/trailofbits/mcsema/pull/391#discussion_r178852438"},"pull_request":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/391"}}},"pull_request":{"url":"https://api.github.com/repos/trailofbits/mcsema/pulls/391","id":178239847,"html_url":"https://github.com/trailofbits/mcsema/pull/391","diff_url":"https://github.com/trailofbits/mcsema/pull/391.diff","patch_url":"https://github.com/trailofbits/mcsema/pull/391.patch","issue_url":"https://api.github.com/repos/trailofbits/mcsema/issues/391","number":391,"state":"open","locked":false,"title":"C++ exception handling support","user":{"login":"kumarak","id":1365912,"avatar_url":"https://avatars0.githubusercontent.com/u/1365912?v=4","gravatar_id":"","url":"https://api.github.com/users/kumarak","html_url":"https://github.com/kumarak","followers_url":"https://api.github.com/users/kumarak/followers","following_url":"https://api.github.com/users/kumarak/following{/other_user}","gists_url":"https://api.github.com/users/kumarak/gists{/gist_id}","starred_url":"https://api.github.com/users/kumarak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumarak/subscriptions","organizations_url":"https://api.github.com/users/kumarak/orgs","repos_url":"https://api.github.com/users/kumarak/repos","events_url":"https://api.github.com/users/kumarak/events{/privacy}","received_events_url":"https://api.github.com/users/kumarak/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-29T06:44:30Z","updated_at":"2018-04-03T15:00:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1f949ac30f3ff04ff2c5559be94263ffe06e07e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/trailofbits/mcsema/pulls/391/commits","review_comments_url":"https://api.github.com/repos/trailofbits/mcsema/pulls/391/comments","review_comment_url":"https://api.github.com/repos/trailofbits/mcsema/pulls/comments{/number}","comments_url":"https://api.github.com/repos/trailofbits/mcsema/issues/391/comments","statuses_url":"https://api.github.com/repos/trailofbits/mcsema/statuses/1e1299d80346b357d8c1b85a1eb2ef2027a0d136","head":{"label":"trailofbits:issue_346_lift_ehframe","ref":"issue_346_lift_ehframe","sha":"1e1299d80346b357d8c1b85a1eb2ef2027a0d136","user":{"login":"trailofbits","id":2314423,"avatar_url":"https://avatars0.githubusercontent.com/u/2314423?v=4","gravatar_id":"","url":"https://api.github.com/users/trailofbits","html_url":"https://github.com/trailofbits","followers_url":"https://api.github.com/users/trailofbits/followers","following_url":"https://api.github.com/users/trailofbits/following{/other_user}","gists_url":"https://api.github.com/users/trailofbits/gists{/gist_id}","starred_url":"https://api.github.com/users/trailofbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trailofbits/subscriptions","organizations_url":"https://api.github.com/users/trailofbits/orgs","repos_url":"https://api.github.com/users/trailofbits/repos","events_url":"https://api.github.com/users/trailofbits/events{/privacy}","received_events_url":"https://api.github.com/users/trailofbits/received_events","type":"Organization","site_admin":false},"repo":{"id":22399826,"name":"mcsema","full_name":"trailofbits/mcsema","owner":{"login":"trailofbits","id":2314423,"avatar_url":"https://avatars0.githubusercontent.com/u/2314423?v=4","gravatar_id":"","url":"https://api.github.com/users/trailofbits","html_url":"https://github.com/trailofbits","followers_url":"https://api.github.com/users/trailofbits/followers","following_url":"https://api.github.com/users/trailofbits/following{/other_user}","gists_url":"https://api.github.com/users/trailofbits/gists{/gist_id}","starred_url":"https://api.github.com/users/trailofbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trailofbits/subscriptions","organizations_url":"https://api.github.com/users/trailofbits/orgs","repos_url":"https://api.github.com/users/trailofbits/repos","events_url":"https://api.github.com/users/trailofbits/events{/privacy}","received_events_url":"https://api.github.com/users/trailofbits/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/trailofbits/mcsema","description":"Framework for lifting x86, amd64, and aarch64 program binaries to LLVM bitcode","fork":false,"url":"https://api.github.com/repos/trailofbits/mcsema","forks_url":"https://api.github.com/repos/trailofbits/mcsema/forks","keys_url":"https://api.github.com/repos/trailofbits/mcsema/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trailofbits/mcsema/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trailofbits/mcsema/teams","hooks_url":"https://api.github.com/repos/trailofbits/mcsema/hooks","issue_events_url":"https://api.github.com/repos/trailofbits/mcsema/issues/events{/number}","events_url":"https://api.github.com/repos/trailofbits/mcsema/events","assignees_url":"https://api.github.com/repos/trailofbits/mcsema/assignees{/user}","branches_url":"https://api.github.com/repos/trailofbits/mcsema/branches{/branch}","tags_url":"https://api.github.com/repos/trailofbits/mcsema/tags","blobs_url":"https://api.github.com/repos/trailofbits/mcsema/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trailofbits/mcsema/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trailofbits/mcsema/git/refs{/sha}","trees_url":"https://api.github.com/repos/trailofbits/mcsema/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trailofbits/mcsema/statuses/{sha}","languages_url":"https://api.github.com/repos/trailofbits/mcsema/languages","stargazers_url":"https://api.github.com/repos/trailofbits/mcsema/stargazers","contributors_url":"https://api.github.com/repos/trailofbits/mcsema/contributors","subscribers_url":"https://api.github.com/repos/trailofbits/mcsema/subscribers","subscription_url":"https://api.github.com/repos/trailofbits/mcsema/subscription","commits_url":"https://api.github.com/repos/trailofbits/mcsema/commits{/sha}","git_commits_url":"https://api.github.com/repos/trailofbits/mcsema/git/commits{/sha}","comments_url":"https://api.github.com/repos/trailofbits/mcsema/comments{/number}","issue_comment_url":"https://api.github.com/repos/trailofbits/mcsema/issues/comments{/number}","contents_url":"https://api.github.com/repos/trailofbits/mcsema/contents/{+path}","compare_url":"https://api.github.com/repos/trailofbits/mcsema/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trailofbits/mcsema/merges","archive_url":"https://api.github.com/repos/trailofbits/mcsema/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trailofbits/mcsema/downloads","issues_url":"https://api.github.com/repos/trailofbits/mcsema/issues{/number}","pulls_url":"https://api.github.com/repos/trailofbits/mcsema/pulls{/number}","milestones_url":"https://api.github.com/repos/trailofbits/mcsema/milestones{/number}","notifications_url":"https://api.github.com/repos/trailofbits/mcsema/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trailofbits/mcsema/labels{/name}","releases_url":"https://api.github.com/repos/trailofbits/mcsema/releases{/id}","deployments_url":"https://api.github.com/repos/trailofbits/mcsema/deployments","created_at":"2014-07-29T23:24:24Z","updated_at":"2018-04-03T07:18:58Z","pushed_at":"2018-04-03T07:16:22Z","git_url":"git://github.com/trailofbits/mcsema.git","ssh_url":"git@github.com:trailofbits/mcsema.git","clone_url":"https://github.com/trailofbits/mcsema.git","svn_url":"https://github.com/trailofbits/mcsema","homepage":"https://www.trailofbits.com/research-and-development/mcsema/","size":112356,"stargazers_count":902,"watchers_count":902,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":162,"mirror_url":null,"archived":false,"open_issues_count":48,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":162,"open_issues":48,"watchers":902,"default_branch":"master"}},"base":{"label":"trailofbits:master","ref":"master","sha":"7a7dc48a1642710f85be3346b01a584cde8b7ed7","user":{"login":"trailofbits","id":2314423,"avatar_url":"https://avatars0.githubusercontent.com/u/2314423?v=4","gravatar_id":"","url":"https://api.github.com/users/trailofbits","html_url":"https://github.com/trailofbits","followers_url":"https://api.github.com/users/trailofbits/followers","following_url":"https://api.github.com/users/trailofbits/following{/other_user}","gists_url":"https://api.github.com/users/trailofbits/gists{/gist_id}","starred_url":"https://api.github.com/users/trailofbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trailofbits/subscriptions","organizations_url":"https://api.github.com/users/trailofbits/orgs","repos_url":"https://api.github.com/users/trailofbits/repos","events_url":"https://api.github.com/users/trailofbits/events{/privacy}","received_events_url":"https://api.github.com/users/trailofbits/received_events","type":"Organization","site_admin":false},"repo":{"id":22399826,"name":"mcsema","full_name":"trailofbits/mcsema","owner":{"login":"trailofbits","id":2314423,"avatar_url":"https://avatars0.githubusercontent.com/u/2314423?v=4","gravatar_id":"","url":"https://api.github.com/users/trailofbits","html_url":"https://github.com/trailofbits","followers_url":"https://api.github.com/users/trailofbits/followers","following_url":"https://api.github.com/users/trailofbits/following{/other_user}","gists_url":"https://api.github.com/users/trailofbits/gists{/gist_id}","starred_url":"https://api.github.com/users/trailofbits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trailofbits/subscriptions","organizations_url":"https://api.github.com/users/trailofbits/orgs","repos_url":"https://api.github.com/users/trailofbits/repos","events_url":"https://api.github.com/users/trailofbits/events{/privacy}","received_events_url":"https://api.github.com/users/trailofbits/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/trailofbits/mcsema","description":"Framework for lifting x86, amd64, and aarch64 program binaries to LLVM bitcode","fork":false,"url":"https://api.github.com/repos/trailofbits/mcsema","forks_url":"https://api.github.com/repos/trailofbits/mcsema/forks","keys_url":"https://api.github.com/repos/trailofbits/mcsema/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trailofbits/mcsema/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trailofbits/mcsema/teams","hooks_url":"https://api.github.com/repos/trailofbits/mcsema/hooks","issue_events_url":"https://api.github.com/repos/trailofbits/mcsema/issues/events{/number}","events_url":"https://api.github.com/repos/trailofbits/mcsema/events","assignees_url":"https://api.github.com/repos/trailofbits/mcsema/assignees{/user}","branches_url":"https://api.github.com/repos/trailofbits/mcsema/branches{/branch}","tags_url":"https://api.github.com/repos/trailofbits/mcsema/tags","blobs_url":"https://api.github.com/repos/trailofbits/mcsema/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trailofbits/mcsema/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trailofbits/mcsema/git/refs{/sha}","trees_url":"https://api.github.com/repos/trailofbits/mcsema/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trailofbits/mcsema/statuses/{sha}","languages_url":"https://api.github.com/repos/trailofbits/mcsema/languages","stargazers_url":"https://api.github.com/repos/trailofbits/mcsema/stargazers","contributors_url":"https://api.github.com/repos/trailofbits/mcsema/contributors","subscribers_url":"https://api.github.com/repos/trailofbits/mcsema/subscribers","subscription_url":"https://api.github.com/repos/trailofbits/mcsema/subscription","commits_url":"https://api.github.com/repos/trailofbits/mcsema/commits{/sha}","git_commits_url":"https://api.github.com/repos/trailofbits/mcsema/git/commits{/sha}","comments_url":"https://api.github.com/repos/trailofbits/mcsema/comments{/number}","issue_comment_url":"https://api.github.com/repos/trailofbits/mcsema/issues/comments{/number}","contents_url":"https://api.github.com/repos/trailofbits/mcsema/contents/{+path}","compare_url":"https://api.github.com/repos/trailofbits/mcsema/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trailofbits/mcsema/merges","archive_url":"https://api.github.com/repos/trailofbits/mcsema/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trailofbits/mcsema/downloads","issues_url":"https://api.github.com/repos/trailofbits/mcsema/issues{/number}","pulls_url":"https://api.github.com/repos/trailofbits/mcsema/pulls{/number}","milestones_url":"https://api.github.com/repos/trailofbits/mcsema/milestones{/number}","notifications_url":"https://api.github.com/repos/trailofbits/mcsema/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trailofbits/mcsema/labels{/name}","releases_url":"https://api.github.com/repos/trailofbits/mcsema/releases{/id}","deployments_url":"https://api.github.com/repos/trailofbits/mcsema/deployments","created_at":"2014-07-29T23:24:24Z","updated_at":"2018-04-03T07:18:58Z","pushed_at":"2018-04-03T07:16:22Z","git_url":"git://github.com/trailofbits/mcsema.git","ssh_url":"git@github.com:trailofbits/mcsema.git","clone_url":"https://github.com/trailofbits/mcsema.git","svn_url":"https://github.com/trailofbits/mcsema","homepage":"https://www.trailofbits.com/research-and-development/mcsema/","size":112356,"stargazers_count":902,"watchers_count":902,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":162,"mirror_url":null,"archived":false,"open_issues_count":48,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":162,"open_issues":48,"watchers":902,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/391"},"html":{"href":"https://github.com/trailofbits/mcsema/pull/391"},"issue":{"href":"https://api.github.com/repos/trailofbits/mcsema/issues/391"},"comments":{"href":"https://api.github.com/repos/trailofbits/mcsema/issues/391/comments"},"review_comments":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/391/comments"},"review_comment":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/trailofbits/mcsema/pulls/391/commits"},"statuses":{"href":"https://api.github.com/repos/trailofbits/mcsema/statuses/1e1299d80346b357d8c1b85a1eb2ef2027a0d136"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"pgoodman"}}