Go to the documentation of this file.
17 #define EX_SOFTWARE 70
40 if(cmdline.
isset(
"native-linker"))
41 return cmdline.
get_value(
"native-linker");
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")
118 if(arg.is_infile_name)
142 std::vector<std::string> new_argv;
145 new_argv.push_back(a.arg);
151 log.debug() <<
"RUN:";
152 for(std::size_t i = 0; i < new_argv.size(); i++)
153 log.debug() <<
" " << new_argv[i];
160 bool building_executable,
161 const std::list<std::string> &object_files)
163 std::string output_file;
169 if(output_file ==
"/dev/null")
173 output_file =
"a.out";
176 log.debug() <<
"Running " <<
native_tool_name <<
" to generate hybrid binary"
199 for(
const auto &object_file : object_files)
201 log.debug() <<
"stripping goto-cc sections before building EFI binary"
211 std::vector<std::string> objcopy_argv;
213 objcopy_argv.push_back(objcopy_cmd);
214 objcopy_argv.push_back(
"--remove-section=goto-cc");
215 objcopy_argv.push_back(object_file);
217 if(
run(objcopy_argv[0], objcopy_argv) != 0)
219 log.debug() <<
"EFI binary preparation: removing goto-cc section failed"
240 log.debug() <<
"arch set with " << object_files.size() <<
messaget::eom;
241 for(
const auto &object_file : object_files)
243 log.debug() <<
"EFI binary preparation: restoring object files"
246 const int mv_result = rename(bin_name.c_str(), object_file.c_str());
249 log.debug() <<
"Rename failed: " << std::strerror(errno)
275 std::cout <<
"goto-ld understands the options of "
276 <<
"ld plus the following.\n\n";
Class that provides messages with a built-in verbosity 'level'.
gcc_message_handlert gcc_message_handler
Merge linker script-defined symbols into a goto-program.
virtual bool isset(char option) const
std::list< std::string > source_files
static std::string linker_name(const cmdlinet &cmdline, const std::string &base_name)
void help_mode() final
display command line help
int add_linker_script_definitions()
Add values of linkerscript-defined symbols to the goto-binary.
message_handlert & message_handler
bool doit()
reads and source and object files, compiles and links them into goto program objects.
int run(const std::string &what, const std::vector< std::string > &argv)
std::list< std::string > libraries
Synthesise definitions of symbols that are defined in linker scripts.
const std::string base_name
std::string native_tool_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.
std::string output_file_object
ld_modet(goto_cc_cmdlinet &_cmdline, const std::string &_base_name)
std::list< std::string > object_files
std::string objcopy_command(const std::string &compiler_or_linker)
Return the name of the objcopy tool matching the chosen compiler or linker command.
@ COMPILE_LINK_EXECUTABLE
std::string output_file_executable
#define PRECONDITION(CONDITION)
std::string get_value(char option) const
std::list< std::string > library_paths
std::string object_file_extension
goto_cc_cmdlinet & cmdline
bool add_input_file(const std::string &)
puts input file names into a list and does preprocessing for libraries.
const std::string goto_binary_tmp_suffix
bool set(const cmdlinet &cmdline)
virtual std::string what() const
A human readable description of what went wrong.
static std::string binary(const constant_exprt &src)
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.
void help()
display command line help
unsignedbv_typet size_type()
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.
int run_ld()
call ld with original command line
const std::list< std::string > & get_values(const std::string &option) const
Base class for exceptions thrown in the cprover project.
void file_rename(const std::string &old_path, const std::string &new_path)
Rename a file.