X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=bfd%2Fecoff.c;h=45a378f858692ee18f55798fe7b19fda5c072d35;hb=aac6b32f3129e8a9b2856fd3fb80c4613bddd455;hp=64661cdd18321d3fd46e0d4d43f121f906f1af39;hpb=30f34d07c74ca1cc7a2aae4ff58f31d8046cd9a1;p=binutils-gdb.git diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 64661cdd183..45a378f8586 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -412,7 +412,7 @@ ecoff_styp_to_sec_flags (abfd, hdr) void ecoff_swap_tir_in (bigend, ext_copy, intern) int bigend; - struct tir_ext *ext_copy; + const struct tir_ext *ext_copy; TIR *intern; { struct tir_ext ext[1]; @@ -469,7 +469,7 @@ ecoff_swap_tir_in (bigend, ext_copy, intern) void ecoff_swap_tir_out (bigend, intern_copy, ext) int bigend; - TIR *intern_copy; + const TIR *intern_copy; struct tir_ext *ext; { TIR intern[1]; @@ -525,7 +525,7 @@ ecoff_swap_tir_out (bigend, intern_copy, ext) void ecoff_swap_rndx_in (bigend, ext_copy, intern) int bigend; - struct rndx_ext *ext_copy; + const struct rndx_ext *ext_copy; RNDXR *intern; { struct rndx_ext ext[1]; @@ -564,7 +564,7 @@ ecoff_swap_rndx_in (bigend, ext_copy, intern) void ecoff_swap_rndx_out (bigend, intern_copy, ext) int bigend; - RNDXR *intern_copy; + const RNDXR *intern_copy; struct rndx_ext *ext; { RNDXR intern[1]; @@ -665,11 +665,15 @@ ecoff_slurp_symbolic_header (abfd) } /* Read in and swap the important symbolic information for an ECOFF - object file. This is called by gdb. */ + object file. This is called by gdb via the read_debug_info entry + point in the backend structure. */ +/*ARGSUSED*/ boolean -ecoff_slurp_symbolic_info (abfd) +ecoff_slurp_symbolic_info (abfd, ignore, debug) bfd *abfd; + asection *ignore; + struct ecoff_debug_info *debug; { const struct ecoff_backend_data * const backend = ecoff_backend (abfd); HDRR *internal_symhdr; @@ -683,6 +687,8 @@ ecoff_slurp_symbolic_info (abfd) bfd_size_type raw_end; bfd_size_type cb_end; + BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info); + /* Check whether we've already gotten it, and whether there's any to get. */ if (ecoff_data (abfd)->raw_syments != (PTR) NULL) @@ -696,7 +702,7 @@ ecoff_slurp_symbolic_info (abfd) if (! ecoff_slurp_symbolic_header (abfd)) return false; - internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header; + internal_symhdr = &debug->symbolic_header; /* Read all the symbolic information at once. */ raw_base = (ecoff_data (abfd)->sym_filepos @@ -756,11 +762,11 @@ ecoff_slurp_symbolic_info (abfd) /* Get pointers for the numeric offsets in the HDRR structure. */ #define FIX(off1, off2, type) \ if (internal_symhdr->off1 == 0) \ - ecoff_data (abfd)->debug_info.off2 = (type) NULL; \ + debug->off2 = (type) NULL; \ else \ - ecoff_data (abfd)->debug_info.off2 = (type) ((char *) raw \ - + internal_symhdr->off1 \ - - raw_base) + debug->off2 = (type) ((char *) raw \ + + internal_symhdr->off1 \ + - raw_base) FIX (cbLineOffset, line, unsigned char *); FIX (cbDnOffset, external_dnr, PTR); FIX (cbPdOffset, external_pdr, PTR); @@ -782,18 +788,17 @@ ecoff_slurp_symbolic_info (abfd) We need to look at the fdr to deal with a lot of information in the symbols, so we swap them here. */ - ecoff_data (abfd)->debug_info.fdr = - (struct fdr *) bfd_alloc (abfd, - (internal_symhdr->ifdMax * - sizeof (struct fdr))); - if (ecoff_data (abfd)->debug_info.fdr == NULL) + debug->fdr = (struct fdr *) bfd_alloc (abfd, + (internal_symhdr->ifdMax * + sizeof (struct fdr))); + if (debug->fdr == NULL) { bfd_set_error (bfd_error_no_memory); return false; } external_fdr_size = backend->debug_swap.external_fdr_size; - fdr_ptr = ecoff_data (abfd)->debug_info.fdr; - fraw_src = (char *) ecoff_data (abfd)->debug_info.external_fdr; + fdr_ptr = debug->fdr; + fraw_src = (char *) debug->external_fdr; fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size; for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++) (*backend->debug_swap.swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr); @@ -1128,7 +1133,8 @@ ecoff_slurp_symbol_table (abfd) return true; /* Get the symbolic information. */ - if (ecoff_slurp_symbolic_info (abfd) == false) + if (! ecoff_slurp_symbolic_info (abfd, (asection *) NULL, + &ecoff_data (abfd)->debug_info)) return false; if (bfd_get_symcount (abfd) == 0) return true; @@ -1211,7 +1217,8 @@ long ecoff_get_symtab_upper_bound (abfd) bfd *abfd; { - if (! ecoff_slurp_symbolic_info (abfd)) + if (! ecoff_slurp_symbolic_info (abfd, (asection *) NULL, + &ecoff_data (abfd)->debug_info)) return -1; if (bfd_get_symcount (abfd) == 0) @@ -2020,7 +2027,8 @@ ecoff_find_nearest_line (abfd, return false; /* Make sure we have the FDR's. */ - if (ecoff_slurp_symbolic_info (abfd) == false + if (! ecoff_slurp_symbolic_info (abfd, (asection *) NULL, + &ecoff_data (abfd)->debug_info) || bfd_get_symcount (abfd) == 0) return false; @@ -2918,11 +2926,10 @@ ecoff_write_object_contents (abfd) goto error_return; /* Build the external symbol information. This must be done before - writing out the relocs so that we know the symbol indices. The - condition checks makes sure this object was not created by - ecoff_bfd_final_link, since if it was we do not want to tamper - with the external symbols. */ - if (bfd_get_outsymbols (abfd) != (asymbol **) NULL) + writing out the relocs so that we know the symbol indices. We + don't do this if this BFD was created by the backend linker, + since it will have already handled the symbols and relocs. */ + if (! ecoff_data (abfd)->linker) { symhdr->iextMax = 0; symhdr->issExtMax = 0; @@ -3576,6 +3583,8 @@ ecoff_link_hash_newfunc (entry, table, string) /* Set local fields. */ ret->indx = -1; ret->abfd = NULL; + ret->written = 0; + ret->small = 0; } memset ((PTR) &ret->esym, 0, sizeof ret->esym); @@ -4172,6 +4181,25 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext) h->abfd = abfd; h->esym = esym; } + + /* Remember whether this symbol was small undefined. */ + if (esym.asym.sc == scSUndefined) + h->small = 1; + + /* If this symbol was ever small undefined, it needs to wind + up in a GP relative section. We can't control the + section of a defined symbol, but we can control the + section of a common symbol. This case is actually needed + on Ultrix 4.2 to handle the symbol cred in -lckrb. */ + if (h->small + && h->root.type == bfd_link_hash_common + && strcmp (h->root.u.c.section->name, SCOMMON) != 0) + { + h->root.u.c.section = bfd_make_section_old_way (abfd, SCOMMON); + h->root.u.c.section->flags = SEC_ALLOC; + if (h->esym.asym.sc == scCommon) + h->esym.asym.sc = scSCommon; + } } } @@ -4388,6 +4416,8 @@ ecoff_bfd_final_link (abfd, info) bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax; + ecoff_data (abfd)->linker = true; + return true; } @@ -4505,7 +4535,7 @@ ecoff_link_write_external (h, data) /* FIXME: We should check if this symbol is being stripped. */ - if (h->root.written) + if (h->written) return true; if (h->abfd == (bfd *) NULL) @@ -4606,7 +4636,7 @@ ecoff_link_write_external (h, data) /* bfd_ecoff_debug_one_external uses iextMax to keep track of the symbol number. */ h->indx = ecoff_data (output_bfd)->debug_info.symbolic_header.iextMax; - h->root.written = true; + h->written = 1; return (bfd_ecoff_debug_one_external (output_bfd, &ecoff_data (output_bfd)->debug_info,