X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-tic6x.c;h=419b269e35d797114772a670678be6ccef34fba4;hb=95830fd17d6ae253d8f6c2595188cadd59058799;hp=6d6b59baac3a37d076a6a04e2db11adf3ab54f37;hpb=1d7e9d183fa77485f4af5b916342e1dfa5394cd9;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 6d6b59baac..419b269e35 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1670,9 +1670,9 @@ elf32_tic6x_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) || ! bfd_set_section_alignment (dynobj, htab->elf.splt, 5)) return FALSE; - htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); + htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss"); if (!info->shared) - htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); + htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss"); if (!htab->sdynbss || (!info->shared && !htab->srelbss)) @@ -1849,8 +1849,8 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, /* This symbol has an entry in the global offset table. Set it up. */ - sgot = bfd_get_section_by_name (dynobj, ".got"); - srela = bfd_get_section_by_name (dynobj, ".rela.got"); + sgot = bfd_get_linker_section (dynobj, ".got"); + srela = bfd_get_linker_section (dynobj, ".rela.got"); BFD_ASSERT (sgot != NULL && srela != NULL); /* If this is a -Bsymbolic link, and the symbol is defined @@ -1903,7 +1903,7 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 + if (h == elf_hash_table (info)->hdynamic || h == elf_hash_table (info)->hgot) sym->st_shndx = SHN_ABS; @@ -2327,9 +2327,9 @@ elf32_tic6x_relocate_section (bfd *output_bfd, unresolved_reloc, warned); } - if (sec != NULL && elf_discarded_section (sec)) + if (sec != NULL && discarded_section (sec)) RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, - rel, relend, howto, contents); + rel, 1, relend, howto, 0, contents); if (info->relocatable) { @@ -3305,7 +3305,7 @@ elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) /* Set the contents of the .interp section to the interpreter. */ if (info->executable) { - s = bfd_get_section_by_name (dynobj, ".interp"); + s = bfd_get_linker_section (dynobj, ".interp"); if (s == NULL) abort (); s->size = sizeof ELF_DYNAMIC_INTERPRETER; @@ -3520,79 +3520,10 @@ elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) static bfd_boolean elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) { - if (elf32_tic6x_using_dsbt (output_bfd) && !info->relocatable) - { - struct elf_link_hash_entry *h; - - /* Force a PT_GNU_STACK segment to be created. */ - if (! elf_tdata (output_bfd)->stack_flags) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; - - /* Define __stacksize if it's not defined yet. */ - h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize", - FALSE, FALSE, FALSE); - if (! h || h->root.type != bfd_link_hash_defined - || h->type != STT_OBJECT - || !h->def_regular) - { - struct bfd_link_hash_entry *bh = NULL; - - if (!(_bfd_generic_link_add_one_symbol - (info, output_bfd, "__stacksize", - BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE, - (const char *) NULL, FALSE, - get_elf_backend_data (output_bfd)->collect, &bh))) - return FALSE; - - h = (struct elf_link_hash_entry *) bh; - h->def_regular = 1; - h->type = STT_OBJECT; - } - } - return TRUE; -} - -static bfd_boolean -elf32_tic6x_modify_program_headers (bfd *output_bfd, - struct bfd_link_info *info) -{ - struct elf_obj_tdata *tdata = elf_tdata (output_bfd); - struct elf_segment_map *m; - Elf_Internal_Phdr *p; - - /* objcopy and strip preserve what's already there using - elf32_tic6x_copy_private_bfd_data (). */ - if (! info) - return TRUE; - - for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++) - if (m->p_type == PT_GNU_STACK) - break; - - if (m) - { - struct elf_link_hash_entry *h; - - /* Obtain the pointer to the __stacksize symbol. */ - h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize", - FALSE, FALSE, FALSE); - if (h) - { - while (h->root.type == bfd_link_hash_indirect - || h->root.type == bfd_link_hash_warning) - h = (struct elf_link_hash_entry *) h->root.u.i.link; - BFD_ASSERT (h->root.type == bfd_link_hash_defined); - } - - /* Set the header p_memsz from the symbol value. We - intentionally ignore the symbol section. */ - if (h && h->root.type == bfd_link_hash_defined) - p->p_memsz = h->root.u.def.value; - else - p->p_memsz = DEFAULT_STACK_SIZE; - - p->p_align = 8; - } + if (elf32_tic6x_using_dsbt (output_bfd) && !info->relocatable + && !bfd_elf_stack_segment_size (output_bfd, info, + "__stacksize", DEFAULT_STACK_SIZE)) + return FALSE; return TRUE; } @@ -3607,7 +3538,7 @@ elf32_tic6x_finish_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, htab = elf32_tic6x_hash_table (info); dynobj = htab->elf.dynobj; - sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + sdyn = bfd_get_linker_section (dynobj, ".dynamic"); if (elf_hash_table (info)->dynamic_sections_created) { @@ -4011,51 +3942,11 @@ elf32_tic6x_merge_private_bfd_data (bfd *ibfd, bfd *obfd) if (!_bfd_generic_verify_endian_match (ibfd, obfd)) return FALSE; - if (!elf32_tic6x_merge_attributes (ibfd, obfd)) - return FALSE; - - return TRUE; -} - -static bfd_boolean -elf32_tic6x_copy_private_data (bfd * ibfd, bfd * obfd) -{ - _bfd_elf_copy_private_bfd_data (ibfd, obfd); - if (! is_tic6x_elf (ibfd) || ! is_tic6x_elf (obfd)) return TRUE; - /* Copy the stack size. */ - if (elf_tdata (ibfd)->phdr && elf_tdata (obfd)->phdr - && elf32_tic6x_using_dsbt (ibfd) && elf32_tic6x_using_dsbt (obfd)) - { - unsigned i; - - for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++) - if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK) - { - Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i]; - - for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++) - if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK) - { - memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr)); - - /* Rewrite the phdrs, since we're only called after they - were first written. */ - if (bfd_seek (obfd, - (bfd_signed_vma) get_elf_backend_data (obfd) - ->s->sizeof_ehdr, SEEK_SET) != 0 - || get_elf_backend_data (obfd)->s - ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr, - elf_elfheader (obfd)->e_phnum) != 0) - return FALSE; - break; - } - - break; - } - } + if (!elf32_tic6x_merge_attributes (ibfd, obfd)) + return FALSE; return TRUE; } @@ -4481,12 +4372,12 @@ elf32_tic6x_set_osabi (bfd *abfd, struct bfd_link_info *link_info) #define ELF_MAXPAGESIZE 0x1000 #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup -#define bfd_elf32_bfd_copy_private_bfd_data elf32_tic6x_copy_private_data #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data #define bfd_elf32_mkobject elf32_tic6x_mkobject #define bfd_elf32_bfd_link_hash_table_create elf32_tic6x_link_hash_table_create #define bfd_elf32_bfd_link_hash_table_free elf32_tic6x_link_hash_table_free #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook +#define elf_backend_stack_align 8 #define elf_backend_can_gc_sections 1 #define elf_backend_default_use_rela_p 1 #define elf_backend_may_use_rel_p 1 @@ -4506,8 +4397,6 @@ elf32_tic6x_set_osabi (bfd *abfd, struct bfd_link_info *link_info) #define elf_backend_fake_sections elf32_tic6x_fake_sections #define elf_backend_gc_sweep_hook elf32_tic6x_gc_sweep_hook #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections -#define elf_backend_modify_program_headers \ - elf32_tic6x_modify_program_headers #define elf_backend_create_dynamic_sections \ elf32_tic6x_create_dynamic_sections #define elf_backend_adjust_dynamic_symbol \