aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-sparc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-sparc.c')
-rw-r--r--bfd/elf32-sparc.c141
1 files changed, 11 insertions, 130 deletions
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index e44922c..b0962cf 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -27,10 +27,6 @@ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void elf_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static boolean elf32_sparc_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf32_sparc_create_got_section
- PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf32_sparc_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
@@ -199,124 +195,6 @@ elf_info_to_howto (abfd, cache_ptr, dst)
/* nop. */
#define PLT_ENTRY_WORD2 SPARC_NOP
-/* Create dynamic sections when linking against a dynamic object. */
-
-static boolean
-elf32_sparc_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
- struct elf_link_hash_entry *h;
-
- /* We need to create .plt, .rela.plt, .got, .dynbss, and .rela.bss
- sections. */
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- s = bfd_make_section (abfd, ".plt");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
- .plt section. */
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
- (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
-
- s = bfd_make_section (abfd, ".rela.plt");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- if (! elf32_sparc_create_got_section (abfd, info))
- return false;
-
- /* The .dynbss section is a place to put symbols which are defined
- by dynamic objects, are referenced by regular objects, and are
- not functions. We must allocate space for them in the process
- image and use a R_SPARC_COPY reloc to tell the dynamic linker to
- initialize them at run time. The linker script puts the .dynbss
- section into the .bss section of the final image. */
- s = bfd_make_section (abfd, ".dynbss");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
- return false;
-
- /* The .rela.bss section holds copy relocs. */
- if (! info->shared)
- {
- s = bfd_make_section (abfd, ".rela.bss");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
- }
-
- return true;
-}
-
-/* Create the .got section to hold the global offset table. */
-
-static boolean
-elf32_sparc_create_got_section (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- register asection *s;
- struct elf_link_hash_entry *h;
-
- /* This function may be called more than once. */
- if (bfd_get_section_by_name (abfd, ".got") != NULL)
- return true;
-
- s = bfd_make_section (abfd, ".got");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s,
- (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY))
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
- section. We don't do this in the linker script because we don't
- want to define the symbol if we are not creating a global offset
- table. FIXME: The Solaris linker puts _GLOBAL_OFFSET_TABLE_ at
- the start of the .got section, but when using the small PIC model
- the .got is accessed using a signed 13 bit offset. Shouldn't
- _GLOBAL_OFFSET_TABLE_ be located at .got + 4096? */
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
- (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
-
- /* The first global offset table entry is reserved. */
- s->_raw_size += 4;
-
- return true;
-}
-
/* Look through the relocs for a section during the first phase, and
allocate space in the global offset table or procedure linkage
table. */
@@ -373,7 +251,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
{
/* Create the .got section. */
elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! elf32_sparc_create_got_section (dynobj, info))
+ if (! _bfd_elf_create_got_section (dynobj, info))
return false;
}
@@ -515,7 +393,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
{
const char *name;
- name = (elf_string_from_elf_section
+ name = (bfd_elf_string_from_elf_section
(abfd,
elf_elfheader (abfd)->e_shstrndx,
elf_section_data (sec)->rel_hdr.sh_name));
@@ -1211,7 +1089,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
{
const char *name;
- name = (elf_string_from_elf_section
+ name = (bfd_elf_string_from_elf_section
(input_bfd,
elf_elfheader (input_bfd)->e_shstrndx,
elf_section_data (input_section)->rel_hdr.sh_name));
@@ -1308,9 +1186,9 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
name = h->root.root.string;
else
{
- name = elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
+ name = bfd_elf_string_from_elf_section (input_bfd,
+ symtab_hdr->sh_link,
+ sym->st_name);
if (name == NULL)
return false;
if (*name == '\0')
@@ -1568,7 +1446,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
sym.st_shndx = indx;
bfd_elf32_swap_symbol_out (output_bfd, &sym,
- ((Elf32_External_Sym *) sdynsym->contents
+(char*) ((Elf32_External_Sym *) sdynsym->contents
+ elf_section_data (s)->dynindx));
}
@@ -1587,7 +1465,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
#define ELF_MACHINE_CODE EM_SPARC
#define ELF_MAXPAGESIZE 0x10000
#define elf_backend_create_dynamic_sections \
- elf32_sparc_create_dynamic_sections
+ _bfd_elf_create_dynamic_sections
#define elf_backend_check_relocs elf32_sparc_check_relocs
#define elf_backend_adjust_dynamic_symbol \
elf32_sparc_adjust_dynamic_symbol
@@ -1598,5 +1476,8 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
elf32_sparc_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections \
elf32_sparc_finish_dynamic_sections
+#define elf_backend_want_got_plt 0
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_plt_sym 1
#include "elf32-target.h"