diff options
author | Alan Modra <amodra@gmail.com> | 2013-02-21 02:29:11 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2013-02-21 02:29:11 +0000 |
commit | 12bd695738760b28c04dd34b3ff228247ec747c9 (patch) | |
tree | 4b6d7393eada7903b839e2d842cbd47da3c863f8 /bfd | |
parent | 9f44fbc03496a470cf661d011d9bcdcf21859726 (diff) | |
download | gdb-12bd695738760b28c04dd34b3ff228247ec747c9.zip gdb-12bd695738760b28c04dd34b3ff228247ec747c9.tar.gz gdb-12bd695738760b28c04dd34b3ff228247ec747c9.tar.bz2 |
bfd/
* elf-bfd.h (struct elf_obj_tdata): Rename segment_map to seg_map.
Delete num_locals and num_globals.
(elf_num_locals, elf_num_globals): Don't define.
(elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker,
elf_stack_flags, elf_strtab_sec, elf_shstrtab_sec): Define.
* bfd.c, * elf-eh-frame.c, * elf-nacl.c, * elf-vxworks.c, * elf.c,
* elf32-arm.c, * elf32-lm32.c, * elf32-ppc.c, * elf32-rx.c,
* elf32-spu.c, * elf64-hppa.c, * elfcode.h, * elflink.c,
* elfnn-ia64.c, * elfxx-mips.c: Use newly defined elf_obj_tdata
accessor macros.
* elf.c (elf_map_symbols): Add pnum_locals param. Return
number of locals syms via new param.
(swap_out_syms): Adjust to suit elf_map_symbols change.
ld/
* emultempl/elf-generic.em: Use newly defined elf_obj_tdata
accessor macros.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 16 | ||||
-rw-r--r-- | bfd/bfd.c | 2 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 13 | ||||
-rw-r--r-- | bfd/elf-eh-frame.c | 2 | ||||
-rw-r--r-- | bfd/elf-nacl.c | 4 | ||||
-rw-r--r-- | bfd/elf-vxworks.c | 2 | ||||
-rw-r--r-- | bfd/elf.c | 162 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 12 | ||||
-rw-r--r-- | bfd/elf32-lm32.c | 3 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 2 | ||||
-rw-r--r-- | bfd/elf32-rx.c | 2 | ||||
-rw-r--r-- | bfd/elf32-spu.c | 16 | ||||
-rw-r--r-- | bfd/elf64-hppa.c | 8 | ||||
-rw-r--r-- | bfd/elfcode.h | 4 | ||||
-rw-r--r-- | bfd/elflink.c | 14 | ||||
-rw-r--r-- | bfd/elfnn-ia64.c | 10 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 14 |
17 files changed, 149 insertions, 137 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d8834bf..ed4508f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +2013-02-21 Alan Modra <amodra@gmail.com> + + * elf-bfd.h (struct elf_obj_tdata): Rename segment_map to seg_map. + Delete num_locals and num_globals. + (elf_num_locals, elf_num_globals): Don't define. + (elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker, + elf_stack_flags, elf_strtab_sec, elf_shstrtab_sec): Define. + * bfd.c, * elf-eh-frame.c, * elf-nacl.c, * elf-vxworks.c, * elf.c, + * elf32-arm.c, * elf32-lm32.c, * elf32-ppc.c, * elf32-rx.c, + * elf32-spu.c, * elf64-hppa.c, * elfcode.h, * elflink.c, + * elfnn-ia64.c, * elfxx-mips.c: Use newly defined elf_obj_tdata + accessor macros. + * elf.c (elf_map_symbols): Add pnum_locals param. Return + number of locals syms via new param. + (swap_out_syms): Adjust to suit elf_map_symbols change. + 2013-02-19 Maciej W. Rozycki <macro@codesourcery.com> * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Also clear @@ -1580,7 +1580,7 @@ bfd_record_phdr (bfd *abfd, if (count > 0) memcpy (m->sections, secs, count * sizeof (asection *)); - for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next) + for (pm = &elf_seg_map (abfd); *pm != NULL; pm = &(*pm)->next) ; *pm = m; diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index d2f62f5..b59ef20 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1542,10 +1542,8 @@ struct elf_obj_tdata Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */ Elf_Internal_Shdr **elf_sect_ptr; Elf_Internal_Phdr *phdr; - struct elf_segment_map *segment_map; + struct elf_segment_map *seg_map; struct elf_strtab_hash *strtab_ptr; - int num_locals; - int num_globals; unsigned int num_elf_sections; /* elf_sect_ptr size */ int num_section_syms; asymbol **section_syms; /* STT_SECTION symbols for each section */ @@ -1692,9 +1690,16 @@ struct elf_obj_tdata #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header) #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr) #define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections) +#define elf_seg_map(bfd) (elf_tdata(bfd) -> seg_map) +#define elf_next_file_pos(bfd) (elf_tdata(bfd) -> next_file_pos) +#define elf_eh_frame_hdr(bfd) (elf_tdata(bfd) -> eh_frame_hdr) +#define elf_linker(bfd) (elf_tdata(bfd) -> linker) +#define elf_stack_flags(bfd) (elf_tdata(bfd) -> stack_flags) #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr) #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section) #define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section) +#define elf_strtab_sec(bfd) (elf_tdata(bfd) -> strtab_section) +#define elf_shstrtab_sec(bfd) (elf_tdata(bfd) -> shstrtab_section) #define elf_symtab_hdr(bfd) (elf_tdata(bfd) -> symtab_hdr) #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section) #define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section) @@ -1702,8 +1707,6 @@ struct elf_obj_tdata #define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section) #define elf_eh_frame_section(bfd) \ (elf_tdata(bfd) -> eh_frame_section) -#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals) -#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals) #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms) #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms) #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo) diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index 24ae741..832a991 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -1243,7 +1243,7 @@ _bfd_elf_discard_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) if (hdr_info->table) sec->size += 4 + hdr_info->fde_count * 8; - elf_tdata (abfd)->eh_frame_hdr = sec; + elf_eh_frame_hdr (abfd) = sec; return TRUE; } diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c index 6753c7c..39ffb5d 100644 --- a/bfd/elf-nacl.c +++ b/bfd/elf-nacl.c @@ -71,7 +71,7 @@ segment_eligible_for_headers (struct elf_segment_map *seg, bfd_boolean nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) { - struct elf_segment_map **m = &elf_tdata (abfd)->segment_map; + struct elf_segment_map **m = &elf_seg_map (abfd); struct elf_segment_map **first_load = NULL; struct elf_segment_map **last_load = NULL; bfd_boolean moved_headers = FALSE; @@ -151,7 +151,7 @@ nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) bfd_boolean nacl_modify_program_headers (bfd *abfd, struct bfd_link_info *info) { - struct elf_segment_map **m = &elf_tdata (abfd)->segment_map; + struct elf_segment_map **m = &elf_seg_map (abfd); Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr; Elf_Internal_Phdr *p = phdr; diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c index 01e1c34..bb9dbbb 100644 --- a/bfd/elf-vxworks.c +++ b/bfd/elf-vxworks.c @@ -227,7 +227,7 @@ elf_vxworks_final_write_processing (bfd *abfd, if (!sec) return; d = elf_section_data (sec); - d->this_hdr.sh_link = elf_tdata (abfd)->symtab_section; + d->this_hdr.sh_link = elf_onesymtab (abfd); sec = bfd_get_section_by_name (abfd, ".plt"); if (sec) d->this_hdr.sh_info = elf_section_data (sec)->this_idx; @@ -1436,9 +1436,9 @@ bfd_elf_print_symbol (bfd *abfd, bfd_fprintf_vma (abfd, file, val); /* If we have version information, print it. */ - if (elf_tdata (abfd)->dynversym_section != 0 - && (elf_tdata (abfd)->dynverdef_section != 0 - || elf_tdata (abfd)->dynverref_section != 0)) + if (elf_dynversym (abfd) != 0 + && (elf_dynverdef (abfd) != 0 + || elf_dynverref (abfd) != 0)) { unsigned int vernum; const char *version_string; @@ -2974,9 +2974,9 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) d->rela.idx = 0; } - t->shstrtab_section = section_number++; + elf_shstrtab_sec (abfd) = section_number++; _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name); - elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section; + elf_elfheader (abfd)->e_shstrndx = elf_shstrtab_sec (abfd); need_symtab = (bfd_get_symcount (abfd) > 0 || (link_info == NULL @@ -2984,18 +2984,18 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) == HAS_RELOC))); if (need_symtab) { - t->symtab_section = section_number++; + elf_onesymtab (abfd) = section_number++; _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name); if (section_number > ((SHN_LORESERVE - 2) & 0xFFFF)) { - t->symtab_shndx_section = section_number++; + elf_symtab_shndx (abfd) = section_number++; t->symtab_shndx_hdr.sh_name = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), ".symtab_shndx", FALSE); if (t->symtab_shndx_hdr.sh_name == (unsigned int) -1) return FALSE; } - t->strtab_section = section_number++; + elf_strtab_sec (abfd) = section_number++; _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->strtab_hdr.sh_name); } @@ -3029,17 +3029,17 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) elf_elfsections (abfd) = i_shdrp; - i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr; + i_shdrp[elf_shstrtab_sec (abfd)] = &t->shstrtab_hdr; if (need_symtab) { - i_shdrp[t->symtab_section] = &t->symtab_hdr; + i_shdrp[elf_onesymtab (abfd)] = &t->symtab_hdr; if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF)) { - i_shdrp[t->symtab_shndx_section] = &t->symtab_shndx_hdr; - t->symtab_shndx_hdr.sh_link = t->symtab_section; + i_shdrp[elf_symtab_shndx (abfd)] = &t->symtab_shndx_hdr; + t->symtab_shndx_hdr.sh_link = elf_onesymtab (abfd); } - i_shdrp[t->strtab_section] = &t->strtab_hdr; - t->symtab_hdr.sh_link = t->strtab_section; + i_shdrp[elf_strtab_sec (abfd)] = &t->strtab_hdr; + t->symtab_hdr.sh_link = elf_strtab_sec (abfd); } for (sec = abfd->sections; sec; sec = sec->next) @@ -3062,12 +3062,12 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) the relocation entries apply. */ if (d->rel.idx != 0) { - d->rel.hdr->sh_link = t->symtab_section; + d->rel.hdr->sh_link = elf_onesymtab (abfd); d->rel.hdr->sh_info = d->this_idx; } if (d->rela.idx != 0) { - d->rela.hdr->sh_link = t->symtab_section; + d->rela.hdr->sh_link = elf_onesymtab (abfd); d->rela.hdr->sh_info = d->this_idx; } @@ -3222,7 +3222,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) break; case SHT_GROUP: - d->this_hdr.sh_link = t->symtab_section; + d->this_hdr.sh_link = elf_onesymtab (abfd); } } @@ -3273,7 +3273,7 @@ ignore_section_sym (bfd *abfd, asymbol *sym) all local symbols to be at the head of the list. */ static bfd_boolean -elf_map_symbols (bfd *abfd) +elf_map_symbols (bfd *abfd, unsigned int *pnum_locals) { unsigned int symcount = bfd_get_symcount (abfd); asymbol **syms = bfd_get_outsymbols (abfd); @@ -3389,8 +3389,7 @@ elf_map_symbols (bfd *abfd) bfd_set_symtab (abfd, new_syms, num_locals + num_globals); - elf_num_locals (abfd) = num_locals; - elf_num_globals (abfd) = num_globals; + *pnum_locals = num_locals; return TRUE; } @@ -3501,7 +3500,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd, file_ptr off; Elf_Internal_Shdr *hdr; - off = elf_tdata (abfd)->next_file_pos; + off = elf_next_file_pos (abfd); hdr = &elf_tdata (abfd)->symtab_hdr; off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); @@ -3513,7 +3512,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd, hdr = &elf_tdata (abfd)->strtab_hdr; off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; /* Now that we know where the .strtab section goes, write it out. */ @@ -3564,13 +3563,13 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) ++segs; } - if (elf_tdata (abfd)->eh_frame_hdr) + if (elf_eh_frame_hdr (abfd)) { /* We need a PT_GNU_EH_FRAME segment. */ ++segs; } - if (elf_tdata (abfd)->stack_flags) + if (elf_stack_flags (abfd)) { /* We need a PT_GNU_STACK segment. */ ++segs; @@ -3632,8 +3631,7 @@ _bfd_elf_find_segment_containing_section (bfd * abfd, asection * section) struct elf_segment_map *m; Elf_Internal_Phdr *p; - for (m = elf_tdata (abfd)->segment_map, - p = elf_tdata (abfd)->phdr; + for (m = elf_seg_map (abfd), p = elf_tdata (abfd)->phdr; m != NULL; m = m->next, p++) { @@ -3717,7 +3715,7 @@ elf_modify_segment_map (bfd *abfd, sections from the segment map. We also remove excluded sections. Finally, any PT_LOAD segment without sections is removed. */ - m = &elf_tdata (abfd)->segment_map; + m = &elf_seg_map (abfd); while (*m) { unsigned int i, new_count; @@ -3761,7 +3759,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) const struct elf_backend_data *bed = get_elf_backend_data (abfd); bfd_boolean no_user_phdrs; - no_user_phdrs = elf_tdata (abfd)->segment_map == NULL; + no_user_phdrs = elf_seg_map (abfd) == NULL; if (info != NULL) info->user_phdrs = !no_user_phdrs; @@ -3872,7 +3870,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) program headers we will need. */ if (count > 0) { - bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size; + bfd_size_type phdr_size = elf_program_header_size (abfd); if (phdr_size == (bfd_size_type) -1) phdr_size = get_program_header_size (abfd, info); @@ -4117,7 +4115,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME segment. */ - eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr; + eh_frame_hdr = elf_eh_frame_hdr (abfd); if (eh_frame_hdr != NULL && (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0) { @@ -4134,7 +4132,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) pm = &m->next; } - if (elf_tdata (abfd)->stack_flags) + if (elf_stack_flags (abfd)) { amt = sizeof (struct elf_segment_map); m = (struct elf_segment_map *) bfd_zalloc (abfd, amt); @@ -4142,7 +4140,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) goto error_return; m->next = NULL; m->p_type = PT_GNU_STACK; - m->p_flags = elf_tdata (abfd)->stack_flags; + m->p_flags = elf_stack_flags (abfd); m->p_align = bed->stack_align; m->p_flags_valid = 1; m->p_align_valid = m->p_align != 0; @@ -4198,15 +4196,15 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) } free (sections); - elf_tdata (abfd)->segment_map = mfirst; + elf_seg_map (abfd) = mfirst; } if (!elf_modify_segment_map (abfd, info, no_user_phdrs)) return FALSE; - for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (count = 0, m = elf_seg_map (abfd); m != NULL; m = m->next) ++count; - elf_tdata (abfd)->program_header_size = count * bed->s->sizeof_phdr; + elf_program_header_size (abfd) = count * bed->s->sizeof_phdr; return TRUE; @@ -4370,7 +4368,7 @@ assign_file_positions_for_load_sections (bfd *abfd, return FALSE; alloc = 0; - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) { ++alloc; if (m->header_size) @@ -4391,32 +4389,32 @@ assign_file_positions_for_load_sections (bfd *abfd, elf_elfheader (abfd)->e_phnum = alloc; - if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1) - elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr; + if (elf_program_header_size (abfd) == (bfd_size_type) -1) + elf_program_header_size (abfd) = alloc * bed->s->sizeof_phdr; else - BFD_ASSERT (elf_tdata (abfd)->program_header_size + BFD_ASSERT (elf_program_header_size (abfd) >= alloc * bed->s->sizeof_phdr); if (alloc == 0) { - elf_tdata (abfd)->next_file_pos = bed->s->sizeof_ehdr; + elf_next_file_pos (abfd) = bed->s->sizeof_ehdr; return TRUE; } - /* We're writing the size in elf_tdata (abfd)->program_header_size, + /* We're writing the size in elf_program_header_size (abfd), see assign_file_positions_except_relocs, so make sure we have that amount allocated, with trailing space cleared. - The variable alloc contains the computed need, while elf_tdata - (abfd)->program_header_size contains the size used for the + The variable alloc contains the computed need, while + elf_program_header_size (abfd) contains the size used for the layout. See ld/emultempl/elf-generic.em:gld${EMULATION_NAME}_map_segments where the layout is forced to according to a larger size in the last iterations for the testcase ld-elf/header. */ - BFD_ASSERT (elf_tdata (abfd)->program_header_size % bed->s->sizeof_phdr + BFD_ASSERT (elf_program_header_size (abfd) % bed->s->sizeof_phdr == 0); phdrs = (Elf_Internal_Phdr *) bfd_zalloc2 (abfd, - (elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr), + (elf_program_header_size (abfd) / bed->s->sizeof_phdr), sizeof (Elf_Internal_Phdr)); elf_tdata (abfd)->phdr = phdrs; if (phdrs == NULL) @@ -4434,7 +4432,7 @@ assign_file_positions_for_load_sections (bfd *abfd, header_pad -= off; off += header_pad; - for (m = elf_tdata (abfd)->segment_map, p = phdrs, j = 0; + for (m = elf_seg_map (abfd), p = phdrs, j = 0; m != NULL; m = m->next, p++, j++) { @@ -4815,7 +4813,7 @@ assign_file_positions_for_load_sections (bfd *abfd, } } - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; return TRUE; } @@ -4841,10 +4839,9 @@ assign_file_positions_for_non_load_sections (bfd *abfd, i_shdrpp = elf_elfsections (abfd); num_sec = elf_numsections (abfd); - off = elf_tdata (abfd)->next_file_pos; + off = elf_next_file_pos (abfd); for (i = 1, hdrpp = i_shdrpp + 1; i < num_sec; i++, hdrpp++) { - struct elf_obj_tdata *tdata = elf_tdata (abfd); Elf_Internal_Shdr *hdr; hdr = *hdrpp; @@ -4874,9 +4871,9 @@ assign_file_positions_for_non_load_sections (bfd *abfd, } else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA) && hdr->bfd_section == NULL) - || hdr == i_shdrpp[tdata->symtab_section] - || hdr == i_shdrpp[tdata->symtab_shndx_section] - || hdr == i_shdrpp[tdata->strtab_section]) + || hdr == i_shdrpp[elf_onesymtab (abfd)] + || hdr == i_shdrpp[elf_symtab_shndx (abfd)] + || hdr == i_shdrpp[elf_strtab_sec (abfd)]) hdr->sh_offset = -1; else off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); @@ -4891,9 +4888,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, phdrs_paddr = 0; hdrs_segment = NULL; phdrs = elf_tdata (abfd)->phdr; - for (m = elf_tdata (abfd)->segment_map, p = phdrs; - m != NULL; - m = m->next, p++) + for (m = elf_seg_map (abfd), p = phdrs; m != NULL; m = m->next, p++) { ++count; if (p->p_type != PT_LOAD) @@ -4939,7 +4934,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, s = hdrs_segment->sections[0]; else /* Use the first (i.e. lowest-addressed) section in any segment. */ - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->count != 0) { s = m->sections[0]; @@ -4963,9 +4958,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, } } - for (m = elf_tdata (abfd)->segment_map, p = phdrs; - m != NULL; - m = m->next, p++) + for (m = elf_seg_map (abfd), p = phdrs; m != NULL; m = m->next, p++) { if (p->p_type == PT_GNU_RELRO) { @@ -4976,7 +4969,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, { /* During linking the range of the RELRO segment is passed in link_info. */ - for (lm = elf_tdata (abfd)->segment_map, lp = phdrs; + for (lm = elf_seg_map (abfd), lp = phdrs; lm != NULL; lm = lm->next, lp++) { @@ -5074,7 +5067,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd, } } - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; return TRUE; } @@ -5123,9 +5116,9 @@ assign_file_positions_except_relocs (bfd *abfd, hdr = *hdrpp; if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA) && hdr->bfd_section == NULL) - || i == tdata->symtab_section - || i == tdata->symtab_shndx_section - || i == tdata->strtab_section) + || i == elf_onesymtab (abfd) + || i == elf_symtab_shndx (abfd) + || i == elf_strtab_sec (abfd)) { hdr->sh_offset = -1; } @@ -5153,12 +5146,12 @@ assign_file_positions_except_relocs (bfd *abfd, } /* Write out the program headers. */ - alloc = tdata->program_header_size / bed->s->sizeof_phdr; + alloc = elf_program_header_size (abfd) / bed->s->sizeof_phdr; if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0 || bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0) return FALSE; - off = tdata->next_file_pos; + off = elf_next_file_pos (abfd); } /* Place the section headers. */ @@ -5166,7 +5159,7 @@ assign_file_positions_except_relocs (bfd *abfd, i_ehdrp->e_shoff = off; off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; - tdata->next_file_pos = off; + elf_next_file_pos (abfd) = off; return TRUE; } @@ -5269,7 +5262,7 @@ _bfd_elf_assign_file_positions_for_relocs (bfd *abfd) unsigned int i, num_sec; Elf_Internal_Shdr **shdrpp; - off = elf_tdata (abfd)->next_file_pos; + off = elf_next_file_pos (abfd); num_sec = elf_numsections (abfd); for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++) @@ -5282,7 +5275,7 @@ _bfd_elf_assign_file_positions_for_relocs (bfd *abfd) off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE); } - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; } bfd_boolean @@ -5331,7 +5324,7 @@ _bfd_elf_write_object_contents (bfd *abfd) return FALSE; if (bed->elf_backend_final_write_processing) - (*bed->elf_backend_final_write_processing) (abfd, t->linker); + (*bed->elf_backend_final_write_processing) (abfd, elf_linker (abfd)); if (!bed->s->write_shdrs_and_ehdr (abfd)) return FALSE; @@ -6073,7 +6066,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) free (sections); } - elf_tdata (obfd)->segment_map = map_first; + elf_seg_map (obfd) = map_first; /* If we had to estimate the number of program headers that were going to be needed, then check our estimate now and adjust @@ -6267,7 +6260,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd) pointer_to_map = &map->next; } - elf_tdata (obfd)->segment_map = map_first; + elf_seg_map (obfd) = map_first; return TRUE; } @@ -6558,7 +6551,7 @@ _bfd_elf_copy_private_header_data (bfd *ibfd, bfd *obfd) entry point, because the latter is called after the section contents have been set, which means that the program headers have already been worked out. */ - if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL) + if (elf_seg_map (obfd) == NULL && elf_tdata (ibfd)->phdr != NULL) { if (! copy_private_bfd_data (ibfd, obfd)) return FALSE; @@ -6606,11 +6599,11 @@ _bfd_elf_copy_private_symbol_data (bfd *ibfd, shndx = MAP_ONESYMTAB; else if (shndx == elf_dynsymtab (ibfd)) shndx = MAP_DYNSYMTAB; - else if (shndx == elf_tdata (ibfd)->strtab_section) + else if (shndx == elf_strtab_sec (ibfd)) shndx = MAP_STRTAB; - else if (shndx == elf_tdata (ibfd)->shstrtab_section) + else if (shndx == elf_shstrtab_sec (ibfd)) shndx = MAP_SHSTRTAB; - else if (shndx == elf_tdata (ibfd)->symtab_shndx_section) + else if (shndx == elf_symtab_shndx (ibfd)) shndx = MAP_SYM_SHNDX; osym->internal_elf_sym.st_shndx = shndx; } @@ -6635,10 +6628,11 @@ swap_out_syms (bfd *abfd, bfd_byte *outbound_syms; bfd_byte *outbound_shndx; int idx; + unsigned int num_locals; bfd_size_type amt; bfd_boolean name_local_sections; - if (!elf_map_symbols (abfd)) + if (!elf_map_symbols (abfd, &num_locals)) return FALSE; /* Dump out the symtabs. */ @@ -6652,7 +6646,7 @@ swap_out_syms (bfd *abfd, symtab_hdr->sh_type = SHT_SYMTAB; symtab_hdr->sh_entsize = bed->s->sizeof_sym; symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1); - symtab_hdr->sh_info = elf_num_locals (abfd) + 1; + symtab_hdr->sh_info = num_locals + 1; symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align; symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr; @@ -6786,13 +6780,13 @@ swap_out_syms (bfd *abfd, shndx = elf_dynsymtab (abfd); break; case MAP_STRTAB: - shndx = elf_tdata (abfd)->strtab_section; + shndx = elf_strtab_sec (abfd); break; case MAP_SHSTRTAB: - shndx = elf_tdata (abfd)->shstrtab_section; + shndx = elf_shstrtab_sec (abfd); break; case MAP_SYM_SHNDX: - shndx = elf_tdata (abfd)->symtab_shndx_section; + shndx = elf_symtab_shndx (abfd); break; default: shndx = SHN_ABS; @@ -7723,21 +7717,21 @@ _bfd_elf_sizeof_headers (bfd *abfd, struct bfd_link_info *info) if (!info->relocatable) { - bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size; + bfd_size_type phdr_size = elf_program_header_size (abfd); if (phdr_size == (bfd_size_type) -1) { struct elf_segment_map *m; phdr_size = 0; - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) phdr_size += bed->s->sizeof_phdr; if (phdr_size == 0) phdr_size = get_program_header_size (abfd, info); } - elf_tdata (abfd)->program_header_size = phdr_size; + elf_program_header_size (abfd) = phdr_size; ret += phdr_size; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 97b1bf0..8fc25db 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -15531,7 +15531,7 @@ elf32_arm_modify_segment_map (bfd *abfd, /* If there is already a PT_ARM_EXIDX header, then we do not want to add another one. This situation arises when running "strip"; the input binary already has the header. */ - m = elf_tdata (abfd)->segment_map; + m = elf_seg_map (abfd); while (m && m->p_type != PT_ARM_EXIDX) m = m->next; if (!m) @@ -15544,8 +15544,8 @@ elf32_arm_modify_segment_map (bfd *abfd, m->count = 1; m->sections[0] = sec; - m->next = elf_tdata (abfd)->segment_map; - elf_tdata (abfd)->segment_map = m; + m->next = elf_seg_map (abfd); + elf_seg_map (abfd) = m; } } @@ -16138,15 +16138,15 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd, dynsec = bfd_get_section_by_name (abfd, ".dynamic"); if (dynsec) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_DYNAMIC) break; if (m == NULL) { m = _bfd_elf_make_dynamic_segment (abfd, dynsec); - m->next = elf_tdata (abfd)->segment_map; - elf_tdata (abfd)->segment_map = m; + m->next = elf_seg_map (abfd); + elf_seg_map (abfd) = m; } } diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index f5d03e5..d198560 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -775,8 +775,7 @@ _lm32fdpic_osec_to_segment (bfd *output_bfd, asection *osec) Elf_Internal_Phdr *p; /* Find the segment that contains the output_section. */ - for (m = elf_tdata (output_bfd)->segment_map, - p = elf_tdata (output_bfd)->phdr; + for (m = elf_seg_map (output_bfd), p = elf_tdata (output_bfd)->phdr; m != NULL; m = m->next, p++) { diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index bf14206..8925d5a 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2436,7 +2436,7 @@ ppc_elf_modify_segment_map (bfd *abfd, If we find that case, we split the segment. We maintain the original output section order. */ - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) { if (m->count == 0) continue; diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 5000eb7..8cca4b1 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -3510,7 +3510,7 @@ elf32_rx_modify_program_headers (bfd * abfd ATTRIBUTE_UNUSED, bed = get_elf_backend_data (abfd); tdata = elf_tdata (abfd); phdr = tdata->phdr; - count = tdata->program_header_size / bed->s->sizeof_phdr; + count = elf_program_header_size (abfd) / bed->s->sizeof_phdr; if (ignore_lma) for (i = count; i-- != 0;) diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index cb4ff52..c72bbfb 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -2152,7 +2152,7 @@ spu_elf_check_vma (struct bfd_link_info *info) htab->local_store = hi + 1 - lo; - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_LOAD) for (i = 0; i < m->count; i++) if (m->sections[i]->size != 0 @@ -4175,7 +4175,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info) /* Find the extents of our loadable image. */ lo = (unsigned int) -1; hi = 0; - for (m = elf_tdata (info->output_bfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (info->output_bfd); m != NULL; m = m->next) if (m->p_type == PT_LOAD) for (i = 0; i < m->count; i++) if (m->sections[i]->size != 0) @@ -5198,7 +5198,7 @@ spu_elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info) return TRUE; toe = bfd_get_section_by_name (abfd, ".toe"); - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_LOAD && m->count > 1) for (i = 0; i < m->count; i++) if ((s = m->sections[i]) == toe @@ -5248,7 +5248,7 @@ spu_elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info) as PF_OVERLAY) will be placed into SPU local store on startup. */ /* Move all overlay segments onto a separate list. */ - p = &elf_tdata (abfd)->segment_map; + p = &elf_seg_map (abfd); p_overlay = &m_overlay; while (*p != NULL) { @@ -5266,8 +5266,8 @@ spu_elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info) } /* Re-insert overlay segments at the head of the segment map. */ - *p_overlay = elf_tdata (abfd)->segment_map; - elf_tdata (abfd)->segment_map = m_overlay; + *p_overlay = elf_seg_map (abfd); + elf_seg_map (abfd) = m_overlay; return TRUE; } @@ -5302,14 +5302,14 @@ spu_elf_modify_program_headers (bfd *abfd, struct bfd_link_info *info) bed = get_elf_backend_data (abfd); tdata = elf_tdata (abfd); phdr = tdata->phdr; - count = tdata->program_header_size / bed->s->sizeof_phdr; + count = elf_program_header_size (abfd) / bed->s->sizeof_phdr; htab = spu_hash_table (info); if (htab->num_overlays != 0) { struct elf_segment_map *m; unsigned int o; - for (i = 0, m = elf_tdata (abfd)->segment_map; m; ++i, m = m->next) + for (i = 0, m = elf_seg_map (abfd); m; ++i, m = m->next) if (m->count != 0 && (o = spu_elf_section_data (m->sections[0])->u.o.ovl_index) != 0) { diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 0d5fa6e..8348fd8 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -2687,7 +2687,7 @@ elf64_hppa_modify_segment_map (bfd *abfd, s = bfd_get_section_by_name (abfd, ".interp"); if (! s) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_PHDR) break; if (m == NULL) @@ -2703,12 +2703,12 @@ elf64_hppa_modify_segment_map (bfd *abfd, m->p_paddr_valid = 1; m->includes_phdrs = 1; - m->next = elf_tdata (abfd)->segment_map; - elf_tdata (abfd)->segment_map = m; + m->next = elf_seg_map (abfd); + elf_seg_map (abfd) = m; } } - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_LOAD) { unsigned int i; diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 63a3306..e296c5c 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1152,9 +1152,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic) verhdr = NULL; else verhdr = &elf_tdata (abfd)->dynversym_hdr; - if ((elf_tdata (abfd)->dynverdef_section != 0 + if ((elf_dynverdef (abfd) != 0 && elf_tdata (abfd)->verdef == NULL) - || (elf_tdata (abfd)->dynverref_section != 0 + || (elf_dynverref (abfd) != 0 && elf_tdata (abfd)->verref == NULL)) { if (!_bfd_elf_slurp_version_tables (abfd, FALSE)) diff --git a/bfd/elflink.c b/bfd/elflink.c index b652bec..e9ed760 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -5667,9 +5667,9 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, /* Determine any GNU_STACK segment requirements, after the backend has had a chance to set a default segment size. */ if (info->execstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; + elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X; else if (info->noexecstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; + elf_stack_flags (output_bfd) = PF_R | PF_W; else { bfd *inputobj; @@ -5696,7 +5696,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, exec = PF_X; } if (notesec || info->stacksize > 0) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | exec; + elf_stack_flags (output_bfd) = PF_R | PF_W | exec; if (notesec && exec && info->relocatable && notesec->output_section != bfd_abs_section_ptr) notesec->output_section->flags |= SEC_CODE; @@ -10783,10 +10783,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) /* sh_offset is set just below. */ symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align; - off = elf_tdata (abfd)->next_file_pos; + off = elf_next_file_pos (abfd); off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); - /* Note that at this point elf_tdata (abfd)->next_file_pos is + /* Note that at this point elf_next_file_pos (abfd) is incorrect. We do not yet know the size of the .symtab section. We correct next_file_pos below, after we do know the size. */ @@ -11242,7 +11242,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) symstrtab_hdr->sh_addralign = 1; off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE); - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; if (bfd_get_symcount (abfd) > 0) { @@ -11538,7 +11538,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) elf_final_link_free (abfd, &flinfo); - elf_tdata (abfd)->linker = TRUE; + elf_linker (abfd) = TRUE; if (attr_section) { diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index 864feba..9e46bbc 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -1094,7 +1094,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd, s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_archext); if (s && (s->flags & SEC_LOAD)) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_IA_64_ARCHEXT) break; if (m == NULL) @@ -1109,7 +1109,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd, m->sections[0] = s; /* We want to put it after the PHDR and INTERP segments. */ - pm = &elf_tdata (abfd)->segment_map; + pm = &elf_seg_map (abfd); while (*pm != NULL && ((*pm)->p_type == PT_PHDR || (*pm)->p_type == PT_INTERP)) @@ -1129,7 +1129,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd, if (s && (s->flags & SEC_LOAD)) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_IA_64_UNWIND) { int i; @@ -1158,7 +1158,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd, m->next = NULL; /* We want to put it last. */ - pm = &elf_tdata (abfd)->segment_map; + pm = &elf_seg_map (abfd); while (*pm != NULL) pm = &(*pm)->next; *pm = m; @@ -1181,7 +1181,7 @@ elfNN_ia64_modify_program_headers (bfd *abfd, struct elf_segment_map *m; Elf_Internal_Phdr *p; - for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++) + for (p = tdata->phdr, m = elf_seg_map (abfd); m != NULL; m = m->next, p++) if (m->p_type == PT_LOAD) { int i; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index f5296a4..2843118 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -11141,7 +11141,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, s = bfd_get_section_by_name (abfd, ".reginfo"); if (s != NULL && (s->flags & SEC_LOAD) != 0) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_MIPS_REGINFO) break; if (m == NULL) @@ -11156,7 +11156,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, m->sections[0] = s; /* We want to put it after the PHDR and INTERP segments. */ - pm = &elf_tdata (abfd)->segment_map; + pm = &elf_seg_map (abfd); while (*pm != NULL && ((*pm)->p_type == PT_PHDR || (*pm)->p_type == PT_INTERP)) @@ -11186,7 +11186,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, { struct elf_segment_map *options_segment; - pm = &elf_tdata (abfd)->segment_map; + pm = &elf_seg_map (abfd); while (*pm != NULL && ((*pm)->p_type == PT_PHDR || (*pm)->p_type == PT_INTERP)) @@ -11216,7 +11216,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, && bfd_get_section_by_name (abfd, ".dynamic") != NULL && bfd_get_section_by_name (abfd, ".mdebug") != NULL) { - for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) + for (m = elf_seg_map (abfd); m != NULL; m = m->next) if (m->p_type == PT_MIPS_RTPROC) break; if (m == NULL) @@ -11242,7 +11242,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, } /* We want to put it after the DYNAMIC segment. */ - pm = &elf_tdata (abfd)->segment_map; + pm = &elf_seg_map (abfd); while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC) pm = &(*pm)->next; if (*pm != NULL) @@ -11256,7 +11256,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, /* On IRIX5, the PT_DYNAMIC segment includes the .dynamic, .dynstr, .dynsym, and .hash sections, and everything in between. */ - for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; + for (pm = &elf_seg_map (abfd); *pm != NULL; pm = &(*pm)->next) if ((*pm)->p_type == PT_DYNAMIC) break; @@ -11363,7 +11363,7 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, && !SGI_COMPAT (abfd) && bfd_get_section_by_name (abfd, ".dynamic")) { - for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next) + for (pm = &elf_seg_map (abfd); *pm != NULL; pm = &(*pm)->next) if ((*pm)->p_type == PT_NULL) break; if (*pm == NULL) |