From aad2c618d3e074fe49d42bf79d7f9375c85567ec Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 27 Oct 1995 03:36:17 +0000 Subject: more XCOFF linker tweaks --- bfd/xcofflink.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'bfd/xcofflink.c') diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 8dedde0..843dc06 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -603,7 +603,8 @@ xcoff_read_internal_relocs (abfd, sec, cache, external_relocs, if (enclosing != NULL && (coff_section_data (abfd, enclosing) == NULL || coff_section_data (abfd, enclosing)->relocs == NULL) - && cache) + && cache + && enclosing->reloc_count > 0) { if (_bfd_coff_read_internal_relocs (abfd, enclosing, true, external_relocs, false, @@ -1478,6 +1479,7 @@ xcoff_link_add_symbols (abfd, info) if (sym.n_sclass == C_EXT) { csect->flags |= SEC_IS_COMMON; + csect->_raw_size = 0; section = csect; value = aux.x_csect.x_scnlen.l; } @@ -1533,7 +1535,7 @@ xcoff_link_add_symbols (abfd, info) if (! (_bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, - (const char *) NULL, copy, false, + (const char *) NULL, copy, true, (struct bfd_link_hash_entry **) sym_hash))) goto error_return; @@ -1640,7 +1642,7 @@ xcoff_link_add_symbols (abfd, info) (info, abfd, hds->root.root.string, (flagword) 0, bfd_und_section_ptr, (bfd_vma) 0, (const char *) NULL, false, - false, + true, (struct bfd_link_hash_entry **) NULL))) goto error_return; } @@ -2578,6 +2580,18 @@ xcoff_build_ldsyms (h, p) } } + /* If this is still a common symbol, and it wasn't garbage + collected, we need to actually allocate space for it in the .bss + section. */ + if (h->root.type == bfd_link_hash_common + && (! xcoff_hash_table (ldinfo->info)->gc + || (h->flags & XCOFF_MARK) != 0) + && h->root.u.c.p->section->_raw_size == 0) + { + BFD_ASSERT (bfd_is_com_section (h->root.u.c.p->section)); + h->root.u.c.p->section->_raw_size = h->root.u.c.size; + } + /* We need to add a symbol to the .loader section if it is mentioned in a reloc which we are copying to the .loader section and it was not defined or common, or if it is the entry point. */ @@ -4792,6 +4806,14 @@ _bfd_ppc_xcoff_relocate_section (output_bfd, info, input_bfd, + sec->output_section->vma + sec->output_offset); } + else if (h->root.type == bfd_link_hash_common) + { + asection *sec; + + sec = h->root.u.c.p->section; + val = (sec->output_section->vma + + sec->output_offset); + } else if ((h->flags & XCOFF_REF_DYNAMIC) != 0 || (h->flags & XCOFF_IMPORT) != 0) { -- cgit v1.1