17 #define EX_SOFTWARE 70 38 const std::string &base_name)
40 if(cmdline.
isset(
"native-assembler"))
41 return cmdline.
get_value(
"native-assembler");
43 if(base_name==
"as86" ||
44 base_name.find(
"goto-as86")!=std::string::npos)
49 if(
pos==std::string::npos)
52 std::string result=base_name;
53 result.replace(
pos, 7,
"as");
60 const std::string &_base_name,
61 bool _produce_hybrid_binary):
63 produce_hybrid_binary(_produce_hybrid_binary),
78 unsigned int verbosity=1;
82 base_name.find(
"goto-as86")!=std::string::npos;
91 status() <<
"GNU assembler version 2.20.51.0.7 20100318" 95 "Copyright (C) 2006-2014 Daniel Kroening, Christoph Wintersteiger\n" <<
114 debug() <<
"AS86 mode (hybrid)" <<
eom;
121 debug() <<
"AS mode (hybrid)" <<
eom;
135 debug() <<
"Compiling and linking an executable" <<
eom;
140 debug() <<
"Compiling and linking a library" <<
eom;
145 compiler.object_file_extension=
"o";
159 compiler.output_file_object=
"a.out";
160 compiler.output_file_executable=
"a.out";
167 for(goto_cc_cmdlinet::parsed_argvt::iterator
172 if(!arg_it->is_infile_name)
177 std::ifstream is(infile);
180 error() <<
"Failed to open input source " << infile <<
eom;
191 const std::string comment2=act_as_as86 ?
"::" :
"##";
195 while(std::getline(is, line))
197 if(line==comment2+
" GOTO-CC")
201 assert(!dest.empty());
202 compiler.add_input_file(dest);
207 std::string new_name=
209 std::to_string(outputs)+
".i";
210 dest=temp_dir(new_name);
215 error() <<
"Failed to tmp output file " << dest <<
eom;
225 os << line.substr(2) <<
'\n';
230 assert(!dest.empty());
231 compiler.add_input_file(dest);
234 warning() <<
"No GOTO-CC section found in " << arg_it->arg <<
eom;
239 if(compiler.source_files.empty())
260 std::vector<std::string> new_argv;
263 new_argv.push_back(a.arg);
270 for(std::size_t i=0; i<new_argv.size(); i++)
271 std::cout <<
" " << new_argv[i];
280 std::string output_file=
"a.out";
289 if(output_file==
"/dev/null")
293 <<
" to generate hybrid binary" <<
eom;
296 rename(output_file.c_str(),
297 (output_file+
".goto-cc-saved").c_str());
303 debug() <<
"merging " << output_file <<
eom;
304 std::string saved=output_file+
".goto-cc-saved";
310 std::vector<std::string> objcopy_argv;
312 objcopy_argv.push_back(
"objcopy");
313 objcopy_argv.push_back(
"--remove-section=goto-cc");
314 objcopy_argv.push_back(output_file);
316 result=
run(objcopy_argv[0], objcopy_argv,
"",
"");
322 std::vector<std::string> objcopy_argv;
324 objcopy_argv.push_back(
"objcopy");
325 objcopy_argv.push_back(
"--add-section");
326 objcopy_argv.push_back(
"goto-cc="+saved);
327 objcopy_argv.push_back(output_file);
329 result=
run(objcopy_argv[0], objcopy_argv,
"",
"");
332 remove(saved.c_str());
333 #elif defined(__APPLE__) 337 std::vector<std::string> lipo_argv;
340 lipo_argv.push_back(
"lipo");
341 lipo_argv.push_back(output_file);
342 lipo_argv.push_back(
"-create");
343 lipo_argv.push_back(
"-arch");
344 lipo_argv.push_back(
"hppa7100LC");
345 lipo_argv.push_back(saved);
346 lipo_argv.push_back(
"-output");
347 lipo_argv.push_back(output_file);
349 result=
run(lipo_argv[0], lipo_argv,
"",
"");
352 remove(saved.c_str());
355 error() <<
"binary merging not implemented for this platform" <<
eom;
365 std::cout <<
"goto-as understands the options of as plus the following.\n\n";
struct configt::ansi_ct ansi_c
virtual int doit()
does it.
unsigned unsafe_string2unsigned(const std::string &str, int base)
std::string get_value(char option) const
unsignedbv_typet size_type()
const bool produce_hybrid_binary
static mstreamt & eom(mstreamt &m)
std::string get_base_name(const std::string &in, bool strip_suffix)
cleans a filename from path and extension
bool set(const cmdlinet &cmdline)
bool rename(exprt &expr, const irep_idt &old_name, const irep_idt &new_name)
automated variable renaming
virtual bool isset(char option) const
goto_cc_cmdlinet & cmdline
static std::string assembler_name(const cmdlinet &cmdline, const std::string &base_name)
Compile and link source and object files.
static irep_idt this_operating_system()
virtual void help_mode()
display command line help
gcc_message_handlert message_handler
virtual void help()
display command line help
as_modet(goto_cc_cmdlinet &_cmdline, const std::string &_base_name, bool _produce_hybrid_binary)
void set_verbosity(unsigned _verbosity)
int run_as()
run as or as86 with original command line
const std::string native_tool_name
const std::string base_name
static irep_idt this_architecture()
int run(const std::string &what, const std::vector< std::string > &argv, const std::string &std_input, const std::string &std_output)