Home | History | Annotate | Download | only in bfd

Lines Matching refs:abfd

60 	bool bfd_check_format (bfd *abfd, bfd_format format);
63 Verify if the file attached to the BFD @var{abfd} is compatible
101 bfd_check_format (bfd *abfd, bfd_format format)
103 return bfd_check_format_matches (abfd, format, NULL);
136 bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve,
139 preserve->tdata = abfd->tdata.any;
140 preserve->arch_info = abfd->arch_info;
141 preserve->flags = abfd->flags;
142 preserve->iovec = abfd->iovec;
143 preserve->iostream = abfd->iostream;
144 preserve->sections = abfd->sections;
145 preserve->section_last = abfd->section_last;
146 preserve->section_count = abfd->section_count;
148 preserve->symcount = abfd->symcount;
149 preserve->read_only = abfd->read_only;
150 preserve->start_address = abfd->start_address;
151 preserve->section_htab = abfd->section_htab;
152 preserve->marker = bfd_alloc (abfd, 1);
153 preserve->build_id = abfd->build_id;
158 return bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc,
170 io_reinit (bfd *abfd, struct bfd_preserve *preserve)
172 if (abfd->iovec != preserve->iovec)
175 won't do anything unless abfd->iovec is the cache_iovec.
181 bfd_cache_close (abfd);
182 abfd->iovec = preserve->iovec;
183 abfd->iostream = preserve->iostream;
186 if ((abfd->flags & BFD_CLOSED_BY_CACHE) != 0
187 && (abfd->flags & BFD_IN_MEMORY) != 0
190 bfd_open_file (abfd);
192 abfd->flags = preserve->flags;
198 bfd_reinit (bfd *abfd, unsigned int section_id,
203 cleanup (abfd);
204 abfd->tdata.any = NULL;
205 abfd->arch_info = &bfd_default_arch_struct;
206 io_reinit (abfd, preserve);
207 abfd->symcount = 0;
208 abfd->read_only = 0;
209 abfd->start_address = 0;
210 abfd->build_id = NULL;
211 bfd_section_list_clear (abfd);
217 bfd_preserve_restore (bfd *abfd, struct bfd_preserve *preserve)
219 bfd_hash_table_free (&abfd->section_htab);
221 abfd->tdata.any = preserve->tdata;
222 abfd->arch_info = preserve->arch_info;
223 io_reinit (abfd, preserve);
224 abfd->section_htab = preserve->section_htab;
225 abfd->sections = preserve->sections;
226 abfd->section_last = preserve->section_last;
227 abfd->section_count = preserve->section_count;
229 abfd->symcount = preserve->symcount;
230 abfd->read_only = preserve->read_only;
231 abfd->start_address = preserve->start_address;
232 abfd->build_id = preserve->build_id;
236 bfd_release (abfd, preserve->marker);
245 bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
251 void *tdata = abfd->tdata.any;
252 abfd->tdata.any = preserve->tdata;
253 preserve->cleanup (abfd);
254 abfd->tdata.any = tdata;
365 /* Set lto_type in ABFD. */
368 bfd_set_lto_type (bfd *abfd)
370 if (abfd->format == bfd_object
371 && abfd->lto_type == lto_non_object
372 && (abfd->flags
374 | (bfd_get_flavour (abfd) == bfd_target_elf_flavour
377 asection *sec = abfd->sections;
384 if (bfd_seek (abfd, 0, SEEK_SET) == 0
385 && bfd_read (llvm_ir_magic, 4, abfd) == 4
401 abfd->object_only_section = sec;
411 && bfd_get_section_contents (abfd, sec, &lsection, 0,
421 abfd->lto_type = type;
431 (bfd *abfd, bfd_format format, char ***matching);
446 bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
458 struct per_xvec_messages messages = { abfd, PER_XVEC_NO_TARGET, NULL, NULL };
465 if (!bfd_read_p (abfd)
466 || (unsigned int) abfd->format >= (unsigned int) bfd_type_end)
472 if (abfd->format != bfd_unknown)
473 return abfd->format == format;
482 if (!bfd_cache_set_uncloseable (abfd, true, &old_in_format_matches))
491 bfd_cache_set_uncloseable (abfd, old_in_format_matches, NULL);
497 abfd->format = format;
498 save_targ = abfd->xvec;
505 if (!bfd_preserve_save (abfd, &preserve, NULL))
516 && abfd->format == bfd_object
517 && abfd->target_defaulted
518 && !abfd->is_linker_input
519 && abfd->plugin_format != bfd_plugin_no)
521 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
525 abfd->xvec = bfd_plugin_vec ();
527 cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
531 bfd_reinit (abfd, initial_section_id, &preserve, cleanup);
532 bfd_release (abfd, preserve.marker);
533 preserve.marker = bfd_alloc (abfd, 1);
534 abfd->xvec = save_targ;
539 if (!(abfd->plugin_format == bfd_plugin_no
542 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
546 cleanup = BFD_SEND_FMT (abfdabfd));
549 if (abfd->format != bfd_archive
553 || (bfd_has_map (abfd)
558 || (!bfd_has_map (abfd)
564 if (!abfd->target_defaulted && !abfd->is_linker_input)
590 abfd->plugin_format is set to bfd_plugin_no. (This occurs
596 || (((abfd->is_linker_input && match_count != 0)
597 || abfd->plugin_format == bfd_plugin_no)
604 bfd_reinit (abfd, initial_section_id, &preserve, cleanup);
611 bfd_release (abfd, *high_water);
612 *high_water = bfd_alloc (abfd, 1);
615 abfd->xvec = *target;
621 clear_messages (&messages, abfd->xvec);
623 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
627 cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
630 if (abfd->format != bfd_archive
631 || (bfd_has_map (abfd)
637 if (abfd->xvec == bfd_default_vector[0])
640 matching_vector[match_count] = abfd->xvec;
643 int match_priority = abfd->xvec->match_priority;
645 && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
649 Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
650 elf_backend_data *bed = get_elf_backend_data (abfd);
663 right_targ = abfd->xvec;
680 match_targ = abfd->xvec;
681 if (!bfd_preserve_save (abfd, &preserve_match, cleanup))
756 cleanup = bfd_preserve_restore (abfd, &preserve_match);
760 abfd->xvec = right_targ;
762 matched is the one we want, then ABFD should still be in a usable
770 bfd_reinit (abfd, initial_section_id, &preserve, cleanup);
771 bfd_release (abfd, preserve.marker);
772 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
774 cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
784 if (abfd->direction == both_direction)
785 abfd->output_has_begun = true;
789 bfd_preserve_finish (abfd, &preserve_match);
790 bfd_preserve_finish (abfd, &preserve);
793 print_and_clear_messages (&messages, abfd->xvec);
795 bfd_set_lto_type (abfd);
798 bool ret = bfd_cache_set_uncloseable (abfd, old_in_format_matches, NULL);
810 cleanup (abfd);
811 abfd->xvec = save_targ;
812 abfd->format = bfd_unknown;
818 abfd->xvec = save_targ;
819 abfd->format = bfd_unknown;
837 cleanup (abfd);
840 bfd_preserve_finish (abfd, &preserve_match);
842 bfd_preserve_restore (abfd, &preserve);
845 bfd_cache_set_uncloseable (abfd, old_in_format_matches, NULL);
855 bool bfd_set_format (bfd *abfd, bfd_format format);
858 This function sets the file format of the BFD @var{abfd} to the
865 bfd_set_format (bfd *abfd, bfd_format format)
867 if (bfd_read_p (abfd)
868 || (unsigned int) abfd->format >= (unsigned int) bfd_type_end)
874 if (abfd->format != bfd_unknown)
875 return abfd->format == format;
878 abfd->format = format;
880 if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd)))
882 abfd->format = bfd_unknown;