7 static FILE *my_popen(const char *command
, const char *file
)
9 static char command_buf
[MAXPATHLEN
];
11 size_t command_len
= strlen(command
);
12 size_t file_len
= strlen(file
);
16 if (file_len
+ command_len
>= sizeof(command_buf
))
17 fatal("collect_sets()", strerror(ENAMETOOLONG
));
19 memcpy(command_buf
, command
, command_len
);
20 memcpy(command_buf
+ command_len
, file
, file_len
+ 1);
24 pipe
= popen(command_buf
, "r");
26 fatal(command_buf
, strerror(errno
));
33 This routine is slow, but does the work and it's the simplest to write down.
34 All this will get integrated into the linker anyway, so there's no point
35 in doing optimizations
37 void collect_sets(const char *file
, setnode
**setlist_ptr
)
41 FILE *pipe
= my_popen("objdump -h ", file
);
43 /* This fscanf() simply splits the whole stream into separate words */
44 while (fscanf(pipe
, " %200s ", secname
) > 0)
46 parse_format(secname
);
47 parse_secname(secname
, setlist_ptr
);
53 int check_and_print_undefined_symbols(const char *file
)
55 int there_are_undefined_syms
= 0;
59 FILE *pipe
= my_popen("nm -ulC ", file
);
61 while ((cnt
= fread(buf
, 1, sizeof(buf
), pipe
)) != 0)
63 if (!there_are_undefined_syms
)
65 there_are_undefined_syms
= 1;
66 fprintf(stderr
, "There are undefined symbols in '%s':\n", file
);
69 fwrite(buf
, cnt
, 1, stderr
);
74 return there_are_undefined_syms
;