+2005-02-11 Paul Brook <paul@codesourcery.com>
+
+ * elf-bfd.h (struct elf_link_hash_table): Add
+ is_relocatable_executable.
+ * elf.c (_bfd_elf_link_hash_table_init): Initialize it.
+ * elflink.c (bfd_elf_link_record_dynamic_symbol): Create local dynamic
+ symbols in relocatable executables.
+ (bfd_elf_record_link_assignment): Create dynamic section symbols in
+ relocatable executables.
+ (_bfd_elf_link_renumber_dynsyms): Ditto.
+ (bfd_elf_final_link): Ditto.
+ * elf32-arm.c (elf32_arm_final_link_relocate): Copy absolute
+ relocations into relocatable executables.
+ (elf32_arm_check_relocs): Crate dynamic sections for relocatable
+ executables. Also copy absolute relocations.
+ (elf32_arm_adjust_dynamic_symbol): Don't create copy relocations
+ in relocatable executables.
+ (allocate_dynrelocs): Copy relocations for relocatable executables.
+ Output dynamic symbols for symbols defined in linker scripts.
+
2005-02-11 Nick Clifton <nickc@redhat.com>
* libbfd.c (read_signed_leb128): Use an unsigned type for 'shift'
(bfd_vma) 0);
}
- /* When generating a shared object, these relocations are copied
- into the output file to be resolved at run time. */
- if (info->shared
+ /* When generating a shared object or relocatable executable, these
+ relocations are copied into the output file to be resolved at
+ run time. */
+ if ((info->shared || globals->root.is_relocatable_executable)
&& (input_section->flags & SEC_ALLOC)
&& (r_type != R_ARM_REL32
|| !SYMBOL_CALLS_LOCAL (info, h))
htab = elf32_arm_hash_table (info);
sreloc = NULL;
+ /* Create dynamic sections for relocatable executables so that we can
+ copy relocations. */
+ if (htab->root.is_relocatable_executable
+ && ! htab->root.dynamic_sections_created)
+ {
+ if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
+ return FALSE;
+ }
+
dynobj = elf_hash_table (info)->dynobj;
local_got_offsets = elf_local_got_offsets (abfd);
eh->plt_thumb_refcount += 1;
}
- /* If we are creating a shared library, and this is a reloc
- against a global symbol, or a non PC relative reloc
- against a local symbol, then we need to copy the reloc
- into the shared library. However, if we are linking with
- -Bsymbolic, we do not need to copy a reloc against a
+ /* If we are creating a shared library or relocatable executable,
+ and this is a reloc against a global symbol, or a non PC
+ relative reloc against a local symbol, then we need to copy
+ the reloc into the shared library. However, if we are linking
+ with -Bsymbolic, we do not need to copy a reloc against a
global symbol which is defined in an object we are
including in the link (i.e., DEF_REGULAR is set). At
this point we have not seen all the input files, so it is
later (it is never cleared). We account for that
possibility below by storing information in the
relocs_copied field of the hash table entry. */
- if (info->shared
+ if ((info->shared || htab->root.is_relocatable_executable)
&& (sec->flags & SEC_ALLOC) != 0
&& ((r_type != R_ARM_PC24
&& r_type != R_ARM_PLT32
asection * s;
unsigned int power_of_two;
struct elf32_arm_link_hash_entry * eh;
+ struct elf32_arm_link_hash_table *globals;
+ globals = elf32_arm_hash_table (info);
dynobj = elf_hash_table (info)->dynobj;
/* Make sure we know what is going on here. */
/* If we are creating a shared library, we must presume that the
only references to the symbol are via the global offset table.
For such cases we need not do anything here; the relocations will
- be handled correctly by relocate_section. */
- if (info->shared)
+ be handled correctly by relocate_section. Relocatable executables
+ can reference data in shared objects directly, so we don't need to
+ do anything here. */
+ if (info->shared || globals->root.is_relocatable_executable)
return TRUE;
/* We must allocate the symbol in our .dynbss section, which will
space for pc-relative relocs that have become local due to symbol
visibility changes. */
- if (info->shared)
+ if (info->shared || htab->root.is_relocatable_executable)
{
/* Discard relocs on undefined weak syms with non-default
visibility. */
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
&& h->root.type == bfd_link_hash_undefweak)
eh->relocs_copied = NULL;
+ else if (htab->root.is_relocatable_executable && h->dynindx == -1
+ && h->root.type == bfd_link_hash_new)
+ {
+ /* Output absolute symbols so that we can create relocations
+ against them. For normal symbols we output a relocation
+ against the section that contains them. */
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+
}
else
{
/* The PLT entries are each three instructions. */
htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry);
htab->symbian_p = 1;
+ htab->root.is_relocatable_executable = 1;
}
return ret;
}