* elf64-sparc.c (struct sparc64_elf_link_hash_table): New 'sgot' and

'srelgot' fields.
	(create_got_section): New function.
	(sparc64_elf_create_dynamic_sections): Likewise.
	(sparc64_elf_check_relocs): Invoke create_got_section instead of
	_bfd_elf_create_got_section.  Use the sgot and srelgot shortcuts.
	(sparc64_elf_size_dynamic_sections): Use the srelgot shortcut.
	(sparc64_elf_relocate_section): Use the sgot and srelgot shortcuts.
	(sparc64_elf_finish_dynamic_symbol): Likewise.
	(sparc64_elf_finish_dynamic_sections): Use the sgot shortcut.
	(elf_backend_create_dynamic_sections): Define to
	sparc64_elf_create_dynamic_sections.
This commit is contained in:
Eric Botcazou 2005-01-09 19:48:28 +00:00
parent 7cb9022a14
commit a51a7930ba
2 changed files with 86 additions and 25 deletions

View file

@ -1,3 +1,18 @@
2005-01-09 Eric Botcazou <ebotcazou@libertysurf.fr>
* elf64-sparc.c (struct sparc64_elf_link_hash_table): New 'sgot' and
'srelgot' fields.
(create_got_section): New function.
(sparc64_elf_create_dynamic_sections): Likewise.
(sparc64_elf_check_relocs): Invoke create_got_section instead of
_bfd_elf_create_got_section. Use the sgot and srelgot shortcuts.
(sparc64_elf_size_dynamic_sections): Use the srelgot shortcut.
(sparc64_elf_relocate_section): Use the sgot and srelgot shortcuts.
(sparc64_elf_finish_dynamic_symbol): Likewise.
(sparc64_elf_finish_dynamic_sections): Use the sgot shortcut.
(elf_backend_create_dynamic_sections): Define to
sparc64_elf_create_dynamic_sections.
2005-01-09 Eric Botcazou <ebotcazou@libertysurf.fr> 2005-01-09 Eric Botcazou <ebotcazou@libertysurf.fr>
* elf32-sparc.c (elf32_sparc_omit_section_dynsym): New function. * elf32-sparc.c (elf32_sparc_omit_section_dynsym): New function.

View file

