- return run_command(m, "ld -r -o ../%s.o %s", m->basename, obj_list(m));
+ filename = link_objects(m, obj_list(m), &err);
+ if (filename) {
+ char *realname = talloc_asprintf(m, "../%s.o", m->basename);
+ /* We leave this object file around, all built. */
+ if (rename(filename, realname) != 0)
+ return talloc_asprintf(m, "Failed to rename %s to %s",
+ filename, realname);
+ return NULL;
+ }
+ return err;