From 372170607324f200e993f356448225cb3474d58e Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 29 Nov 1991 20:31:57 +0000 Subject: [PATCH] Two small bug-fixes (affecting ar and nm). --- bfd/ChangeLog | 10 ++-- bfd/archive.c | 147 ++++++++++++++++++++++++++------------------------ bfd/syms.c | 10 +--- 3 files changed, 87 insertions(+), 80 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 36934ba9ae9..7172bf6449d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +Fri Nov 29 12:16:51 1991 Per Bothner (bothner at cygnus.com) + + * syms.c (bfd_decode_symclass): Return 'A' + for symbols that are both absolute and global. + * archive.c (bfd_special_undocumented_glue): Return NULL + if bfd_ar_hdr_from_filesystem returns NULL. + Tue Nov 26 09:10:55 1991 Steve Chamberlain (sac at cygnus.com) * Makefile.in: added coff-h8300 @@ -13,9 +20,6 @@ Tue Nov 26 09:10:55 1991 Steve Chamberlain (sac at cygnus.com) handled, from the nest of #ifdefs to macros defined in the including coff-.c - - - Fri Nov 22 08:11:42 1991 John Gilmore (gnu at cygnus.com) * aoutx.h (some_aout_object_p): Set the `executable' bit diff --git a/bfd/archive.c b/bfd/archive.c index 17ee03bb763..efd18a3f5b8 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -827,8 +827,10 @@ DEFUN(bfd_special_undocumented_glue, (abfd, filename), bfd *abfd AND char *filename) { - - return (struct ar_hdr *) bfd_ar_hdr_from_filesystem (abfd, filename) -> arch_header; + struct areltdata *ar_elt = bfd_ar_hdr_from_filesystem (abfd, filename); + if (ar_elt == NULL) + return NULL; + return (struct ar_hdr *) ar_elt->arch_header; } @@ -1076,80 +1078,87 @@ compute_and_write_armap (arch, elength) bfd *arch; unsigned int elength; { - bfd *current; - file_ptr elt_no = 0; - struct orl *map; - int orl_max = 15000; /* fine initial default */ - int orl_count = 0; - int stridx = 0; /* string index */ - - /* Dunno if this is the best place for this info... */ - if (elength != 0) elength += sizeof (struct ar_hdr); - elength += elength %2 ; - - map = (struct orl *) bfd_zalloc (arch,orl_max * sizeof (struct orl)); - if (map == NULL) { - bfd_error = no_memory; - return false; - } + bfd *current; + file_ptr elt_no = 0; + struct orl *map; + int orl_max = 15000; /* fine initial default */ + int orl_count = 0; + int stridx = 0; /* string index */ + + /* Dunno if this is the best place for this info... */ + if (elength != 0) elength += sizeof (struct ar_hdr); + elength += elength %2 ; + + map = (struct orl *) bfd_zalloc (arch,orl_max * sizeof (struct orl)); + if (map == NULL) { + bfd_error = no_memory; + return false; + } - /* Map over each element */ - for (current = arch->archive_head; - current != (bfd *)NULL; - current = current->next, elt_no++) - { + /* Drop all the files called __.SYMDEF, we're going to make our + own */ + while (arch->archive_head && + strcmp(arch->archive_head->filename,"__.SYMDEF") == 0) + { + arch->archive_head = arch->archive_head->next; + } + /* Map over each element */ + for (current = arch->archive_head; + current != (bfd *)NULL; + current = current->next, elt_no++) + { if ((bfd_check_format (current, bfd_object) == true) && ((bfd_get_file_flags (current) & HAS_SYMS))) { - asymbol **syms; - unsigned int storage; - unsigned int symcount; - unsigned int src_count; - - storage = get_symtab_upper_bound (current); - if (storage != 0) { - - syms = (asymbol **) bfd_zalloc (arch,storage); - if (syms == NULL) { - bfd_error = no_memory; /* FIXME -- memory leak */ - return false; - } - symcount = bfd_canonicalize_symtab (current, syms); - - - /* Now map over all the symbols, picking out the ones we want */ - for (src_count = 0; src_count flags; - if ((flags & BSF_GLOBAL) || - (flags & BSF_FORT_COMM)) { - - /* This symbol will go into the archive header */ - if (orl_count == orl_max) - { - orl_max *= 2; - map = (struct orl *) bfd_realloc (arch, (char *) map, - orl_max * sizeof (struct orl)); + asymbol **syms; + unsigned int storage; + unsigned int symcount; + unsigned int src_count; + + storage = get_symtab_upper_bound (current); + if (storage != 0) { + + syms = (asymbol **) bfd_zalloc (arch,storage); + if (syms == NULL) { + bfd_error = no_memory; /* FIXME -- memory leak */ + return false; + } + symcount = bfd_canonicalize_symtab (current, syms); + + + /* Now map over all the symbols, picking out the ones we want */ + for (src_count = 0; src_count flags; + if ((flags & BSF_GLOBAL) || + (flags & BSF_FORT_COMM)) { + + /* This symbol will go into the archive header */ + if (orl_count == orl_max) + { + orl_max *= 2; + map = (struct orl *) bfd_realloc (arch, (char *) map, + orl_max * sizeof (struct orl)); + } + + (map[orl_count]).name = (char **) &((syms[src_count])->name); + (map[orl_count]).pos = (file_ptr) current; + (map[orl_count]).namidx = stridx; + + stridx += strlen ((syms[src_count])->name) + 1; + ++orl_count; + } + } } - - (map[orl_count]).name = (char **) &((syms[src_count])->name); - (map[orl_count]).pos = (file_ptr) current; - (map[orl_count]).namidx = stridx; - - stridx += strlen ((syms[src_count])->name) + 1; - ++orl_count; - } } - } - } - } - /* OK, now we have collected all the data, let's write them out */ - if (!BFD_SEND (arch, write_armap, - (arch, elength, map, orl_count, stridx))) { + } + /* OK, now we have collected all the data, let's write them out */ + if (!BFD_SEND (arch, write_armap, + (arch, elength, map, orl_count, stridx))) { - return false; - } + return false; + } - return true; + return true; } boolean @@ -1157,7 +1166,7 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) bfd *arch; unsigned int elength; struct orl *map; - int orl_count; + unsigned int orl_count; int stridx; { unsigned int ranlibsize = orl_count * sizeof (struct ranlib); diff --git a/bfd/syms.c b/bfd/syms.c index f791c060a69..c6a2b39f8cb 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -383,16 +383,10 @@ asymbol *symbol) { flagword flags = symbol->flags; -#if 0 - if ((symbol->value == 0) && (symbol->section != NULL)) - /* Huh? All section names don't begin with "." */ - return (symbol->section->name)[1]; -#endif - if (flags & BSF_FORT_COMM) return 'C'; if (flags & BSF_UNDEFINED) return 'U'; - if (flags & BSF_ABSOLUTE) return 'a'; - + if (flags & BSF_ABSOLUTE) + return (flags & BSF_GLOBAL) ? 'A' : 'a'; if ( flags & (BSF_GLOBAL|BSF_LOCAL) ) { if (symbol->section == (asection *)NULL) -- 2.30.2