20 const std::string &compiler_or_linker,
21 const std::string &goto_binary_file,
22 const std::string &output_file,
29 #if defined(__linux__) || defined(__FreeBSD_kernel__)
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;
97 (void)compiler_or_linker;
98 (void)goto_binary_file;
100 message.
error() <<
"binary merging not implemented for this platform"