@ -36,6 +36,10 @@
static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create
PARAMS ((bfd *)); PARAMS ((bfd *));
static bfd_boolean create_got_section
PARAMS ((bfd *, struct bfd_link_info *));
static bfd_boolean sparc64_elf_create_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static bfd_reloc_status_type init_insn_reloc static bfd_reloc_status_type init_insn_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *,
bfd *, bfd_vma *, bfd_vma *)); bfd *, bfd_vma *, bfd_vma *));
@ -738,6 +742,10 @@ struct sparc64_elf_link_hash_table
{ {
struct elf_link_hash_table root; struct elf_link_hash_table root;
/* Short-cuts to get to dynamic linker sections. */
asection *sgot;
asection *srelgot;
struct sparc64_elf_app_reg app_regs [4]; struct sparc64_elf_app_reg app_regs [4];
}; };
@ -768,6 +776,57 @@ sparc64_elf_bfd_link_hash_table_create (abfd)
return &ret->root.root; return &ret->root.root;
} }
/* Create .got and .rela.got sections in DYNOBJ and set up
shortcuts to them in our hash table. */
static bfd_boolean
create_got_section (dynobj, info)
bfd *dynobj;
struct bfd_link_info *info;
{
struct sparc64_elf_link_hash_table *htab;
if (! _bfd_elf_create_got_section (dynobj, info))
return FALSE;
htab = sparc64_elf_hash_table (info);
htab->sgot = bfd_get_section_by_name (dynobj, ".got");
BFD_ASSERT (htab->sgot != NULL);
htab->srelgot = bfd_make_section (dynobj, ".rela.got");
if (htab->srelgot == NULL
|| ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY)
|| ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
return FALSE;
return TRUE;
}
/* Create .plt, .rela.plt, .got, .rela.got, .dynbss, and
.rela.bss sections in DYNOBJ, and set up shortcuts to them in our
hash table. */
static bfd_boolean
sparc64_elf_create_dynamic_sections (dynobj, info)
bfd *dynobj;
struct bfd_link_info *info;
{
struct sparc64_elf_link_hash_table *htab;
htab = sparc64_elf_hash_table (info);
if (!htab->sgot && !create_got_section (dynobj, info))
return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
return FALSE;
return TRUE;
}
/* Utility for performing the standard initial work of an instruction /* Utility for performing the standard initial work of an instruction
relocation. relocation.
@ -1137,35 +1196,22 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
if (dynobj == NULL) if (dynobj == NULL)
{ {
/* Create the .got section. */ /* Create the .got and .rela.got sections. */
elf_hash_table (info)->dynobj = dynobj = abfd; elf_hash_table (info)->dynobj = dynobj = abfd;
if (! _bfd_elf_create_got_section (dynobj, info)) if (! create_got_section (dynobj, info))
return FALSE; return FALSE;
} }
if (sgot == NULL) if (sgot == NULL)
{ {
sgot = bfd_get_section_by_name (dynobj, ".got"); sgot = sparc64_elf_hash_table (info)->sgot;
BFD_ASSERT (sgot != NULL); BFD_ASSERT (sgot != NULL);
} }
if (srelgot == NULL && (h != NULL || info->shared)) if (srelgot == NULL && (h != NULL || info->shared))
{ {
srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); srelgot = sparc64_elf_hash_table (info)->srelgot;
if (srelgot == NULL) BFD_ASSERT (srelgot != NULL);
{
srelgot = bfd_make_section (dynobj, ".rela.got");
if (srelgot == NULL
|| ! bfd_set_section_flags (dynobj, srelgot,
(SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY))
|| ! bfd_set_section_alignment (dynobj, srelgot, 3))
return FALSE;
}
} }
if (h != NULL) if (h != NULL)
@ -1811,7 +1857,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
not actually use these entries. Reset the size of .rela.got, not actually use these entries. Reset the size of .rela.got,
which will cause it to get stripped from the output file which will cause it to get stripped from the output file
below. */ below. */
s = bfd_get_section_by_name (dynobj, ".rela.got"); s = sparc64_elf_hash_table (info)->srelgot;
if (s != NULL) if (s != NULL)
s->size = 0; s->size = 0;
} }
@ -2324,7 +2370,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
offset table. */ offset table. */
if (sgot == NULL) if (sgot == NULL)
{ {
sgot = bfd_get_section_by_name (dynobj, ".got"); sgot = sparc64_elf_hash_table (info)->sgot;
BFD_ASSERT (sgot != NULL); BFD_ASSERT (sgot != NULL);
} }
@ -2398,7 +2444,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* We need to generate a R_SPARC_RELATIVE reloc /* We need to generate a R_SPARC_RELATIVE reloc
for the dynamic linker. */ for the dynamic linker. */
s = bfd_get_section_by_name(dynobj, ".rela.got"); s = sparc64_elf_hash_table (info)->srelgot;
BFD_ASSERT (s != NULL); BFD_ASSERT (s != NULL);
outrel.r_offset = (sgot->output_section->vma outrel.r_offset = (sgot->output_section->vma
@ -2779,8 +2825,8 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the GOT. Set it up. */ /* This symbol has an entry in the GOT. Set it up. */
sgot = bfd_get_section_by_name (dynobj, ".got"); sgot = sparc64_elf_hash_table (info)->sgot;
srela = bfd_get_section_by_name (dynobj, ".rela.got"); srela = sparc64_elf_hash_table (info)->srelgot;
BFD_ASSERT (sgot != NULL && srela != NULL); BFD_ASSERT (sgot != NULL && srela != NULL);
rela.r_offset = (sgot->output_section->vma rela.r_offset = (sgot->output_section->vma
@ -2928,7 +2974,7 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info)
/* Set the first entry in the global offset table to the address of /* Set the first entry in the global offset table to the address of
the dynamic section. */ the dynamic section. */
sgot = bfd_get_section_by_name (dynobj, ".got"); sgot = sparc64_elf_hash_table (info)->sgot;
BFD_ASSERT (sgot != NULL); BFD_ASSERT (sgot != NULL);
if (sgot->size > 0) if (sgot->size > 0)
{ {
@ -3206,7 +3252,7 @@ const struct elf_size_info sparc64_elf_size_info =
sparc64_elf_new_section_hook sparc64_elf_new_section_hook
#define elf_backend_create_dynamic_sections \ #define elf_backend_create_dynamic_sections \
_bfd_elf_create_dynamic_sections sparc64_elf_create_dynamic_sections
#define elf_backend_add_symbol_hook \ #define elf_backend_add_symbol_hook \
sparc64_elf_add_symbol_hook sparc64_elf_add_symbol_hook
#define elf_backend_get_symbol_type \ #define elf_backend_get_symbol_type \