20 const std::string &compiler_or_linker,
21 const std::string &goto_binary_file,
22 const std::string &output_file,
30 std::string objcopy_cmd;
34 objcopy_cmd = compiler_or_linker;
35 objcopy_cmd.erase(objcopy_cmd.size() - 2);
36 objcopy_cmd +=
"objcopy";
39 objcopy_cmd =
"objcopy";
43 message.
debug() <<
"merging " << output_file <<
" and " << goto_binary_file
44 <<
" using " << objcopy_cmd
50 std::vector<std::string> objcopy_argv = {
52 "--remove-section",
"goto-cc",
53 "--add-section",
"goto-cc=" + goto_binary_file, output_file};
55 result =
run(objcopy_argv[0], objcopy_argv,
"",
"");
59 int remove_result =
remove(goto_binary_file.c_str());
60 if(remove_result != 0)
62 message.
error() <<
"Remove failed: " << std::strerror(errno)
65 result = remove_result;
68 #elif defined(__APPLE__) 71 message.
debug() <<
"merging " << output_file <<
" and " << goto_binary_file
78 std::vector<std::string> lipo_argv = {
79 "lipo", output_file,
"-create",
"-arch",
"hppa7100LC", goto_binary_file,
80 "-output", output_file };
82 result =
run(lipo_argv[0], lipo_argv,
"",
"");
86 int remove_result =
remove(goto_binary_file.c_str());
87 if(remove_result != 0)
89 message.
error() <<
"Remove failed: " << std::strerror(errno)
92 result = remove_result;
96 message.
error() <<
"binary merging not implemented for this platform" int run(const std::string &what, const std::vector< std::string > &argv, const std::string &std_input, const std::string &std_output, const std::string &std_error)
static mstreamt & eom(mstreamt &m)
Create hybrid binary with goto-binary section.
int hybrid_binary(const std::string &compiler_or_linker, const std::string &goto_binary_file, const std::string &output_file, message_handlert &message_handler)
Merges a goto binary into an object file (e.g.
bool has_suffix(const std::string &s, const std::string &suffix)
goto_programt coverage_criteriont message_handlert & message_handler