--- src/ldgeneric.c 2015-08-21 14:22:37.000000000 +0200 +++ src/ldgeneric.c 2015-11-20 08:25:42.003092970 +0100 @@ -2628,12 +2628,12 @@ } -/* Callback function registered with on_exit to make sure the temporary +/* Callback function registered with atexit to make sure the temporary files gets removed if something goes wrong. */ static void -remove_tempfile (int status, void *arg) +remove_tempfile (void) { - if (status != 0 && ld_state.tempfname != NULL) + if (error_message_count != 0 && ld_state.tempfname != NULL) unlink (ld_state.tempfname); } @@ -2680,7 +2680,7 @@ /* Make sure we remove the temporary file in case something goes wrong. */ - on_exit (remove_tempfile, NULL); + atexit (remove_tempfile); /* Create the ELF file data for the output file. */ Elf *elf = ld_state.outelf = elf_begin (fd,