2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
7 #define PACKAGE_VERSION
13 #include <sys/param.h>
18 static void bfd_fatal(const char *msg
)
20 fatal(msg
, bfd_errmsg(bfd_get_error()));
23 int check_and_print_undefined_symbols(const char *file
)
25 bfd_byte
*cur
, *minisyms
;
29 int there_are_undefined_syms
= 0;
36 (abfd
= bfd_openr(file
, "default")) == NULL
||
37 !bfd_check_format(abfd
, bfd_object
)
43 symcount
= bfd_read_minisymbols(abfd
, FALSE
, (void **)&minisyms
, &size
);
45 bfd_fatal (bfd_get_filename (abfd
));
50 store
= bfd_make_empty_symbol(abfd
);
52 bfd_fatal(bfd_get_filename(abfd
));
54 for (cur
= minisyms
; cur
< (minisyms
+ (symcount
* size
)); cur
+= size
)
58 sym
= bfd_minisymbol_to_symbol(abfd
, FALSE
, (const void *)cur
, store
);
60 bfd_fatal(bfd_get_filename (abfd
));
62 if (bfd_is_und_section (sym
->section
))
64 if (!there_are_undefined_syms
)
66 there_are_undefined_syms
= 1;
68 fprintf(stderr
, "There are undefined symbols in '%s':\n", bfd_get_filename(abfd
));
71 fprintf(stderr
, "%s\n", sym
->name
);
76 /* We should free() minisyms, but since we're called only once, we let the system
79 return there_are_undefined_syms
;
82 static void setfunc(bfd
*exe
, asection
*sect
, PTR setlist_ptr
)
84 parse_secname(sect
->name
, (setnode
**)setlist_ptr
);
87 void collect_sets(const char *file
, setnode
**setlist_ptr
)
95 (abfd
= bfd_openr(file
, "default")) == NULL
||
96 !bfd_check_format(abfd
, bfd_object
)
102 parse_format(abfd
->xvec
->name
);
103 bfd_map_over_sections(abfd
, setfunc
, setlist_ptr
);
108 static void collect_lib(asymbol
*sym
, setnode
**liblist_ptr
)
114 if (strncmp(sym
->name
, "__aros_libreq_", 14) != 0)
117 node
= xmalloc(sizeof(*node
)+strlen(sym
->name
)+1);
118 name
= (char *)(&node
[1]);
119 strcpy(name
, sym
->name
);
121 cp
= strchr(name
+ 14, '.');
124 pri
= strtoul(cp
+1, &tmp
, 0);
137 node
->secname
= name
;
138 node
->off_setname
= 14;
140 node
->next
= *liblist_ptr
;
144 void collect_libs(const char *file
, setnode
**liblist_ptr
)
149 /* We assume bfd_init() has already been colled by
155 (abfd
= bfd_openr(file
, "default")) == NULL
||
156 !bfd_check_format(abfd
, bfd_object
)
162 symtab_size
= bfd_get_symtab_upper_bound(abfd
);
163 if (symtab_size
> 0) {
167 symtab
= (asymbol
**)xmalloc(symtab_size
);
168 symbols
= bfd_canonicalize_symtab(abfd
, symtab
);
172 for (i
= 0; i
< symbols
; i
++)
173 collect_lib(symtab
[i
], liblist_ptr
);