Line 1... |
Line 1... |
/* SuperH SH64-specific support for 64-bit ELF
|
/* SuperH SH64-specific support for 64-bit ELF
|
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
Line 1723... |
Line 1723... |
are copied into the output file to be resolved at run
|
are copied into the output file to be resolved at run
|
time. */
|
time. */
|
|
|
if (sreloc == NULL)
|
if (sreloc == NULL)
|
{
|
{
|
const char *name;
|
sreloc = _bfd_elf_get_dynamic_reloc_section
|
|
(input_bfd, input_section, /*rela?*/ TRUE);
|
name = (bfd_elf_string_from_elf_section
|
if (sreloc == NULL)
|
(input_bfd,
|
|
elf_elfheader (input_bfd)->e_shstrndx,
|
|
elf_section_data (input_section)->rel_hdr.sh_name));
|
|
if (name == NULL)
|
|
return FALSE;
|
return FALSE;
|
|
|
BFD_ASSERT (CONST_STRNEQ (name, ".rela")
|
|
&& strcmp (bfd_get_section_name (input_bfd,
|
|
input_section),
|
|
name + 5) == 0);
|
|
|
|
sreloc = bfd_get_section_by_name (dynobj, name);
|
|
BFD_ASSERT (sreloc != NULL);
|
|
}
|
}
|
|
|
skip = FALSE;
|
skip = FALSE;
|
relocate = FALSE;
|
relocate = FALSE;
|
|
|
Line 2193... |
Line 2181... |
{
|
{
|
asection *isec;
|
asection *isec;
|
|
|
if (isymp->st_shndx == SHN_UNDEF)
|
if (isymp->st_shndx == SHN_UNDEF)
|
isec = bfd_und_section_ptr;
|
isec = bfd_und_section_ptr;
|
else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
|
|
isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
|
|
else if (isymp->st_shndx == SHN_ABS)
|
else if (isymp->st_shndx == SHN_ABS)
|
isec = bfd_abs_section_ptr;
|
isec = bfd_abs_section_ptr;
|
else if (isymp->st_shndx == SHN_COMMON)
|
else if (isymp->st_shndx == SHN_COMMON)
|
isec = bfd_com_section_ptr;
|
isec = bfd_com_section_ptr;
|
else
|
else
|
{
|
isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
|
/* Who knows? */
|
|
isec = NULL;
|
|
}
|
|
|
|
*secpp = isec;
|
*secpp = isec;
|
}
|
}
|
|
|
if (! sh_elf64_relocate_section (output_bfd, link_info, input_bfd,
|
if (! sh_elf64_relocate_section (output_bfd, link_info, input_bfd,
|
Line 2714... |
Line 2697... |
/* When creating a shared object, we must copy these
|
/* When creating a shared object, we must copy these
|
reloc types into the output file. We create a reloc
|
reloc types into the output file. We create a reloc
|
section in dynobj and make room for this reloc. */
|
section in dynobj and make room for this reloc. */
|
if (sreloc == NULL)
|
if (sreloc == NULL)
|
{
|
{
|
const char *name;
|
sreloc = _bfd_elf_make_dynamic_reloc_section
|
|
(sec, dynobj, 2, abfd, /*rela?*/ TRUE);
|
|
|
name = (bfd_elf_string_from_elf_section
|
|
(abfd,
|
|
elf_elfheader (abfd)->e_shstrndx,
|
|
elf_section_data (sec)->rel_hdr.sh_name));
|
|
if (name == NULL)
|
|
return FALSE;
|
|
|
|
BFD_ASSERT (CONST_STRNEQ (name, ".rela")
|
|
&& strcmp (bfd_get_section_name (abfd, sec),
|
|
name + 5) == 0);
|
|
|
|
sreloc = bfd_get_section_by_name (dynobj, name);
|
|
if (sreloc == NULL)
|
if (sreloc == NULL)
|
{
|
|
flagword flags;
|
|
|
|
flags = (SEC_HAS_CONTENTS | SEC_READONLY
|
|
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
|
|
if ((sec->flags & SEC_ALLOC) != 0)
|
|
flags |= SEC_ALLOC | SEC_LOAD;
|
|
sreloc = bfd_make_section_with_flags (dynobj,
|
|
name,
|
|
flags);
|
|
if (sreloc == NULL
|
|
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
|
|
return FALSE;
|
return FALSE;
|
}
|
}
|
}
|
|
|
|
sreloc->size += sizeof (Elf64_External_Rela);
|
sreloc->size += sizeof (Elf64_External_Rela);
|
|
|
/* If we are linking with -Bsymbolic, and this is a
|
/* If we are linking with -Bsymbolic, and this is a
|
global symbol, we count the number of PC relative
|
global symbol, we count the number of PC relative
|
Line 2918... |
Line 2877... |
DataLabel references, a relation that is not visible to the linker.
|
DataLabel references, a relation that is not visible to the linker.
|
Since no stripping of global symbols in done when doing such linking,
|
Since no stripping of global symbols in done when doing such linking,
|
we don't need to look up and make sure to emit the main symbol for each
|
we don't need to look up and make sure to emit the main symbol for each
|
DataLabel symbol. */
|
DataLabel symbol. */
|
|
|
static bfd_boolean
|
static int
|
sh64_elf64_link_output_symbol_hook (struct bfd_link_info *info,
|
sh64_elf64_link_output_symbol_hook (struct bfd_link_info *info,
|
const char *cname,
|
const char *cname,
|
Elf_Internal_Sym *sym,
|
Elf_Internal_Sym *sym,
|
asection *input_sec ATTRIBUTE_UNUSED,
|
asection *input_sec ATTRIBUTE_UNUSED,
|
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
|
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
|
Line 2933... |
Line 2892... |
{
|
{
|
if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL)
|
if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL)
|
name[strlen (name) - strlen (DATALABEL_SUFFIX)] = 0;
|
name[strlen (name) - strlen (DATALABEL_SUFFIX)] = 0;
|
}
|
}
|
|
|
return TRUE;
|
return 1;
|
}
|
}
|
|
|
/* Set bit 0 on the entry address; it always points to SHmedia code. This
|
/* Set bit 0 on the entry address; it always points to SHmedia code. This
|
is mostly for symmetry with the 32-bit format, where code can be
|
is mostly for symmetry with the 32-bit format, where code can be
|
SHcompact and we need to make a distinction to make sure execution
|
SHcompact and we need to make a distinction to make sure execution
|