sreloc = bfd_get_section_by_name (dynobj, dname);
if (sreloc == NULL && create_p)
{
- sreloc = bfd_make_section (dynobj, dname);
+ sreloc = bfd_make_section_with_flags (dynobj, dname,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY));
if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc, SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
+ || ! bfd_set_section_alignment (dynobj, sreloc,
+ SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
return NULL;
}
-
- return sreloc;
+ return sreloc;
}
static void
struct bfd_link_info *info,
const Elf_Internal_Rela *rel,
struct score_elf_link_hash_entry *h,
- asection *sec, bfd_vma symbol,
+ bfd_vma symbol,
bfd_vma *addendp, asection *input_section)
{
Elf_Internal_Rela outrel[3];
}
else
{
- if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
- else
- {
- indx = elf_section_data (sec->output_section)->dynindx;
- if (indx == 0)
- abort ();
- }
-
- /* Instead of generating a relocation using the section
- symbol, we may as well make it a fully relative
- relocation. We want to avoid generating relocations to
- local symbols because we used to generate them
- incorrectly, without adding the original symbol value,
- which is mandated by the ABI for section symbols. In
- order to give dynamic loaders and applications time to
- phase out the incorrect use, we refrain from emitting
- section-relative relocations. It's not like they're
- useful, after all. This should be a bit more efficient
- as well. */
- /* ??? Although this behavior is compatible with glibc's ld.so,
- the ABI says that relocations against STN_UNDEF should have
- a symbol value of 0. Irix rld honors this, so relocations
- against STN_UNDEF have no effect. */
+ indx = 0;
defined_p = TRUE;
}
/* We have to use an alignment of 2**4 here because this is hardcoded
in the function stub generation and in the linker script. */
- s = bfd_make_section (abfd, ".got");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
+ s = bfd_make_section_with_flags (abfd, ".got", flags);
+ if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 4))
return FALSE;
Elf_Internal_Rela *relocs,
bfd_vma symbol,
struct bfd_link_info *info,
- asection *sym_sec,
const char *sym_name ATTRIBUTE_UNUSED,
int sym_flags ATTRIBUTE_UNUSED,
struct score_elf_link_hash_entry *h,
r_type = ELF32_R_TYPE (rel->r_info);
rel_addr = (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
- /* If the start address has been set, then set the EF_SCORE_HASENTRY
- flag. Setting this more than once is redundant, but the cost is
- not too high, and it keeps the code simple.
- The test is done here, rather than somewhere else, because the
- start address is only set just before the final link commences.
- Note - if the user deliberately sets a start address of 0, the flag will not be set. */
- if (bfd_get_start_address (output_bfd) != 0)
- elf_elfheader (output_bfd)->e_flags |= EF_SCORE_HASENTRY;
-
if (r_type == R_SCORE_GOT15)
{
const Elf_Internal_Rela *relend;
to the dynamic linker. */
value = addend;
if (!score_elf_create_dynamic_relocation (output_bfd, info, rel, h,
- sym_sec, symbol, &value,
+ symbol, &value,
input_section))
return bfd_reloc_undefined;
}
r = score_elf_final_link_relocate (howto, input_bfd, output_bfd,
input_section, contents, rel, relocs,
- relocation, info, sec, name,
+ relocation, info, name,
(h ? ELF_ST_TYPE ((unsigned int)h->root.root.type) :
ELF_ST_TYPE ((unsigned int)sym->st_info)), h, local_sections,
gp_disp_p);
/* Create .stub section. */
if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
{
- s = bfd_make_section (abfd, SCORE_ELF_STUB_SECTION_NAME);
+ s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
+ flags | SEC_CODE);
if (s == NULL
- || !bfd_set_section_flags (abfd, s, flags | SEC_CODE)
|| !bfd_set_section_alignment (abfd, s, 2))
return FALSE;
return FALSE;
}
-/* This function discover the section a particular relocation refers to.
- Return the section that should be marked against GC for a given relocation. */
+/* Return the section that should be marked against GC for a given
+ relocation. */
static asection *
_bfd_score_elf_gc_mark_hook (asection *sec,
- struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ struct bfd_link_info *info,
Elf_Internal_Rela *rel,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
if (h != NULL)
- {
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_SCORE_GNU_VTINHERIT:
- case R_SCORE_GNU_VTENTRY:
- break;
- default:
- switch (h->root.type)
- {
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- return h->root.u.def.section;
- case bfd_link_hash_common:
- return h->root.u.c.p->section;
- default:
- break;
- }
- }
- }
- else
- return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SCORE_GNU_VTINHERIT:
+ case R_SCORE_GNU_VTENTRY:
+ return NULL;
+ }
- return NULL;
+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
}
/* Support for core dump NOTE sections. */
#define ELF_MACHINE_CODE EM_SCORE
#define ELF_MAXPAGESIZE 0x8000
-#define elf_info_to_howto 0
-#define elf_info_to_howto_rel _bfd_score_info_to_howto
-#define elf_backend_relocate_section _bfd_score_elf_relocate_section
-#define elf_backend_check_relocs _bfd_score_elf_check_relocs
-#define elf_backend_add_symbol_hook _bfd_score_elf_add_symbol_hook
-#define elf_backend_symbol_processing _bfd_score_elf_symbol_processing
-#define elf_backend_link_output_symbol_hook _bfd_score_elf_link_output_symbol_hook
-#define elf_backend_section_from_bfd_section _bfd_score_elf_section_from_bfd_section
-#define elf_backend_adjust_dynamic_symbol _bfd_score_elf_adjust_dynamic_symbol
-#define elf_backend_always_size_sections _bfd_score_elf_always_size_sections
-#define elf_backend_size_dynamic_sections _bfd_score_elf_size_dynamic_sections
-#define elf_backend_create_dynamic_sections _bfd_score_elf_create_dynamic_sections
-#define elf_backend_finish_dynamic_symbol _bfd_score_elf_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections _bfd_score_elf_finish_dynamic_sections
-#define elf_backend_fake_sections _bfd_score_elf_fake_sections
-#define elf_backend_section_processing _bfd_score_elf_section_processing
-#define elf_backend_write_section _bfd_score_elf_write_section
-#define elf_backend_copy_indirect_symbol _bfd_score_elf_copy_indirect_symbol
-#define elf_backend_hide_symbol _bfd_score_elf_hide_symbol
-#define elf_backend_discard_info _bfd_score_elf_discard_info
-#define elf_backend_ignore_discarded_relocs _bfd_score_elf_ignore_discarded_relocs
-#define elf_backend_gc_mark_hook _bfd_score_elf_gc_mark_hook
-#define elf_backend_grok_prstatus _bfd_score_elf_grok_prstatus
-#define elf_backend_grok_psinfo _bfd_score_elf_grok_psinfo
-#define elf_backend_can_gc_sections 1
-#define elf_backend_want_plt_sym 0
-#define elf_backend_got_header_size (4 * SCORE_RESERVED_GOTNO)
-#define elf_backend_plt_header_size 0
-#define elf_backend_collect TRUE
-#define elf_backend_type_change_ok TRUE
-
-#define bfd_elf32_bfd_reloc_type_lookup elf32_score_reloc_type_lookup
-#define bfd_elf32_bfd_link_hash_table_create elf32_score_link_hash_table_create
-#define bfd_elf32_bfd_print_private_bfd_data elf32_score_print_private_bfd_data
-#define bfd_elf32_bfd_merge_private_bfd_data elf32_score_merge_private_bfd_data
-#define bfd_elf32_new_section_hook elf32_score_new_section_hook
+#define elf_info_to_howto 0
+#define elf_info_to_howto_rel _bfd_score_info_to_howto
+#define elf_backend_relocate_section _bfd_score_elf_relocate_section
+#define elf_backend_check_relocs _bfd_score_elf_check_relocs
+#define elf_backend_add_symbol_hook _bfd_score_elf_add_symbol_hook
+#define elf_backend_symbol_processing _bfd_score_elf_symbol_processing
+#define elf_backend_link_output_symbol_hook \
+ _bfd_score_elf_link_output_symbol_hook
+#define elf_backend_section_from_bfd_section \
+ _bfd_score_elf_section_from_bfd_section
+#define elf_backend_adjust_dynamic_symbol \
+ _bfd_score_elf_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+ _bfd_score_elf_always_size_sections
+#define elf_backend_size_dynamic_sections \
+ _bfd_score_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+ ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+#define elf_backend_create_dynamic_sections \
+ _bfd_score_elf_create_dynamic_sections
+#define elf_backend_finish_dynamic_symbol \
+ _bfd_score_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ _bfd_score_elf_finish_dynamic_sections
+#define elf_backend_fake_sections _bfd_score_elf_fake_sections
+#define elf_backend_section_processing _bfd_score_elf_section_processing
+#define elf_backend_write_section _bfd_score_elf_write_section
+#define elf_backend_copy_indirect_symbol _bfd_score_elf_copy_indirect_symbol
+#define elf_backend_hide_symbol _bfd_score_elf_hide_symbol
+#define elf_backend_discard_info _bfd_score_elf_discard_info
+#define elf_backend_ignore_discarded_relocs \
+ _bfd_score_elf_ignore_discarded_relocs
+#define elf_backend_gc_mark_hook _bfd_score_elf_gc_mark_hook
+#define elf_backend_grok_prstatus _bfd_score_elf_grok_prstatus
+#define elf_backend_grok_psinfo _bfd_score_elf_grok_psinfo
+#define elf_backend_can_gc_sections 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size (4 * SCORE_RESERVED_GOTNO)
+#define elf_backend_plt_header_size 0
+#define elf_backend_collect TRUE
+#define elf_backend_type_change_ok TRUE
+
+#define bfd_elf32_bfd_reloc_type_lookup elf32_score_reloc_type_lookup
+#define bfd_elf32_bfd_link_hash_table_create elf32_score_link_hash_table_create
+#define bfd_elf32_bfd_print_private_bfd_data elf32_score_print_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data elf32_score_merge_private_bfd_data
+#define bfd_elf32_new_section_hook elf32_score_new_section_hook
#include "elf32-target.h"