11 static void bfd_fatal(const char *msg
)
13 fatal(msg
, bfd_errmsg(bfd_get_error()));
16 int check_and_print_undefined_symbols(const char *file
)
18 bfd_byte
*cur
, *minisyms
;
22 int there_are_undefined_syms
= 0;
29 (abfd
= bfd_openr(file
, "default")) == NULL
||
30 !bfd_check_format(abfd
, bfd_object
)
36 symcount
= bfd_read_minisymbols(abfd
, FALSE
, (void **)&minisyms
, &size
);
38 bfd_fatal (bfd_get_filename (abfd
));
43 store
= bfd_make_empty_symbol(abfd
);
45 bfd_fatal(bfd_get_filename(abfd
));
47 for (cur
= minisyms
; cur
< (minisyms
+ (symcount
* size
)); cur
+= size
)
51 sym
= bfd_minisymbol_to_symbol(abfd
, FALSE
, (const void *)cur
, store
);
53 bfd_fatal(bfd_get_filename (abfd
));
55 if (bfd_is_und_section (sym
->section
))
57 if (!there_are_undefined_syms
)
59 there_are_undefined_syms
= 1;
61 fprintf(stderr
, "There are undefined symbols in '%s':\n", bfd_get_filename(abfd
));
64 fprintf(stderr
, "%s\n", sym
->name
);
69 /* We should free() minisyms, but since we're called only once, we let the system
72 return there_are_undefined_syms
;
75 static void setfunc(bfd
*exe
, asection
*sect
, PTR setlist_ptr
)
77 parse_secname(sect
->name
, (setnode
**)setlist_ptr
);
80 void collect_sets(const char *file
, setnode
**setlist_ptr
)
88 (abfd
= bfd_openr(file
, "default")) == NULL
||
89 !bfd_check_format(abfd
, bfd_object
)
95 parse_format(abfd
->xvec
->name
);
96 bfd_map_over_sections(abfd
, setfunc
, setlist_ptr
);
101 static void collect_lib(asymbol
*sym
, setnode
**liblist_ptr
)
107 if (strncmp(sym
->name
, "__aros_libreq_", 14) != 0)
110 node
= xmalloc(sizeof(*node
)+strlen(sym
->name
)+1);
111 name
= (char *)(&node
[1]);
112 strcpy(name
, sym
->name
);
114 cp
= strchr(name
+ 14, '.');
117 pri
= strtoul(cp
+1, &tmp
, 0);
130 node
->secname
= name
;
131 node
->off_setname
= 14;
133 node
->next
= *liblist_ptr
;
137 void collect_libs(const char *file
, setnode
**liblist_ptr
)
142 /* We assume bfd_init() has already been colled by
148 (abfd
= bfd_openr(file
, "default")) == NULL
||
149 !bfd_check_format(abfd
, bfd_object
)
155 symtab_size
= bfd_get_symtab_upper_bound(abfd
);
156 if (symtab_size
> 0) {
160 symtab
= (asymbol
**)xmalloc(symtab_size
);
161 symbols
= bfd_canonicalize_symtab(abfd
, symtab
);
165 for (i
= 0; i
< symbols
; i
++)
166 collect_lib(symtab
[i
], liblist_ptr
);