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")
125 if(arg.is_infile_name)
149 std::vector<std::string> new_argv;
152 new_argv.push_back(a.arg);
158 log.debug() <<
"RUN:";
159 for(std::size_t i = 0; i < new_argv.size(); i++)
160 log.debug() <<
" " << new_argv[i];
167 bool building_executable,
168 const std::list<std::string> &object_files)
170 std::string output_file;
176 if(output_file ==
"/dev/null")
180 output_file =
"a.out";
191 std::filesystem::rename(output_file, goto_binary);
193 catch(
const std::filesystem::filesystem_error &e)
206 for(
const auto &object_file : object_files)
208 log.debug() <<
"stripping goto-cc sections before building EFI binary"
218 std::vector<std::string> objcopy_argv;
220 objcopy_argv.push_back(objcopy_cmd);
221 objcopy_argv.push_back(
"--remove-section=goto-cc");
222 objcopy_argv.push_back(object_file);
224 if(
run(objcopy_argv[0], objcopy_argv) != 0)
226 log.debug() <<
"EFI binary preparation: removing goto-cc section failed"
248 for(
const auto &object_file : object_files)
250 log.debug() <<
"EFI binary preparation: restoring object files"
253 const int mv_result = rename(bin_name.c_str(), object_file.c_str());
282 std::cout <<
"goto-ld understands the options of "
283 <<
"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)
void print_warnings_as_errors(bool yes)
With yes set to true, prefix warnings with "error:" instead of "warning:".
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.
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 binary(const constant_exprt &src)
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)
char * strerror(int errnum)