@@ -30,6 +30,7 @@ Author: Michael Tautschnig
30
30
#include < util/version.h>
31
31
32
32
#include " compile.h"
33
+ #include " hybrid_binary.h"
33
34
34
35
static std::string assembler_name (
35
36
const cmdlinet &cmdline,
@@ -287,9 +288,8 @@ int as_modet::as_hybrid_binary()
287
288
<< " to generate hybrid binary" << eom;
288
289
289
290
// save the goto-cc output file
290
- int result=rename (
291
- output_file.c_str (),
292
- (output_file+" .goto-cc-saved" ).c_str ());
291
+ std::string saved = output_file + " .goto-cc-saved" ;
292
+ int result = rename (output_file.c_str (), saved.c_str ());
293
293
if (result!=0 )
294
294
{
295
295
error () << " Rename failed: " << std::strerror (errno) << eom;
@@ -298,77 +298,12 @@ int as_modet::as_hybrid_binary()
298
298
299
299
result=run_as ();
300
300
301
- // merge output from as with goto-binaries
302
- // using objcopy, or do cleanup if an earlier call failed
303
- debug () << " merging " << output_file << eom;
304
- std::string saved=output_file+" .goto-cc-saved" ;
305
-
306
- #if defined(__linux__) || defined(__FreeBSD_kernel__)
307
- if (result==0 )
308
- {
309
- // remove any existing goto-cc section
310
- std::vector<std::string> objcopy_argv;
311
-
312
- objcopy_argv.push_back (" objcopy" );
313
- objcopy_argv.push_back (" --remove-section=goto-cc" );
314
- objcopy_argv.push_back (output_file);
315
-
316
- result = run (objcopy_argv[0 ], objcopy_argv);
317
- }
318
-
319
- if (result==0 )
301
+ if (result == 0 )
320
302
{
321
- // now add goto-binary as goto-cc section
322
- std::vector<std::string> objcopy_argv;
323
-
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);
328
-
329
- result = run (objcopy_argv[0 ], objcopy_argv);
303
+ result = hybrid_binary (
304
+ native_tool_name, saved, output_file, get_message_handler ());
330
305
}
331
306
332
- int remove_result=remove (saved.c_str ());
333
- if (remove_result!=0 )
334
- {
335
- error () << " Remove failed: " << std::strerror (errno) << eom;
336
- if (result==0 )
337
- result=remove_result;
338
- }
339
-
340
- #elif defined(__APPLE__)
341
- // Mac
342
- if (result==0 )
343
- {
344
- std::vector<std::string> lipo_argv;
345
-
346
- // now add goto-binary as hppa7100LC section
347
- lipo_argv.push_back (" lipo" );
348
- lipo_argv.push_back (output_file);
349
- lipo_argv.push_back (" -create" );
350
- lipo_argv.push_back (" -arch" );
351
- lipo_argv.push_back (" hppa7100LC" );
352
- lipo_argv.push_back (saved);
353
- lipo_argv.push_back (" -output" );
354
- lipo_argv.push_back (output_file);
355
-
356
- result = run (lipo_argv[0 ], lipo_argv);
357
- }
358
-
359
- int remove_result=remove (saved.c_str ());
360
- if (remove_result!=0 )
361
- {
362
- error () << " Remove failed: " << std::strerror (errno) << eom;
363
- if (result==0 )
364
- result=remove_result;
365
- }
366
-
367
- #else
368
- error () << " binary merging not implemented for this platform" << eom;
369
- result = 1 ;
370
- #endif
371
-
372
307
return result;
373
308
}
374
309
0 commit comments