#include <sys/types.h>
#include <sys/wait.h>
+#ifdef CROSS
+#define CMD_AS "/tmp/cross/as"
+#define CMD_CC "/tmp/cross/scc"
+#define CMD_COPT "/tmp/cross/copt"
+#define COPT_FILE "/tmp/cross/ccc-copt"
+#define CMD_LD "/tmp/cross/ld"
+#define CMD_CPP "/tmp/cross/cpp"
+#define CRT0 "/tmp/cross/crt0.o"
+#else
#define CMD_AS "/bin/as"
#define CMD_CC "/usr/lib/cc"
#define CMD_COPT "/usr/lib/copt"
#define CMD_LD "/bin/ld"
#define CMD_CPP "/usr/lib/cpp"
#define CRT0 "/usr/lib/crt0.o"
+#endif
struct obj {
struct obj *next;
char **p = rmlist;
while (p < rmptr) {
if (keep_temp == 0)
- printf("remove %s\n", *p);
+ unlink(*p);
free(*p++);
}
rmptr = rmlist;
fatal();
}
if (pid == 0) {
+// printf("Run %s\n", arglist[0]);
+ fflush(stdout);
if (arginfd != -1) {
dup2(arginfd, 0);
close(arginfd);
fatal();
}
}
- if (WIFSIGNALED(status) || WEXITSTATUS(status))
+ if (WIFSIGNALED(status) || WEXITSTATUS(status)) {
+// printf("cc: %s failed.\n", arglist[0]);
fatal();
+ }
}
static void redirect_in(const char *p)
static void redirect_out(const char *p)
{
- argoutfd = open(p, O_WRONLY | O_CREAT, 0666);
+ argoutfd = open(p, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (argoutfd == -1) {
perror(p);
fatal();
add_argument(COPT_FILE);
redirect_in(tmp);
redirect_out(pathmod(path, ".%", ".s", 2));
+ run_command();
free(tmp);
}
{
build_arglist(CMD_LD);
add_argument("-b");
+ add_argument("-c");
+ add_argument("256");
if (strip)
add_argument("-s");
add_argument("-o");
void sequence(struct obj *i)
{
- printf("Processing %s %d\n", i->name, i->type);
+// printf("Last Phase %d\n", last_phase);
+// printf("1:Processing %s %d\n", i->name, i->type);
if (i->type == TYPE_S) {
convert_S_to_s(i->name);
i->type = TYPE_s;
}
if (last_phase == 1)
return;
- printf("Processing %s %d\n", i->name, i->type);
+// printf("2:Processing %s %d\n", i->name, i->type);
if (i->type == TYPE_C_pp) {
convert_c_to_s(i->name);
i->type = TYPE_s;
}
if (last_phase == 2)
return;
- printf("Processing %s %d\n", i->name, i->type);
+// printf("3:Processing %s %d\n", i->name, i->type);
if (i->type == TYPE_s) {
convert_s_to_o(i->name);
i->type = TYPE_O;