X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-score.c;h=d1a910f2795e9701fd96b291183bf9411164948f;hb=fda3f1174efb2fb1800e3fcb74819ba2dc9c2dd0;hp=897ab8a3f3808681eea934d7d3283247bdc3761f;hpb=219d1afa89d0d53ca93a684cac341f16470f3ca0;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 897ab8a3f3..d1a910f279 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -1,5 +1,5 @@ /* 32-bit ELF support for S+core. - Copyright (C) 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2006-2020 Free Software Foundation, Inc. Contributed by Brain.lin (brain.lin@sunplusct.com) Mei Ligang (ligang@sunnorth.com.cn) @@ -596,8 +596,8 @@ score_elf_got15_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, bfd *output_bfd, char **error_message) { if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0 - || bfd_is_und_section (bfd_get_section (symbol)) - || bfd_is_com_section (bfd_get_section (symbol))) + || bfd_is_und_section (bfd_asymbol_section (symbol)) + || bfd_is_com_section (bfd_asymbol_section (symbol))) /* The relocation is against a global symbol. */ return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, @@ -1257,8 +1257,8 @@ score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p) | SEC_LINKER_CREATED | SEC_READONLY)); if (sreloc == NULL - || ! bfd_set_section_alignment (dynobj, sreloc, - SCORE_ELF_LOG_FILE_ALIGN (dynobj))) + || !bfd_set_section_alignment (sreloc, + SCORE_ELF_LOG_FILE_ALIGN (dynobj))) return NULL; } return sreloc; @@ -1410,7 +1410,7 @@ score_elf_create_got_section (bfd *abfd, struct elf_link_hash_entry *h; struct bfd_link_hash_entry *bh; struct score_got_info *g; - bfd_size_type amt; + size_t amt; /* This function may be called more than once. */ s = score_elf_got_section (abfd, TRUE); @@ -1431,7 +1431,7 @@ score_elf_create_got_section (bfd *abfd, s = bfd_make_section_anyway_with_flags (abfd, ".got", flags); elf_hash_table (info)->sgot = s; if (s == NULL - || ! bfd_set_section_alignment (abfd, s, 4)) + || !bfd_set_section_alignment (s, 4)) return FALSE; /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the @@ -2375,7 +2375,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto, } /* Score backend functions. */ -static void +static bfd_boolean s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) @@ -2384,9 +2384,10 @@ s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, r_type = ELF32_R_TYPE (elf_reloc->r_info); if (r_type >= ARRAY_SIZE (elf32_score_howto_table)) - bfd_reloc->howto = NULL; - else - bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return FALSE; + + bfd_reloc->howto = &elf32_score_howto_table[r_type]; + return TRUE; } /* Relocate an score ELF section. */ @@ -2448,7 +2449,8 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd, r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); - s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel); + if (! s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel)) + continue; howto = bfd_reloc.howto; h = NULL; @@ -2667,13 +2669,14 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd, } else if (!bfd_link_relocatable (info)) { - (*info->callbacks->undefined_symbol) - (info, h->root.root.root.string, input_bfd, - input_section, rel->r_offset, - (info->unresolved_syms_in_objects == RM_GENERATE_ERROR) + info->callbacks->undefined_symbol + (info, h->root.root.root.string, input_bfd, input_section, + rel->r_offset, + (info->unresolved_syms_in_objects == RM_DIAGNOSE + && !info->warn_unresolved_syms) || ELF_ST_VISIBILITY (h->root.other)); - relocation = 0; - } + relocation = 0; + } } if (sec != NULL && discarded_section (sec)) @@ -2741,7 +2744,7 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd, /* Use bfd_reloc_other to check lw48, sw48 word align. */ case bfd_reloc_other: - msg = _("address not word align"); + msg = _("address not word aligned"); goto common_error; default: @@ -2822,7 +2825,7 @@ s3_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: Malformed reloc detected for section %A"), abfd, sec); + (_("%pB: malformed reloc detected for section %pA"), abfd, sec); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2876,8 +2879,8 @@ s3_bfd_score_elf_check_relocs (bfd *abfd, { _bfd_error_handler /* xgettext:c-format */ - (_("%B: CALL15 reloc at %#Lx not against global symbol"), - abfd, rel->r_offset); + (_("%pB: CALL15 reloc at %#" PRIx64 " not against global symbol"), + abfd, (uint64_t) rel->r_offset); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -3068,7 +3071,7 @@ s3_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, int *retval) { - if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0) + if (strcmp (bfd_section_name (sec), ".scommon") == 0) { *retval = SHN_SCORE_SCOMMON; return TRUE; @@ -3281,7 +3284,7 @@ s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i /* It's OK to base decisions on the section name, because none of the dynobj section names depend upon the input files. */ - name = bfd_get_section_name (dynobj, s); + name = bfd_section_name (s); if (CONST_STRNEQ (name, ".rel")) { @@ -3294,8 +3297,7 @@ s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i the linker now does not create empty output sections. */ if (s->output_section != NULL && strcmp (name, - bfd_get_section_name (s->output_section->owner, - s->output_section)) == 0) + bfd_section_name (s->output_section)) == 0) s->flags |= SEC_EXCLUDE; } else @@ -3309,7 +3311,7 @@ s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i assert a DT_TEXTREL entry rather than testing whether there exists a relocation to a read only section or not. */ - outname = bfd_get_section_name (output_bfd, s->output_section); + outname = bfd_section_name (s->output_section); target = bfd_get_section_by_name (output_bfd, outname + 4); if ((target != NULL && (target->flags & SEC_READONLY) != 0 @@ -3422,7 +3424,7 @@ s3_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) s = bfd_get_linker_section (abfd, ".dynamic"); if (s != NULL) { - if (!bfd_set_section_flags (abfd, s, flags)) + if (!bfd_set_section_flags (s, flags)) return FALSE; } @@ -3439,7 +3441,7 @@ s3_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) s = bfd_make_section_anyway_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME, flags | SEC_CODE); if (s == NULL - || !bfd_set_section_alignment (abfd, s, 2)) + || !bfd_set_section_alignment (s, 2)) return FALSE; } @@ -3707,7 +3709,7 @@ s3_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, { const char *name; - name = bfd_get_section_name (abfd, sec); + name = bfd_section_name (sec); if (strcmp (name, ".got") == 0 || strcmp (name, ".srdata") == 0 @@ -3730,7 +3732,7 @@ s3_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Sh { if (hdr->bfd_section != NULL) { - const char *name = bfd_get_section_name (abfd, hdr->bfd_section); + const char *name = bfd_section_name (hdr->bfd_section); if (strcmp (name, ".sdata") == 0) { @@ -4019,6 +4021,10 @@ s3_elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (!_bfd_generic_verify_endian_match (ibfd, info)) return FALSE; + /* FIXME: What should be checked when linking shared libraries? */ + if ((ibfd->flags & DYNAMIC) != 0) + return TRUE; + in_flags = elf_elfheader (ibfd)->e_flags; out_flags = elf_elfheader (obfd)->e_flags; @@ -4045,7 +4051,7 @@ s3_elf32_score_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0)) _bfd_error_handler - (_("%B: warning: linking PIC files with non-PIC files"), ibfd); + (_("%pB: warning: linking PIC files with non-PIC files"), ibfd); /* FIXME: Maybe dependency fix compatibility should be checked here. */ @@ -4056,7 +4062,7 @@ static bfd_boolean s3_elf32_score_new_section_hook (bfd *abfd, asection *sec) { struct _score_elf_section_data *sdata; - bfd_size_type amt = sizeof (*sdata); + size_t amt = sizeof (*sdata); sdata = bfd_zalloc (abfd, amt); if (sdata == NULL) @@ -4069,7 +4075,7 @@ s3_elf32_score_new_section_hook (bfd *abfd, asection *sec) /*****************************************************************************/ /* s3_s7: backend hooks. */ -static void +static bfd_boolean _bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) @@ -4358,7 +4364,7 @@ static struct bfd_link_hash_table * elf32_score_link_hash_table_create (bfd *abfd) { struct elf_link_hash_table *ret; - bfd_size_type amt = sizeof (struct elf_link_hash_table); + size_t amt = sizeof (struct elf_link_hash_table); ret = (struct elf_link_hash_table *) bfd_zmalloc (amt); if (ret == NULL) @@ -4450,7 +4456,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym) #define ELF_MACHINE_ALT1 EM_SCORE_OLD #define ELF_MAXPAGESIZE 0x8000 -#define elf_info_to_howto 0 +#define elf_info_to_howto NULL #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 @@ -4466,8 +4472,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym) _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_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_create_dynamic_sections \ _bfd_score_elf_create_dynamic_sections #define elf_backend_finish_dynamic_symbol \