if (info->relocatable)
return TRUE;
+ /* Don't do anything special with non-loaded, non-alloced sections.
+ In particular, any relocs in such sections should not affect GOT
+ and PLT reference counting (ie. we don't allow them to create GOT
+ or PLT entries), there's no possibility or desire to optimize TLS
+ relocs, and there's not much point in propagating relocs to shared
+ libs that the dynamic linker won't relocate. */
+ if ((sec->flags & SEC_ALLOC) == 0)
+ return TRUE;
+
#ifdef DEBUG
_bfd_error_handler ("ppc_elf_check_relocs called for section %A in %B",
sec, abfd);
|| !h->def_regular))))
|| (ELIMINATE_COPY_RELOCS
&& !info->shared
- && (sec->flags & SEC_ALLOC) != 0
&& h != NULL
&& (h->root.type == bfd_link_hash_defweak
|| !h->def_regular)))
sreloc = bfd_make_section (htab->elf.dynobj, name);
flags = (SEC_HAS_CONTENTS | SEC_READONLY
- | SEC_IN_MEMORY | SEC_LINKER_CREATED);
- if ((sec->flags & SEC_ALLOC) != 0)
- flags |= SEC_ALLOC | SEC_LOAD;
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_ALLOC | SEC_LOAD);
if (sreloc == NULL
|| ! bfd_set_section_flags (htab->elf.dynobj,
sreloc, flags)
bfd_signed_vma *local_got_refcounts;
const Elf_Internal_Rela *rel, *relend;
+ if ((sec->flags & SEC_ALLOC) == 0)
+ return TRUE;
+
elf_section_data (sec)->local_dynrel = NULL;
htab = ppc_elf_hash_table (info);
*again = FALSE;
- /* Nothing to do if there are no relocations. */
- if ((isec->flags & SEC_RELOC) == 0 || isec->reloc_count == 0)
+ /* Nothing to do if there are no relocations, and no need to do
+ anything with non-alloc sections. */
+ if ((isec->flags & SEC_ALLOC) == 0
+ || (isec->flags & SEC_RELOC) == 0
+ || isec->reloc_count == 0)
return TRUE;
trampoff = (isec->size + 3) & (bfd_vma) -4;
return FALSE;
}
\f
-/* Set SYM_NAME to VAL if the symbol exists and is undefined. */
-
-static void
-set_linker_sym (struct ppc_elf_link_hash_table *htab,
- const char *sym_name,
- bfd_vma val)
-{
- struct elf_link_hash_entry *h;
- h = elf_link_hash_lookup (&htab->elf, sym_name, FALSE, FALSE, FALSE);
- if (h != NULL && h->root.type == bfd_link_hash_undefined)
- {
- h->root.type = bfd_link_hash_defined;
- h->root.u.def.section = bfd_abs_section_ptr;
- h->root.u.def.value = val;
- h->def_regular = 1;
- h->type = STT_OBJECT;
- h->other = STV_HIDDEN;
- }
-}
-
/* Set _SDA_BASE_, _SDA2_BASE, and sbss start and end syms. They are
set here rather than via PROVIDE in the default linker script,
because using PROVIDE inside an output section statement results in
val = s->vma + 32768;
lsect->sym_val = val;
- set_linker_sym (htab, lsect->sym_name, val);
+ _bfd_elf_provide_symbol (info, lsect->sym_name, val);
}
s = bfd_get_section_by_name (obfd, ".sbss");
val = 0;
if (s != NULL)
val = s->vma;
- set_linker_sym (htab, "__sbss_start", val);
- set_linker_sym (htab, "___sbss_start", val);
+ _bfd_elf_provide_symbol (info, "__sbss_start", val);
+ _bfd_elf_provide_symbol (info, "___sbss_start", val);
if (s != NULL)
val += s->size;
- set_linker_sym (htab, "__sbss_end", val);
- set_linker_sym (htab, "___sbss_end", val);
+ _bfd_elf_provide_symbol (info, "__sbss_end", val);
+ _bfd_elf_provide_symbol (info, "___sbss_end", val);
return TRUE;
}
\f
{
sym = local_syms + r_symndx;
sec = local_sections[r_symndx];
- sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym);
+ sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec);
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
}
break;
/* Fall thru. */
+ if ((input_section->flags & SEC_ALLOC) == 0)
+ break;
+ /* Fall thru. */
+
if ((info->shared
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| !SYMBOL_CALLS_LOCAL (info, h)))
|| (ELIMINATE_COPY_RELOCS
&& !info->shared
- && (input_section->flags & SEC_ALLOC) != 0
&& h != NULL
&& h->dynindx != -1
&& !h->non_got_ref
if (r != bfd_reloc_ok)
{
- if (sym_name == NULL)
- sym_name = "(null)";
if (r == bfd_reloc_overflow)
{
if (warned)