40 if(cmdline.
isset(
"native-linker"))
41 return cmdline.
get_value(
"native-linker");
43 std::string::size_type
pos = base_name.find(
"goto-ld");
46 pos == std::string::npos || base_name ==
"goto-gcc" ||
47 base_name ==
"goto-ld")
50 std::string result = base_name;
51 result.replace(
pos, 7,
"ld");
58 goto_binary_tmp_suffix(
".goto-cc-saved")
120 if(arg.is_infile_name)
144 std::vector<std::string> new_argv;
147 new_argv.push_back(a.arg);
153 log.debug() <<
"RUN:";
154 for(std::size_t i = 0; i < new_argv.size(); i++)
155 log.debug() <<
" " << new_argv[i];
162 bool building_executable,
163 const std::list<std::string> &object_files)
165 std::string output_file;
171 if(output_file ==
"/dev/null")
175 output_file =
"a.out";
178 log.debug() <<
"Running " <<
native_tool_name <<
" to generate hybrid binary"
201 for(
const auto &object_file : object_files)
203 log.debug() <<
"stripping goto-cc sections before building EFI binary"
208 std::ifstream in(object_file, std::ios::binary);
209 std::ofstream out(bin_name, std::ios::binary);
213 std::vector<std::string> objcopy_argv;
215 objcopy_argv.push_back(objcopy_cmd);
216 objcopy_argv.push_back(
"--remove-section=goto-cc");
217 objcopy_argv.push_back(object_file);
219 if(
run(objcopy_argv[0], objcopy_argv) != 0)
221 log.debug() <<
"EFI binary preparation: removing goto-cc section failed"
242 log.debug() <<
"arch set with " << object_files.size() <<
messaget::eom;
243 for(
const auto &object_file : object_files)
245 log.debug() <<
"EFI binary preparation: restoring object files"
248 const int mv_result = rename(bin_name.c_str(), object_file.c_str());
251 log.debug() <<
"Rename failed: " << std::strerror(errno)
277 std::cout <<
"goto-ld understands the options of "
278 <<
"ld plus the following.\n\n";
std::string get_value(char option) const
virtual bool isset(char option) const
const std::list< std::string > & get_values(const std::string &option) const
@ COMPILE_LINK_EXECUTABLE
std::string output_file_object
bool add_input_file(const std::string &)
puts input file names into a list and does preprocessing for libraries.
std::list< std::string > libraries
std::list< std::string > object_files
bool doit()
reads and source and object files, compiles and links them into goto program objects.
std::list< std::string > source_files
std::string object_file_extension
std::list< std::string > library_paths
std::string output_file_executable
bool set(const cmdlinet &cmdline)
Base class for exceptions thrown in the cprover project.
virtual std::string what() const
A human readable description of what went wrong.
goto_cc_cmdlinet & cmdline
message_handlert & message_handler
const std::string base_name
void help()
display command line help
void help_mode() final
display command line help
const std::string goto_binary_tmp_suffix
std::string native_tool_name
gcc_message_handlert gcc_message_handler
int run_ld()
call ld with original command line
ld_modet(goto_cc_cmdlinet &_cmdline, const std::string &_base_name)
int ld_hybrid_binary(bool building_executable, const std::list< std::string > &object_files)
Build an ELF or Mach-O binary containing a goto-cc section.
Synthesise definitions of symbols that are defined in linker scripts.
int add_linker_script_definitions()
Add values of linkerscript-defined symbols to the goto-binary.
Class that provides messages with a built-in verbosity 'level'.
static unsigned eval_verbosity(const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.
Compile and link source and object files.
void file_rename(const std::string &old_path, const std::string &new_path)
Rename a file.
static std::string linker_name(const cmdlinet &cmdline, const std::string &base_name)
Command line interpretation for goto-cc.
int hybrid_binary(const std::string &compiler_or_linker, const std::string &goto_binary_file, const std::string &output_file, bool building_executable, message_handlert &message_handler, bool linking_efi)
Merges a goto binary into an object file (e.g.
std::string objcopy_command(const std::string &compiler_or_linker)
Return the name of the objcopy tool matching the chosen compiler or linker command.
Create hybrid binary with goto-binary section.
static std::string linker_name(const cmdlinet &cmdline, const std::string &base_name)
Base class for command line interpretation.
Merge linker script-defined symbols into a goto-program.
int run(const std::string &what, const std::vector< std::string > &argv)
#define PRECONDITION(CONDITION)