Lines Matching defs:abfd

61 _bfd_elf_swap_verdef_in (bfd *abfd,
65 dst->vd_version = H_GET_16 (abfd, src->vd_version);
66 dst->vd_flags = H_GET_16 (abfd, src->vd_flags);
67 dst->vd_ndx = H_GET_16 (abfd, src->vd_ndx);
68 dst->vd_cnt = H_GET_16 (abfd, src->vd_cnt);
69 dst->vd_hash = H_GET_32 (abfd, src->vd_hash);
70 dst->vd_aux = H_GET_32 (abfd, src->vd_aux);
71 dst->vd_next = H_GET_32 (abfd, src->vd_next);
77 _bfd_elf_swap_verdef_out (bfd *abfd,
81 H_PUT_16 (abfd, src->vd_version, dst->vd_version);
82 H_PUT_16 (abfd, src->vd_flags, dst->vd_flags);
83 H_PUT_16 (abfd, src->vd_ndx, dst->vd_ndx);
84 H_PUT_16 (abfd, src->vd_cnt, dst->vd_cnt);
85 H_PUT_32 (abfd, src->vd_hash, dst->vd_hash);
86 H_PUT_32 (abfd, src->vd_aux, dst->vd_aux);
87 H_PUT_32 (abfd, src->vd_next, dst->vd_next);
93 _bfd_elf_swap_verdaux_in (bfd *abfd,
97 dst->vda_name = H_GET_32 (abfd, src->vda_name);
98 dst->vda_next = H_GET_32 (abfd, src->vda_next);
104 _bfd_elf_swap_verdaux_out (bfd *abfd,
108 H_PUT_32 (abfd, src->vda_name, dst->vda_name);
109 H_PUT_32 (abfd, src->vda_next, dst->vda_next);
115 _bfd_elf_swap_verneed_in (bfd *abfd,
119 dst->vn_version = H_GET_16 (abfd, src->vn_version);
120 dst->vn_cnt = H_GET_16 (abfd, src->vn_cnt);
121 dst->vn_file = H_GET_32 (abfd, src->vn_file);
122 dst->vn_aux = H_GET_32 (abfd, src->vn_aux);
123 dst->vn_next = H_GET_32 (abfd, src->vn_next);
129 _bfd_elf_swap_verneed_out (bfd *abfd,
133 H_PUT_16 (abfd, src->vn_version, dst->vn_version);
134 H_PUT_16 (abfd, src->vn_cnt, dst->vn_cnt);
135 H_PUT_32 (abfd, src->vn_file, dst->vn_file);
136 H_PUT_32 (abfd, src->vn_aux, dst->vn_aux);
137 H_PUT_32 (abfd, src->vn_next, dst->vn_next);
143 _bfd_elf_swap_vernaux_in (bfd *abfd,
147 dst->vna_hash = H_GET_32 (abfd, src->vna_hash);
148 dst->vna_flags = H_GET_16 (abfd, src->vna_flags);
149 dst->vna_other = H_GET_16 (abfd, src->vna_other);
150 dst->vna_name = H_GET_32 (abfd, src->vna_name);
151 dst->vna_next = H_GET_32 (abfd, src->vna_next);
157 _bfd_elf_swap_vernaux_out (bfd *abfd,
161 H_PUT_32 (abfd, src->vna_hash, dst->vna_hash);
162 H_PUT_16 (abfd, src->vna_flags, dst->vna_flags);
163 H_PUT_16 (abfd, src->vna_other, dst->vna_other);
164 H_PUT_32 (abfd, src->vna_name, dst->vna_name);
165 H_PUT_32 (abfd, src->vna_next, dst->vna_next);
171 _bfd_elf_swap_versym_in (bfd *abfd,
175 dst->vs_vers = H_GET_16 (abfd, src->vs_vers);
181 _bfd_elf_swap_versym_out (bfd *abfd,
185 H_PUT_16 (abfd, src->vs_vers, dst->vs_vers);
229 bfd_elf_mkobject (bfd *abfd)
231 if (abfd->tdata.any == NULL)
233 abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
234 if (abfd->tdata.any == NULL)
238 elf_tdata (abfd)->program_header_size = (bfd_size_type) -1;
244 bfd_elf_mkcorefile (bfd *abfd)
247 return bfd_elf_mkobject (abfd);
251 bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
258 i_shdrp = elf_elfsections (abfd);
260 || shindex >= elf_numsections (abfd)
274 || (shstrtab = bfd_alloc (abfd, shstrtabsize + 1)) == NULL
275 || bfd_seek (abfd, offset, SEEK_SET) != 0)
277 else if (bfd_bread (shstrtab, shstrtabsize, abfd) != shstrtabsize)
291 bfd_elf_string_from_elf_section (bfd *abfd,
300 if (elf_elfsections (abfd) == NULL || shindex >= elf_numsections (abfd))
303 hdr = elf_elfsections (abfd)[shindex];
306 && bfd_elf_get_str_section (abfd, shindex) == NULL)
311 unsigned int shstrndx = elf_elfheader(abfd)->e_shstrndx;
314 abfd, strindex, (unsigned long) hdr->sh_size,
317 : bfd_elf_string_from_elf_section (abfd, shstrndx, hdr->sh_name)));
433 bfd_elf_sym_name (bfd *abfd,
444 && isym->st_shndx < elf_numsections (abfd)
447 iname = elf_elfsections (abfd)[isym->st_shndx]->sh_name;
448 shindex = elf_elfheader (abfd)->e_shstrndx;
451 name = bfd_elf_string_from_elf_section (abfd, shindex, iname);
455 name = bfd_section_name (abfd, sym_sec);
473 group_signature (bfd *abfd, Elf_Internal_Shdr *ghdr)
482 hdr = elf_elfsections (abfd) [ghdr->sh_link];
484 || ! bfd_section_from_shdr (abfd, ghdr->sh_link))
488 hdr = &elf_tdata (abfd)->symtab_hdr;
489 if (bfd_elf_get_elf_syms (abfd, hdr, 1, ghdr->sh_info,
493 return bfd_elf_sym_name (abfd, hdr, &isym, NULL);
499 setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
501 unsigned int num_group = elf_tdata (abfd)->num_group;
511 shnum = elf_numsections (abfd);
522 Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
531 elf_tdata (abfd)->num_group = num_group;
539 elf_tdata (abfd)->num_group = num_group;
540 elf_tdata (abfd)->group_sect_ptr
541 = bfd_alloc2 (abfd, num_group, sizeof (Elf_Internal_Shdr *));
542 if (elf_tdata (abfd)->group_sect_ptr == NULL)
548 Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
556 elf_tdata (abfd)->group_sect_ptr[num_group] = shdr;
562 shdr->contents = bfd_alloc2 (abfd, shdr->sh_size,
568 (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
575 if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0
576 || (bfd_bread (shdr->contents, shdr->sh_size, abfd)
592 idx = H_GET_32 (abfd, src);
604 (_("%B: invalid SHT_GROUP entry"), abfd));
607 dest->shdr = elf_elfsections (abfd)[idx];
620 Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i];
652 gname = group_signature (abfd, shdr);
675 abfd, newsect);
681 _bfd_elf_setup_sections (bfd *abfd)
684 unsigned int num_group = elf_tdata (abfd)->num_group;
689 for (s = abfd->sections; s != NULL; s = s->next)
701 = get_elf_backend_data (abfd);
705 abfd, s);
711 this_hdr = elf_elfsections (abfd)[elfsec];
736 Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i];
756 abfd,
758 bfd_elf_string_from_elf_section (abfd,
759 (elf_elfheader (abfd)
770 bfd_elf_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec)
779 _bfd_elf_make_section_from_shdr (bfd *abfd,
791 bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
795 newsect = bfd_make_section_anyway (abfd, name);
809 if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
810 || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
811 || ! bfd_set_section_alignment (abfd, newsect,
840 if (!setup_group (abfd, hdr, newsect))
895 bed = get_elf_backend_data (abfd);
900 if (! bfd_set_section_flags (abfd, newsect, flags))
911 phdr = elf_tdata (abfd)->phdr;
912 for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
917 if (i < elf_elfheader (abfd)->e_phnum)
919 phdr = elf_tdata (abfd)->phdr;
920 for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
977 struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
988 bfd_elf_find_section (bfd *abfd, char *name)
995 i_shdrp = elf_elfsections (abfd);
998 shstrtab = bfd_elf_get_str_section (abfd,
999 elf_elfheader (abfd)->e_shstrndx);
1002 max = elf_numsections (abfd);
1028 bfd_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
1052 merge_sections_remove_hook (bfd *abfd ATTRIBUTE_UNUSED,
1062 _bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
1079 if (! _bfd_add_merge_section (abfd,
1088 _bfd_merge_sections (abfd, info, elf_hash_table (info)->merge_info,
1154 _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
1161 p = elf_tdata (abfd)->phdr;
1167 c = elf_elfheader (abfd)->e_phnum;
1179 bfd_fprintf_vma (abfd, f, p->p_offset);
1181 bfd_fprintf_vma (abfd, f, p->p_vaddr);
1183 bfd_fprintf_vma (abfd, f, p->p_paddr);
1186 bfd_fprintf_vma (abfd, f, p->p_filesz);
1188 bfd_fprintf_vma (abfd, f, p->p_memsz);
1199 s = bfd_get_section_by_name (abfd, ".dynamic");
1210 if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
1213 elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
1216 shlink = elf_elfsections (abfd)[elfsec]->sh_link;
1218 extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
1219 swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
1230 (*swap_dyn_in) (abfd, extdyn, &dyn);
1311 string = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
1323 if ((elf_dynverdef (abfd) != 0 && elf_tdata (abfd)->verdef == NULL)
1324 || (elf_dynverref (abfd) != 0 && elf_tdata (abfd)->verref == NULL))
1326 if (! _bfd_elf_slurp_version_tables (abfd, FALSE))
1330 if (elf_dynverdef (abfd) != 0)
1335 for (t = elf_tdata (abfd)->verdef; t != NULL; t = t->vd_nextdef)
1355 if (elf_dynverref (abfd) != 0)
1360 for (t = elf_tdata (abfd)->verref; t != NULL; t = t->vn_nextref)
1384 bfd_elf_print_symbol (bfd *abfd,
1397 bfd_fprintf_vma (abfd, file, symbol->value);
1410 bed = get_elf_backend_data (abfd);
1412 name = (*bed->elf_backend_print_symbol_all) (abfd, filep, symbol);
1417 bfd_print_symbol_vandf (abfd, file, symbol);
1429 bfd_fprintf_vma (abfd, file, val);
1432 if (elf_tdata (abfd)->dynversym_section != 0
1433 && (elf_tdata (abfd)->dynverdef_section != 0
1434 || elf_tdata (abfd)->dynverref_section != 0))
1445 else if (vernum <= elf_tdata (abfd)->cverdefs)
1447 elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
1453 for (t = elf_tdata (abfd)->verref;
1621 bfd *abfd,
1628 int can_refcount = get_elf_backend_data (abfd)->can_refcount;
1638 ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
1647 _bfd_elf_link_hash_table_create (bfd *abfd)
1656 if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc,
1671 bfd_elf_set_dt_needed_name (bfd *abfd, const char *name)
1673 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1674 && bfd_get_format (abfd) == bfd_object)
1675 elf_dt_name (abfd) = name;
1679 bfd_elf_get_dyn_lib_class (bfd *abfd)
1682 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1683 && bfd_get_format (abfd) == bfd_object)
1684 lib_class = elf_dyn_lib_class (abfd);
1691 bfd_elf_set_dyn_lib_class (bfd *abfd, enum dynamic_lib_link_class lib_class)
1693 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1694 && bfd_get_format (abfd) == bfd_object)
1695 elf_dyn_lib_class (abfd) = lib_class;
1702 bfd_elf_get_needed_list (bfd *abfd ATTRIBUTE_UNUSED,
1714 bfd_elf_get_runpath_list (bfd *abfd ATTRIBUTE_UNUSED,
1727 bfd_elf_get_dt_soname (bfd *abfd)
1729 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1730 && bfd_get_format (abfd) == bfd_object)
1731 return elf_dt_name (abfd);
1739 bfd_elf_get_bfd_needed_list (bfd *abfd,
1752 if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
1753 || bfd_get_format (abfd) != bfd_object)
1756 s = bfd_get_section_by_name (abfd, ".dynamic");
1760 if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
1763 elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
1767 shlink = elf_elfsections (abfd)[elfsec]->sh_link;
1769 extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
1770 swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
1778 (*swap_dyn_in) (abfd, extdyn, &dyn);
1790 string = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
1795 l = bfd_alloc (abfd, amt);
1799 l->by = abfd;
1846 bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
1848 Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[shindex];
1849 Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
1850 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1853 name = bfd_elf_string_from_elf_section (abfd,
1854 elf_elfheader (abfd)->e_shstrndx,
1874 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1877 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
1879 if (hdr->sh_link > elf_numsections (abfd)
1880 || elf_elfsections (abfd)[hdr->sh_link] == NULL)
1882 if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
1889 if (elf_dynsymtab (abfd) != 0)
1891 dynsymhdr = elf_elfsections (abfd)[elf_dynsymtab (abfd)];
1898 num_sec = elf_numsections (abfd);
1901 dynsymhdr = elf_elfsections (abfd)[i];
1913 if (elf_onesymtab (abfd) == shindex)
1918 BFD_ASSERT (elf_onesymtab (abfd) == 0);
1919 elf_onesymtab (abfd) = shindex;
1920 elf_tdata (abfd)->symtab_hdr = *hdr;
1921 elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr;
1922 abfd->flags |= HAS_SYMS;
1931 && (abfd->flags & DYNAMIC) != 0
1932 && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
1939 if (elf_elfsections (abfd)[elf_symtab_shndx (abfd)]->sh_link != shindex)
1943 num_sec = elf_numsections (abfd);
1946 Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
1954 Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
1960 return bfd_section_from_shdr (abfd, i);
1965 if (elf_dynsymtab (abfd) == shindex)
1970 BFD_ASSERT (elf_dynsymtab (abfd) == 0);
1971 elf_dynsymtab (abfd) = shindex;
1972 elf_tdata (abfd)->dynsymtab_hdr = *hdr;
1973 elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr;
1974 abfd->flags |= HAS_SYMS;
1978 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1981 if (elf_symtab_shndx (abfd) == shindex)
1984 BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
1985 elf_symtab_shndx (abfd) = shindex;
1986 elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
1987 elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
1995 elf_tdata (abfd)->shstrtab_hdr = *hdr;
1996 elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
1999 if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
2002 elf_tdata (abfd)->strtab_hdr = *hdr;
2003 elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
2006 if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
2009 elf_tdata (abfd)->dynstrtab_hdr = *hdr;
2010 hdr = &elf_tdata (abfd)->dynstrtab_hdr;
2011 elf_elfsections (abfd)[shindex] = hdr;
2014 return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
2021 if (elf_onesymtab (abfd) == 0 || elf_dynsymtab (abfd) == 0)
2025 num_sec = elf_numsections (abfd);
2028 Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
2034 if (! bfd_section_from_shdr (abfd, i))
2036 if (elf_onesymtab (abfd) == i)
2038 if (elf_dynsymtab (abfd) == i)
2043 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
2051 unsigned int num_sec = elf_numsections (abfd);
2064 abfd, hdr->sh_link, name, shindex));
2065 return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
2076 if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
2077 && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
2085 if (elf_elfsections (abfd)[scan]->sh_type == SHT_SYMTAB
2086 || elf_elfsections (abfd)[scan]->sh_type == SHT_DYNSYM)
2101 if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
2102 || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
2103 && ! bfd_section_from_shdr (abfd, hdr->sh_link))
2112 if (hdr->sh_link != elf_onesymtab (abfd)
2116 || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
2117 || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
2118 return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
2121 if (! bfd_section_from_shdr (abfd, hdr->sh_info))
2123 target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
2135 hdr2 = bfd_alloc (abfd, amt);
2139 elf_elfsections (abfd)[shindex] = hdr2;
2148 abfd->flags |= HAS_RELOC;
2153 elf_dynverdef (abfd) = shindex;
2154 elf_tdata (abfd)->dynverdef_hdr = *hdr;
2155 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
2160 elf_dynversym (abfd) = shindex;
2161 elf_tdata (abfd)->dynversym_hdr = *hdr;
2162 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
2165 elf_dynverref (abfd) = shindex;
2166 elf_tdata (abfd)->dynverref_hdr = *hdr;
2167 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
2178 name = group_signature (abfd, hdr);
2181 if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
2215 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
2217 _bfd_elf_parse_attributes (abfd, hdr);
2222 if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
2233 abfd, name, hdr->sh_type);
2236 return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
2245 abfd, name, hdr->sh_type);
2256 abfd, name, hdr->sh_type);
2259 return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
2265 abfd, name, hdr->sh_type);
2277 bfd_section_from_r_symndx (bfd *abfd,
2288 if (cache->abfd == abfd && cache->indx[ent] == r_symndx)
2291 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
2292 if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx,
2296 if (cache->abfd != abfd)
2299 cache->abfd = abfd;
2307 s = bfd_section_from_elf_index (abfd, isym.st_shndx);
2318 bfd_section_from_elf_index (bfd *abfd, unsigned int index)
2320 if (index >= elf_numsections (abfd))
2322 return elf_elfsections (abfd)[index]->bfd_section;
2506 _bfd_elf_get_sec_type_attr (bfd *abfd, asection *sec)
2516 bed = get_elf_backend_data (abfd);
2543 _bfd_elf_new_section_hook (bfd *abfd, asection *sec)
2552 sdata = bfd_zalloc (abfd, sizeof (*sdata));
2559 bed = get_elf_backend_data (abfd);
2568 if ((!sec->flags && abfd->direction != read_direction)
2571 ssect = (*bed->get_sec_type_attr) (abfd, sec);
2579 return _bfd_generic_new_section_hook (abfd, sec);
2605 _bfd_elf_make_section_from_phdr (bfd *abfd,
2621 name = bfd_alloc (abfd, len);
2625 newsect = bfd_make_section (abfd, name);
2654 name = bfd_alloc (abfd, len);
2658 newsect = bfd_make_section (abfd, name);
2678 bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int index)
2685 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "null");
2688 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "load");
2691 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "dynamic");
2694 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "interp");
2697 if (! _bfd_elf_make_section_from_phdr (abfd, hdr, index, "note"))
2699 if (! elfcore_read_notes (abfd, hdr->p_offset, hdr->p_filesz))
2704 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "shlib");
2707 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "phdr");
2710 return _bfd_elf_make_section_from_phdr (abfd, hdr, index,
2714 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "stack");
2717 return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro");
2721 bed = get_elf_backend_data (abfd);
2722 return bed->elf_backend_section_from_phdr (abfd, hdr, index, "proc");
2731 _bfd_elf_init_reloc_shdr (bfd *abfd,
2737 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
2740 name = bfd_alloc (abfd, amt);
2745 (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
2765 elf_fake_sections (bfd *abfd, asection *asect, void *failedptrarg)
2767 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
2781 this_hdr->sh_name = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
2848 if (get_elf_backend_data (abfd)->may_use_rela_p)
2853 if (get_elf_backend_data (abfd)->may_use_rel_p)
2867 this_hdr->sh_info = elf_tdata (abfd)->cverdefs;
2869 BFD_ASSERT (elf_tdata (abfd)->cverdefs == 0
2870 || this_hdr->sh_info == elf_tdata (abfd)->cverdefs);
2879 this_hdr->sh_info = elf_tdata (abfd)->cverrefs;
2881 BFD_ASSERT (elf_tdata (abfd)->cverrefs == 0
2882 || this_hdr->sh_info == elf_tdata (abfd)->cverrefs);
2930 && !(*bed->elf_backend_fake_sections) (abfd, this_hdr, asect))
2945 && !_bfd_elf_init_reloc_shdr (abfd,
2955 bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
2977 if (elf_section_syms (abfd) != NULL)
2978 symindx = elf_section_syms (abfd)[sec->index]->udata.i;
2989 sec->contents = bfd_alloc (abfd, sec->size);
3023 H_PUT_32 (abfd, idx, loc);
3032 H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
3040 assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
3042 struct elf_obj_tdata *t = elf_tdata (abfd);
3050 _bfd_elf_strtab_clear_all_refs (elf_shstrtab (abfd));
3056 for (sec = abfd->sections; sec != NULL; sec = sec->next)
3065 bfd_section_list_remove (abfd, sec);
3066 abfd->section_count--;
3078 for (sec = abfd->sections; sec; sec = sec->next)
3088 _bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name);
3096 _bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel_hdr.sh_name);
3104 _bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel_hdr2->sh_name);
3113 _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);
3114 elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
3116 if (bfd_get_symcount (abfd) > 0)
3121 _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);
3128 = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
3136 _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->strtab_hdr.sh_name);
3139 _bfd_elf_strtab_finalize (elf_shstrtab (abfd));
3140 t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
3142 elf_numsections (abfd) = section_number;
3143 elf_elfheader (abfd)->e_shnum = section_number;
3145 elf_elfheader (abfd)->e_shnum -= SHN_HIRESERVE + 1 - SHN_LORESERVE;
3149 i_shdrp = bfd_zalloc2 (abfd, section_number, sizeof (Elf_Internal_Shdr *));
3153 i_shdrp[0] = bfd_zalloc (abfd, sizeof (Elf_Internal_Shdr));
3156 bfd_release (abfd, i_shdrp);
3160 elf_elfsections (abfd) = i_shdrp;
3163 if (bfd_get_symcount (abfd) > 0)
3166 if (elf_numsections (abfd) > SHN_LORESERVE)
3175 for (sec = abfd->sections; sec; sec = sec->next)
3218 abfd, d->this_hdr.bfd_section,
3241 abfd, d->this_hdr.bfd_section, s, s->owner);
3257 = get_elf_backend_data (abfd);
3261 abfd, sec);
3275 s = bfd_get_section_by_name (abfd, ".dynsym");
3285 s = bfd_get_section_by_name (abfd, name);
3307 s = bfd_get_section_by_name (abfd, alc);
3316 = 4 + 2 * bfd_get_arch_size (abfd) / 8;
3328 s = bfd_get_section_by_name (abfd, ".dynstr");
3337 s = bfd_get_section_by_name (abfd, (sec->flags & SEC_ALLOC)
3348 s = bfd_get_section_by_name (abfd, ".dynsym");
3362 i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd),
3371 sym_is_global (bfd *abfd, asymbol *sym)
3374 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
3376 return (*bed->elf_backend_sym_is_global) (abfd, sym);
3388 ignore_section_sym (bfd *abfd, asymbol *sym)
3392 || (sym->section->owner != abfd
3393 && (sym->section->output_section->owner != abfd
3398 elf_map_symbols (bfd *abfd)
3400 unsigned int symcount = bfd_get_symcount (abfd);
3401 asymbol **syms = bfd_get_outsymbols (abfd);
3417 for (asect = abfd->sections; asect; asect = asect->next)
3424 sect_syms = bfd_zalloc2 (abfd, max_index, sizeof (asymbol *));
3427 elf_section_syms (abfd) = sect_syms;
3428 elf_num_section_syms (abfd) = max_index;
3437 && !ignore_section_sym (abfd, sym))
3441 if (sec->owner != abfd)
3451 if (ignore_section_sym (abfd, syms[idx]))
3453 if (!sym_is_global (abfd, syms[idx]))
3463 for (asect = abfd->sections; asect; asect = asect->next)
3467 if (!sym_is_global (abfd, asect->symbol))
3475 new_syms = bfd_alloc2 (abfd, num_locals + num_globals, sizeof (asymbol *));
3485 if (ignore_section_sym (abfd, sym))
3487 if (!sym_is_global (abfd, sym))
3494 for (asect = abfd->sections; asect; asect = asect->next)
3502 if (!sym_is_global (abfd, sym))
3511 bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
3513 elf_num_locals (abfd) = num_locals;
3514 elf_num_globals (abfd) = num_globals;
3556 _bfd_elf_compute_section_file_positions (bfd *abfd,
3559 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
3564 if (abfd->output_has_begun)
3569 (*bed->elf_backend_begin_write_processing) (abfd, link_info);
3571 if (! prep_headers (abfd))
3576 (*bed->elf_backend_post_process_headers) (abfd, link_info);
3579 bfd_map_over_sections (abfd, elf_fake_sections, &failed);
3583 if (!assign_section_numbers (abfd, link_info))
3587 if (link_info == NULL && bfd_get_symcount (abfd) > 0)
3590 int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));
3592 if (! swap_out_syms (abfd, &strtab, relocatable_p))
3598 bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
3603 shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
3608 shstrtab_hdr->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
3615 if (!assign_file_positions_except_relocs (abfd, link_info))
3618 if (link_info == NULL && bfd_get_symcount (abfd) > 0)
3623 off = elf_tdata (abfd)->next_file_pos;
3625 hdr = &elf_tdata (abfd)->symtab_hdr;
3628 hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
3632 hdr = &elf_tdata (abfd)->strtab_hdr;
3635 elf_tdata (abfd)->next_file_pos = off;
3639 if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
3640 || ! _bfd_stringtab_emit (abfd, strtab))
3645 abfd->output_has_begun = TRUE;
3654 get_program_header_size (bfd *abfd, struct bfd_link_info *info)
3664 s = bfd_get_section_by_name (abfd, ".interp");
3674 if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
3679 if (elf_tdata (abfd)->relro)
3687 if (elf_tdata (abfd)->eh_frame_hdr)
3693 if (elf_tdata (abfd)->stack_flags)
3699 for (s = abfd->sections; s != NULL; s = s->next)
3709 for (s = abfd->sections; s != NULL; s = s->next)
3720 bed = get_elf_backend_data (abfd);
3725 a = (*bed->elf_backend_additional_program_headers) (abfd, info);
3737 make_mapping (bfd *abfd,
3750 m = bfd_zalloc (abfd, amt);
3773 _bfd_elf_make_dynamic_segment (bfd *abfd, asection *dynsec)
3777 m = bfd_zalloc (abfd, sizeof (struct elf_segment_map));
3791 elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
3801 m = &elf_tdata (abfd)->segment_map;
3824 bed = get_elf_backend_data (abfd);
3827 if (!(*bed->elf_backend_modify_segment_map) (abfd, info))
3837 _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
3842 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
3844 if (elf_tdata (abfd)->segment_map == NULL
3845 && bfd_count_sections (abfd) != 0)
3865 sections = bfd_malloc2 (bfd_count_sections (abfd), sizeof (asection *));
3870 for (s = abfd->sections; s != NULL; s = s->next)
3878 BFD_ASSERT (i <= bfd_count_sections (abfd));
3891 s = bfd_get_section_by_name (abfd, ".interp");
3895 m = bfd_zalloc (abfd, amt);
3909 m = bfd_zalloc (abfd, amt);
3929 dynsec = bfd_get_section_by_name (abfd, ".dynamic");
3940 bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
3943 phdr_size = get_program_header_size (abfd, info);
3944 if ((abfd->flags & D_PAGED) == 0
3988 else if ((abfd->flags & D_PAGED) == 0)
4018 new_segment = info->callbacks->override_segment_assignment (info, abfd, hdr, last_hdr, new_segment);
4037 m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
4062 m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
4073 m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
4085 for (s = abfd->sections; s != NULL; s = s->next)
4091 m = bfd_zalloc (abfd, amt);
4117 m = bfd_zalloc (abfd, amt);
4139 eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr;
4144 m = bfd_zalloc (abfd, amt);
4156 if (elf_tdata (abfd)->stack_flags)
4159 m = bfd_zalloc (abfd, amt);
4164 m->p_flags = elf_tdata (abfd)->stack_flags;
4171 if (dynsec != NULL && elf_tdata (abfd)->relro)
4176 m = bfd_zalloc (abfd, amt);
4189 elf_tdata (abfd)->segment_map = mfirst;
4192 if (!elf_modify_segment_map (abfd, info))
4195 for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
4197 elf_tdata (abfd)->program_header_size = count * bed->s->sizeof_phdr;
4299 assign_file_positions_for_load_sections (bfd *abfd,
4302 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
4312 && !elf_modify_segment_map (abfd, link_info))
4316 for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
4319 elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
4320 elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
4321 elf_elfheader (abfd)->e_phnum = alloc;
4323 if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1)
4324 elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
4326 BFD_ASSERT (elf_tdata (abfd)->program_header_size
4331 elf_tdata (abfd)->next_file_pos = bed->s->sizeof_ehdr;
4335 phdrs = bfd_alloc2 (abfd, alloc, sizeof (Elf_Internal_Phdr));
4336 elf_tdata (abfd)->phdr = phdrs;
4341 if ((abfd->flags & D_PAGED) != 0)
4347 for (m = elf_tdata (abfd)->segment_map, p = phdrs, j = 0;
4361 && !(elf_elfheader (abfd)->e_type == ET_CORE
4387 && (abfd->flags & D_PAGED) != 0)
4430 secalign = bfd_get_section_alignment (abfd, *secpp);
4487 abfd);
4510 abfd);
4544 || (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core))
4572 align = (bfd_size_type) 1 << bfd_get_section_alignment (abfd, sec);
4588 abfd, sec, (unsigned long) sec->lma);
4601 if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core)
4656 || (abfd->flags & D_PAGED) == 0))
4673 if (p->p_type == PT_LOAD && bfd_get_format (abfd) != bfd_core)
4686 abfd, sec, j);
4693 elf_tdata (abfd)->next_file_pos = off;
4700 assign_file_positions_for_non_load_sections (bfd *abfd,
4703 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
4716 i_shdrpp = elf_elfsections (abfd);
4717 num_sec = elf_numsections (abfd);
4718 off = elf_tdata (abfd)->next_file_pos;
4721 struct elf_obj_tdata *tdata = elf_tdata (abfd);
4735 abfd,
4740 if ((abfd->flags & D_PAGED) != 0 && hdr->sh_size != 0)
4772 phdrs = elf_tdata (abfd)->phdr;
4773 for (m = elf_tdata (abfd)->segment_map, p = phdrs;
4798 for (m = elf_tdata (abfd)->segment_map, p = phdrs;
4805 && (p->p_type != PT_NOTE || bfd_get_format (abfd) != bfd_core))
4867 elf_tdata (abfd)->next_file_pos = off;
4887 assign_file_positions_except_relocs (bfd *abfd,
4890 struct elf_obj_tdata *tdata = elf_tdata (abfd);
4891 Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
4893 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
4895 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
4896 && bfd_get_format (abfd) != bfd_core)
4898 Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
4899 unsigned int num_sec = elf_numsections (abfd);
4938 if (!assign_file_positions_for_load_sections (abfd, link_info))
4942 if (!assign_file_positions_for_non_load_sections (abfd, link_info))
4947 if (!(*bed->elf_backend_modify_program_headers) (abfd, link_info))
4953 if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0
4954 || bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0)
4971 prep_headers (bfd *abfd)
4977 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
4979 i_ehdrp = elf_elfheader (abfd);
4980 i_shdrp = elf_elfsections (abfd);
4986 elf_shstrtab (abfd) = shstrtab;
4995 bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
5000 if ((abfd->flags & DYNAMIC) != 0)
5002 else if ((abfd->flags & EXEC_P) != 0)
5004 else if (bfd_get_format (abfd) == bfd_core)
5009 switch (bfd_get_arch (abfd))
5036 i_ehdrp->e_entry = bfd_get_start_address (abfd);
5040 if (abfd->flags & EXEC_P)
5050 elf_tdata (abfd)->symtab_hdr.sh_name =
5052 elf_tdata (abfd)->strtab_hdr.sh_name =
5054 elf_tdata (abfd)->shstrtab_hdr.sh_name =
5056 if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
5057 || elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
5058 || elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1)
5068 _bfd_elf_assign_file_positions_for_relocs (bfd *abfd)
5074 off = elf_tdata (abfd)->next_file_pos;
5076 num_sec = elf_numsections (abfd);
5077 for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++)
5087 elf_tdata (abfd)->next_file_pos = off;
5091 _bfd_elf_write_object_contents (bfd *abfd)
5093 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
5099 if (! abfd->output_has_begun
5100 && ! _bfd_elf_compute_section_file_positions (abfd, NULL))
5103 i_shdrp = elf_elfsections (abfd);
5104 i_ehdrp = elf_elfheader (abfd);
5107 bfd_map_over_sections (abfd, bed->s->write_relocs, &failed);
5111 _bfd_elf_assign_file_positions_for_relocs (abfd);
5114 num_sec = elf_numsections (abfd);
5118 (*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
5123 if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
5124 || bfd_bwrite (i_shdrp[count]->contents, amt, abfd) != amt)
5132 if (elf_shstrtab (abfd) != NULL
5133 && (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
5134 || !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
5138 (*bed->elf_backend_final_write_processing) (abfd,
5139 elf_tdata (abfd)->linker);
5141 return bed->s->write_shdrs_and_ehdr (abfd);
5145 _bfd_elf_write_corefile_contents (bfd *abfd)
5148 return _bfd_elf_write_object_contents (abfd);
5154 _bfd_elf_section_from_bfd_section (bfd *abfd, struct bfd_section *asect)
5172 bed = get_elf_backend_data (abfd);
5177 if ((*bed->elf_backend_section_from_bfd_section) (abfd, asect, &retval))
5191 _bfd_elf_symbol_from_bfd_symbol (bfd *abfd, asymbol **asym_ptr_ptr)
5210 if (sec->owner != abfd && sec->output_section != NULL)
5212 if (sec->owner == abfd
5213 && (indx = sec->index) < elf_num_section_syms (abfd)
5214 && elf_section_syms (abfd)[indx] != NULL)
5215 asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
5226 abfd, bfd_asymbol_name (asym_ptr));
6248 swap_out_syms (bfd *abfd,
6265 if (!elf_map_symbols (abfd))
6273 bed = get_elf_backend_data (abfd);
6274 symcount = bfd_get_symcount (abfd);
6275 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
6279 symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
6282 symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
6285 outbound_syms = bfd_alloc2 (abfd, 1 + symcount, bed->s->sizeof_sym);
6294 symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
6298 outbound_shndx = bfd_zalloc2 (abfd, 1 + symcount,
6323 bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx);
6331 && bed->elf_backend_name_local_section_symbols (abfd));
6333 syms = bfd_get_outsymbols (abfd);
6360 type_ptr = elf_symbol_from (abfd, syms[idx]);
6375 (abfd, syms[idx]->section);
6405 shndx = elf_onesymtab (abfd);
6408 shndx = elf_dynsymtab (abfd);
6411 shndx = elf_tdata (abfd)->strtab_section;
6414 shndx = elf_tdata (abfd)->shstrtab_section;
6417 shndx = elf_tdata (abfd)->symtab_shndx_section;
6425 shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
6438 sec2 = bfd_get_section_by_name (abfd, sec->name);
6450 shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
6515 bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx);
6542 _bfd_elf_get_symtab_upper_bound (bfd *abfd)
6546 Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
6548 symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
6557 _bfd_elf_get_dynamic_symtab_upper_bound (bfd *abfd)
6561 Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
6563 if (elf_dynsymtab (abfd) == 0)
6569 symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
6578 _bfd_elf_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
6587 _bfd_elf_canonicalize_reloc (bfd *abfd,
6594 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
6596 if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE))
6609 _bfd_elf_canonicalize_symtab (bfd *abfd, asymbol **allocation)
6611 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
6612 long symcount = bed->s->slurp_symbol_table (abfd, allocation, FALSE);
6615 bfd_get_symcount (abfd) = symcount;
6620 _bfd_elf_canonicalize_dynamic_symtab (bfd *abfd,
6623 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
6624 long symcount = bed->s->slurp_symbol_table (abfd, allocation, TRUE);
6627 bfd_get_dynamic_symcount (abfd) = symcount;
6637 _bfd_elf_get_dynamic_reloc_upper_bound (bfd *abfd)
6642 if (elf_dynsymtab (abfd) == 0)
6649 for (s = abfd->sections; s != NULL; s = s->next)
6651 && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
6669 _bfd_elf_canonicalize_dynamic_reloc (bfd *abfd,
6677 if (elf_dynsymtab (abfd) == 0)
6683 slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
6685 for (s = abfd->sections; s != NULL; s = s->next)
6688 && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
6695 if (! (*slurp_relocs) (abfd, s, syms, TRUE))
6714 _bfd_elf_slurp_version_tables (bfd *abfd, bfd_boolean default_imported_symver)
6719 if (elf_dynverref (abfd) != 0)
6727 hdr = &elf_tdata (abfd)->dynverref_hdr;
6729 elf_tdata (abfd)->verref = bfd_zalloc2 (abfd, hdr->sh_info,
6731 if (elf_tdata (abfd)->verref == NULL)
6734 elf_tdata (abfd)->cverrefs = hdr->sh_info;
6740 elf_tdata (abfd)->verref = NULL;
6741 elf_tdata (abfd)->cverrefs = 0;
6744 if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
6745 || bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size)
6755 iverneed = elf_tdata (abfd)->verref;
6762 _bfd_elf_swap_verneed_in (abfd, everneed, iverneed);
6764 iverneed->vn_bfd = abfd;
6767 bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
6776 iverneed->vn_auxptr = bfd_alloc2 (abfd, iverneed->vn_cnt,
6791 _bfd_elf_swap_vernaux_in (abfd, evernaux, ivernaux);
6794 bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
6832 if (elf_dynverdef (abfd) != 0)
6843 hdr = &elf_tdata (abfd)->dynverdef_hdr;
6848 if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
6849 || bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size)
6869 _bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem);
6889 elf_tdata (abfd)->verdef = bfd_zalloc2 (abfd, maxidx,
6891 if (elf_tdata (abfd)->verdef == NULL)
6894 elf_tdata (abfd)->cverdefs = maxidx;
6897 iverdefarr = elf_tdata (abfd)->verdef;
6904 _bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem);
6909 elf_tdata (abfd)->verdef = NULL;
6910 elf_tdata (abfd)->cverdefs = 0;
6917 iverdef->vd_bfd = abfd;
6923 iverdef->vd_auxptr = bfd_alloc2 (abfd, iverdef->vd_cnt,
6938 _bfd_elf_swap_verdaux_in (abfd, everdaux, iverdaux);
6941 bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
6981 elf_tdata (abfd)->verdef = bfd_zalloc2 (abfd, freeidx,
6983 if (elf_tdata (abfd)->verdef == NULL)
6986 elf_tdata (abfd)->cverdefs = freeidx;
6995 iverdef = &elf_tdata (abfd)->verdef[freeidx - 1];;
7002 iverdef->vd_bfd = abfd;
7004 iverdef->vd_nodename = bfd_elf_get_dt_soname (abfd);
7008 iverdef->vd_auxptr = bfd_alloc (abfd, sizeof (Elf_Internal_Verdaux));
7027 _bfd_elf_make_empty_symbol (bfd *abfd)
7032 newsym = bfd_zalloc (abfd, amt);
7037 newsym->symbol.the_bfd = abfd;
7043 _bfd_elf_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
7055 _bfd_elf_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
7080 _bfd_elf_get_lineno (bfd *abfd ATTRIBUTE_UNUSED,
7088 _bfd_elf_set_arch_mach (bfd *abfd,
7094 if (arch != get_elf_backend_data (abfd)->arch
7096 && get_elf_backend_data (abfd)->arch != bfd_arch_unknown)
7099 return bfd_default_set_arch_mach (abfd, arch, machine);
7106 elf_find_function (bfd *abfd ATTRIBUTE_UNUSED,
7183 _bfd_elf_find_nearest_line (bfd *abfd,
7193 if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
7198 elf_find_function (abfd, section, symbols, offset,
7205 if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
7208 &elf_tdata (abfd)->dwarf2_find_line_info))
7211 elf_find_function (abfd, section, symbols, offset,
7218 if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
7221 &elf_tdata (abfd)->line_info))
7229 if (! elf_find_function (abfd, section, symbols, offset,
7240 _bfd_elf_find_line (bfd *abfd, asymbol **symbols, asymbol *symbol,
7243 return _bfd_dwarf2_find_line (abfd, symbols, symbol,
7245 &elf_tdata (abfd)->dwarf2_find_line_info);
7255 _bfd_elf_find_inliner_info (bfd *abfd,
7261 found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr,
7263 & elf_tdata (abfd)->dwarf2_find_line_info);
7268 _bfd_elf_sizeof_headers (bfd *abfd, struct bfd_link_info *info)
7270 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
7275 bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
7282 for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
7286 phdr_size = get_program_header_size (abfd, info);
7289 elf_tdata (abfd)->program_header_size = phdr_size;
7297 _bfd_elf_set_section_contents (bfd *abfd,
7306 if (! abfd->output_has_begun
7307 && ! _bfd_elf_compute_section_file_positions (abfd, NULL))
7312 if (bfd_seek (abfd, pos, SEEK_SET) != 0
7313 || bfd_bwrite (location, count, abfd) != count)
7320 _bfd_elf_no_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
7330 _bfd_elf_validate_reloc (bfd *abfd, arelent *areloc)
7334 if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
7368 howto = bfd_reloc_type_lookup (abfd, code);
7404 howto = bfd_reloc_type_lookup (abfd, code);
7418 abfd, areloc->howto->name);
7424 _bfd_elf_close_and_cleanup (bfd *abfd)
7426 if (bfd_get_format (abfd) == bfd_object)
7428 if (elf_tdata (abfd) != NULL && elf_shstrtab (abfd) != NULL)
7429 _bfd_elf_strtab_free (elf_shstrtab (abfd));
7430 _bfd_dwarf2_cleanup_debug_info (abfd);
7433 return _bfd_generic_close_and_cleanup (abfd);
7443 (bfd *abfd ATTRIBUTE_UNUSED, arelent *re ATTRIBUTE_UNUSED,
7470 elfcore_make_pid (bfd *abfd)
7472 return ((elf_tdata (abfd)->core_lwpid << 16)
7473 + (elf_tdata (abfd)->core_pid));
7482 elfcore_maybe_make_sect (bfd *abfd, char *name, asection *sect)
7486 if (bfd_get_section_by_name (abfd, name) != NULL)
7489 sect2 = bfd_make_section_with_flags (abfd, name, sect->flags);
7504 PID is elfcore_make_pid (abfd).
7507 _bfd_elfcore_make_pseudosection (bfd *abfd,
7519 sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd));
7521 threaded_name = bfd_alloc (abfd, len);
7526 sect = bfd_make_section_anyway_with_flags (abfd, threaded_name,
7534 return elfcore_maybe_make_sect (abfd, name, sect);
7546 elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
7561 if (elf_tdata (abfd)->core_signal == 0)
7562 elf_tdata (abfd)->core_signal = prstat.pr_cursig;
7563 elf_tdata (abfd)->core_pid = prstat.pr_pid;
7572 elf_tdata (abfd)->core_lwpid = prstat.pr_who;
7587 if (elf_tdata (abfd)->core_signal == 0)
7588 elf_tdata (abfd)->core_signal = prstat.pr_cursig;
7589 elf_tdata (abfd)->core_pid = prstat.pr_pid;
7598 elf_tdata (abfd)->core_lwpid = prstat.pr_who;
7610 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
7617 elfcore_make_note_pseudosection (bfd *abfd,
7621 return _bfd_elfcore_make_pseudosection (abfd, name,
7630 elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
7632 return elfcore_make_note_pseudosection (abfd, ".reg2", note);
7640 elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note)
7642 return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
7648 elfcore_grok_thrmisc (bfd *abfd, Elf_Internal_Note *note)
7650 return elfcore_make_note_pseudosection (abfd, ".tname", note);
7674 _bfd_elfcore_strndup (bfd *abfd, char *start, size_t max)
7685 dups = bfd_alloc (abfd, len + 1);
7697 elfcore_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
7705 elf_tdata (abfd)->core_program
7706 = _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
7709 elf_tdata (abfd)->core_command
7710 = _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
7721 elf_tdata (abfd)->core_program
7722 = _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
7725 elf_tdata (abfd)->core_command
7726 = _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
7743 char *command = elf_tdata (abfd)->core_command;
7756 elfcore_grok_pstatus (bfd *abfd, Elf_Internal_Note *note)
7768 elf_tdata (abfd)->core_pid = pstat.pr_pid;
7778 elf_tdata (abfd)->core_pid = pstat.pr_pid;
7791 elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
7808 elf_tdata (abfd)->core_lwpid = lwpstat.pr_lwpid;
7809 elf_tdata (abfd)->core_signal = lwpstat.pr_cursig;
7813 sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
7815 name = bfd_alloc (abfd, len);
7820 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
7837 if (!elfcore_maybe_make_sect (abfd, ".reg", sect))
7842 sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
7844 name = bfd_alloc (abfd, len);
7849 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
7866 return elfcore_maybe_make_sect (abfd, ".reg2", sect);
7872 elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
7889 elf_tdata (abfd)->core_signal = pstatus.data.process_info.signal;
7890 elf_tdata (abfd)->core_pid = pstatus.data.process_info.pid;
7898 name = bfd_alloc (abfd, len);
7904 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
7915 if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
7925 name = bfd_alloc (abfd, len);
7931 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
7950 elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
7952 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
7961 if ((*bed->elf_backend_grok_prstatus) (abfd, note))
7964 return elfcore_grok_prstatus (abfd, note);
7971 return elfcore_grok_pstatus (abfd, note);
7976 return elfcore_grok_lwpstatus (abfd, note);
7980 return elfcore_grok_prfpreg (abfd, note);
7984 return elfcore_grok_win32pstatus (abfd, note);
7990 return elfcore_grok_prxfpreg (abfd, note);
7997 if ((*bed->elf_backend_grok_psinfo) (abfd, note))
8000 return elfcore_grok_psinfo (abfd, note);
8007 asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
8014 sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
8021 return elfcore_grok_thrmisc (abfd, note);
8042 elfcore_grok_netbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
8045 elf_tdata (abfd)->core_signal
8046 = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
8049 elf_tdata (abfd)->core_pid
8050 = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x50);
8053 elf_tdata (abfd)->core_command
8054 = _bfd_elfcore_strndup (abfd, note->descdata + 0x7c, 31);
8056 return elfcore_make_note_pseudosection (abfd, ".note.netbsdcore.procinfo",
8061 elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
8066 elf_tdata (abfd)->core_lwpid = lwp;
8075 return elfcore_grok_netbsd_procinfo (abfd, note);
8087 switch (bfd_get_arch (abfd))
8097 return elfcore_make_note_pseudosection (abfd, ".reg", note);
8100 return elfcore_make_note_pseudosection (abfd, ".reg2", note);
8113 return elfcore_make_note_pseudosection (abfd, ".reg", note);
8116 return elfcore_make_note_pseudosection (abfd, ".reg2", note);
8126 elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)
8136 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
8139 *tid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
8142 flags = bfd_get_32 (abfd, (bfd_byte *) ddata + 8);
8145 if ((sig = bfd_get_16 (abfd, (bfd_byte *) ddata + 14)) > 0)
8147 elf_tdata (abfd)->core_signal = sig;
8148 elf_tdata (abfd)->core_lwpid = *tid;
8155 elf_tdata (abfd)->core_lwpid = *tid;
8160 name = bfd_alloc (abfd, strlen (buf) + 1);
8165 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
8173 return (elfcore_maybe_make_sect (abfd, ".qnx_core_status", sect));
8177 elfcore_grok_nto_regs (bfd *abfd,
8189 name = bfd_alloc (abfd, strlen (buf) + 1);
8194 sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
8203 if (elf_tdata (abfd)->core_lwpid == tid)
8204 return elfcore_maybe_make_sect (abfd, base, sect);
8215 elfcore_grok_nto_note (bfd *abfd, Elf_Internal_Note *note)
8225 return elfcore_make_note_pseudosection (abfd, ".qnx_core_info", note);
8227 return elfcore_grok_nto_status (abfd, note, &tid);
8229 return elfcore_grok_nto_regs (abfd, note, tid, ".reg");
8231 return elfcore_grok_nto_regs (abfd, note, tid, ".reg2");
8255 elfcore_write_note (bfd *abfd,
8278 H_PUT_32 (abfd, namesz, xnp->namesz);
8279 H_PUT_32 (abfd, size, xnp->descsz);
8280 H_PUT_32 (abfd, type, xnp->type);
8304 elfcore_write_prpsinfo (bfd *abfd,
8311 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
8316 ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
8336 return elfcore_write_note (abfd, buf, bufsiz,
8353 return elfcore_write_note (abfd, buf, bufsiz,
8361 elfcore_write_prstatus (bfd *abfd,
8369 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
8374 ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
8390 return elfcore_write_note (abfd, buf, bufsiz, note_name,
8402 return elfcore_write_note (abfd, buf, bufsiz, note_name,
8410 elfcore_write_lwpstatus (bfd *abfd,
8434 return elfcore_write_note (abfd, buf, bufsiz, note_name,
8441 elfcore_write_pstatus (bfd *abfd,
8450 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
8458 buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
8469 buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
8477 elfcore_write_prfpreg (bfd *abfd,
8484 return elfcore_write_note (abfd, buf, bufsiz,
8489 elfcore_write_thrmisc (bfd *abfd,
8497 return elfcore_write_note (abfd, buf, bufsiz,
8505 elfcore_write_prxfpreg (bfd *abfd,
8512 return elfcore_write_note (abfd, buf, bufsiz,
8517 elfcore_read_notes (bfd *abfd, file_ptr offset, bfd_size_type size)
8525 if (bfd_seek (abfd, offset, SEEK_SET) != 0)
8532 if (bfd_bread (buf, size, abfd) != size)
8546 in.type = H_GET_32 (abfd, xnp->type);
8548 in.namesz = H_GET_32 (abfd, xnp->namesz);
8551 in.descsz = H_GET_32 (abfd, xnp->descsz);
8557 if (! elfcore_grok_netbsd_note (abfd, &in))
8562 if (! elfcore_grok_nto_note (abfd, &in))
8567 if (! elfcore_grok_note (abfd, &in))
8586 bfd_get_elf_phdr_upper_bound (bfd *abfd)
8588 if (abfd->xvec->flavour != bfd_target_elf_flavour)
8594 return elf_elfheader (abfd)->e_phnum * sizeof (Elf_Internal_Phdr);
8606 bfd_get_elf_phdrs (bfd *abfd, void *phdrs)
8610 if (abfd->xvec->flavour != bfd_target_elf_flavour)
8616 num_phdrs = elf_elfheader (abfd)->e_phnum;
8617 memcpy (phdrs, elf_tdata (abfd)->phdr,
8624 _bfd_elf_sprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, char *buf, bfd_vma value)
8629 i_ehdrp = elf_elfheader (abfd);
8652 _bfd_elf_fprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, void *stream, bfd_vma value)
8657 i_ehdrp = elf_elfheader (abfd);
8690 _bfd_elf_rela_local_sym (bfd *abfd,
8706 _bfd_merged_section_offset (abfd, psec,
8727 _bfd_elf_rel_local_sym (bfd *abfd,
8737 return _bfd_merged_section_offset (abfd, psec,
8743 _bfd_elf_section_offset (bfd *abfd,
8754 return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
8787 _bfd_elf_get_synthetic_symtab (bfd *abfd,
8794 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
8808 if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0)
8820 relplt = bfd_get_section_by_name (abfd, relplt_name);
8825 if (hdr->sh_link != elf_dynsymtab (abfd)
8829 plt = bfd_get_section_by_name (abfd, ".plt");
8833 slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
8834 if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE))
9225 _bfd_elf_match_sections_by_type (bfd *abfd, const asection *asec,
9230 || abfd->xvec->flavour != bfd_target_elf_flavour
9238 _bfd_elf_set_osabi (bfd * abfd,
9243 i_ehdrp = elf_elfheader (abfd);
9245 i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;