X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fsyms.c;h=c1de8ebab17c5e7633357d765c0dcc60ca308b9e;hb=340f3ac8082771ecc473ab938fc3d7cbf607ddaa;hp=4d532b2cd21cfc99731cf8e6860cb2d0861e6028;hpb=ed48ec2e6ec5514f01b9b3a810d6ddf39651114b;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/syms.c b/bfd/syms.c index 4d532b2cd2..c1de8ebab1 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -1,5 +1,5 @@ /* Generic symbol-table support for the BFD library. - Copyright (C) 1990-2019 Free Software Foundation, Inc. + Copyright (C) 1990-2020 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -538,7 +538,7 @@ DESCRIPTION asymbol * _bfd_generic_make_empty_symbol (bfd *abfd) { - bfd_size_type amt = sizeof (asymbol); + size_t amt = sizeof (asymbol); asymbol *new_symbol = (asymbol *) bfd_zalloc (abfd, amt); if (new_symbol) new_symbol->the_bfd = abfd; @@ -565,30 +565,15 @@ struct section_to_type char type; }; -/* Map section names to POSIX/BSD single-character symbol types. +/* Map special section names to POSIX/BSD single-character symbol types. This table is probably incomplete. It is sorted for convenience of adding entries. Since it is so short, a linear search is used. */ static const struct section_to_type stt[] = { - {".bss", 'b'}, - {"code", 't'}, /* MRI .text */ - {".data", 'd'}, - {"*DEBUG*", 'N'}, - {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ {".drectve", 'i'}, /* MSVC's .drective section */ {".edata", 'e'}, /* MSVC's .edata (export) section */ - {".fini", 't'}, /* ELF fini section */ {".idata", 'i'}, /* MSVC's .idata (import) section */ - {".init", 't'}, /* ELF init section */ {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ - {".rdata", 'r'}, /* Read only data. */ - {".rodata", 'r'}, /* Read only data. */ - {".sbss", 's'}, /* Small BSS (uninitialized data). */ - {".scommon", 'c'}, /* Small common. */ - {".sdata", 'g'}, /* Small initialized data. */ - {".text", 't'}, - {"vars", 'd'}, /* MRI .data */ - {"zerovars", 'b'}, /* MRI .bss */ {0, 0} }; @@ -596,8 +581,7 @@ static const struct section_to_type stt[] = section S, or '?' for an unknown COFF section. Check for leading strings which match, followed by a number, '.', - or '$' so .text5 matches the .text entry, but .init_array doesn't - match the .init entry. */ + or '$' so .idata5 matches the .idata entry. */ static char coff_section_type (const char *s) @@ -619,7 +603,7 @@ coff_section_type (const char *s) SECTION, or '?' for an unknown section. This uses section flags to identify sections. - FIXME These types are unhandled: c, i, e, p. If we handled these also, + FIXME These types are unhandled: e, i, p. If we handled these also, we could perhaps obsolete coff_section_type. */ static char @@ -668,7 +652,12 @@ bfd_decode_symclass (asymbol *symbol) char c; if (symbol->section && bfd_is_com_section (symbol->section)) - return 'C'; + { + if (symbol->section == bfd_com_section_ptr) + return 'C'; + else + return 'c'; + } if (bfd_is_und_section (symbol->section)) { if (symbol->flags & BSF_WEAK) @@ -705,9 +694,9 @@ bfd_decode_symclass (asymbol *symbol) c = 'a'; else if (symbol->section) { - c = decode_section_type (symbol->section); + c = coff_section_type (symbol->section->name); if (c == '?') - c = coff_section_type (symbol->section->name); + c = decode_section_type (symbol->section); } else return '?'; @@ -884,6 +873,7 @@ struct indexentry char *directory_name; char *file_name; char *function_name; + int idx; }; /* Compare two indexentry structures. This is called via qsort. */ @@ -896,10 +886,9 @@ cmpindexentry (const void *a, const void *b) if (contestantA->val < contestantB->val) return -1; - else if (contestantA->val > contestantB->val) + if (contestantA->val > contestantB->val) return 1; - else - return 0; + return contestantA->idx - contestantB->idx; } /* A pointer to this structure is stored in *pinfo. */ @@ -1078,19 +1067,21 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, arelent *r; unsigned long val; asymbol *sym; + bfd_size_type octets; r = *pr; /* Ignore R_*_NONE relocs. */ if (r->howto->dst_mask == 0) continue; + octets = r->address * bfd_octets_per_byte (abfd, NULL); if (r->howto->rightshift != 0 || r->howto->size != 2 || r->howto->bitsize != 32 || r->howto->pc_relative || r->howto->bitpos != 0 || r->howto->dst_mask != 0xffffffff - || r->address * bfd_octets_per_byte (abfd) + 4 > stabsize) + || octets + 4 > stabsize) { _bfd_error_handler (_("unsupported .stab relocation")); @@ -1100,13 +1091,11 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, return FALSE; } - val = bfd_get_32 (abfd, info->stabs - + r->address * bfd_octets_per_byte (abfd)); + val = bfd_get_32 (abfd, info->stabs + octets); val &= r->howto->src_mask; sym = *r->sym_ptr_ptr; val += sym->value + sym->section->vma + r->addend; - bfd_put_32 (abfd, (bfd_vma) val, info->stabs - + r->address * bfd_octets_per_byte (abfd)); + bfd_put_32 (abfd, (bfd_vma) val, info->stabs + octets); } } @@ -1198,6 +1187,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, info->indextable[i].directory_name = directory_name; info->indextable[i].file_name = file_name; info->indextable[i].function_name = NULL; + info->indextable[i].idx = i; ++i; } @@ -1257,6 +1247,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, info->indextable[i].directory_name = directory_name; info->indextable[i].file_name = file_name; info->indextable[i].function_name = function_name; + info->indextable[i].idx = i; ++i; break; } @@ -1270,6 +1261,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, info->indextable[i].directory_name = directory_name; info->indextable[i].file_name = file_name; info->indextable[i].function_name = NULL; + info->indextable[i].idx = i; ++i; } @@ -1279,6 +1271,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, info->indextable[i].directory_name = NULL; info->indextable[i].file_name = NULL; info->indextable[i].function_name = NULL; + info->indextable[i].idx = i; ++i; info->indextablesize = i; @@ -1290,7 +1283,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd, /* We are passed a section relative offset. The offsets in the stabs information are absolute. */ - offset += bfd_get_section_vma (abfd, section); + offset += bfd_section_vma (section); #ifdef ENABLE_CACHING if (info->cached_indexentry != NULL