From: Hans-Peter Nilsson Date: Tue, 24 Mar 2009 07:57:21 +0000 (+0000) Subject: * elf32-cris.c (cris_elf_relocate_section): : Allow use of non-local symbols for non-allocated sections. Don't check whether to generate R_CRIS_DTPMOD for non-allocated sections. (cris_elf_gc_sweep_hook) : Don't handle relocation GC:ing if applied to non-allocated section. (cris_elf_check_relocs): Similar. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8336ac42928..ea96f891e58 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,13 @@ 2009-03-24 Hans-Peter Nilsson + * elf32-cris.c (cris_elf_relocate_section): : Allow use of non-local + symbols for non-allocated sections. Don't check whether to + generate R_CRIS_DTPMOD for non-allocated sections. + (cris_elf_gc_sweep_hook) : Don't + handle relocation GC:ing if applied to non-allocated section. + (cris_elf_check_relocs): Similar. + * elf32-cris.c (cris_elf_relocate_section) : Don't include the TLS size when emitting a known TP offset in the GOT. diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 6dc669a4939..ed1f3e8d503 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -1615,10 +1615,12 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, case R_CRIS_16_DTPREL: case R_CRIS_32_DTPREL: /* This relocation must only be performed against local - symbols. It's also ok when we link a program and the - symbol is defined in an ordinary (non-DSO) object (if - it's undefined there, we've already seen an error). */ + symbols, or to sections that are not loadable. It's also + ok when we link a program and the symbol is defined in an + ordinary (non-DSO) object (if it's undefined there, we've + already seen an error). */ if (h != NULL + && (input_section->flags & SEC_ALLOC) != 0 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && (info->shared || (!h->def_regular @@ -1641,14 +1643,16 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, return FALSE; } - BFD_ASSERT (elf_cris_hash_table (info)->dtpmod_refcount != 0); + BFD_ASSERT ((input_section->flags & SEC_ALLOC) == 0 + || elf_cris_hash_table (info)->dtpmod_refcount != 0); /* Fill in a R_CRIS_DTPMOD reloc at offset 3 if we haven't already done so. Note that we do this in .got.plt, not in .got, as .got.plt contains the first part, still the reloc is against .got, because the linker script directs (is required to direct) them both into .got. */ - if (elf_cris_hash_table (info)->dtpmod_refcount > 0) + if (elf_cris_hash_table (info)->dtpmod_refcount > 0 + && (input_section->flags & SEC_ALLOC) != 0) { asection *sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (sgotplt != NULL); @@ -2684,6 +2688,10 @@ cris_elf_gc_sweep_hook (bfd *abfd, break; case R_CRIS_32_DTPREL: + /* This'd be a .dtpreld entry in e.g. debug info. */ + if ((sec->flags & SEC_ALLOC) == 0) + break; + /* Fall through. */ case R_CRIS_16_DTPREL: elf_cris_hash_table (info)->dtpmod_refcount--; if (elf_cris_hash_table (info)->dtpmod_refcount == 0) @@ -3151,8 +3159,17 @@ cris_elf_check_relocs (abfd, info, sec, relocs) on the first input bfd we found that contained dynamic relocs. */ switch (r_type) { - case R_CRIS_16_DTPREL: case R_CRIS_32_DTPREL: + if ((sec->flags & SEC_ALLOC) == 0) + /* This'd be a .dtpreld entry in e.g. debug info. We have + several different switch statements below, but none of + that is needed; we need no preparations for resolving + R_CRIS_32_DTPREL into a non-allocated section (debug + info), so let's just move on to the next + relocation. */ + continue; + /* Fall through. */ + case R_CRIS_16_DTPREL: /* The first .got.plt entry is right after the R_CRIS_DTPMOD entry at index 3. */ if (elf_cris_hash_table (info)->dtpmod_refcount == 0)