这篇教程C++ BFD_ASSERT函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BFD_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ BFD_ASSERT函数的具体用法?C++ BFD_ASSERT怎么用?C++ BFD_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BFD_ASSERT函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _bfd_cgc_strtab_addrefvoid_bfd_cgc_strtab_addref (struct cgc_strtab_hash *tab, bfd_size_type idx){ if (idx == 0 || idx == (bfd_size_type) -1) return; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (idx < tab->size); ++tab->array[idx]->refcount;}
开发者ID:CyberGrandChallenge,项目名称:binutils,代码行数:9,
示例2: _bfd_elf_strtab_delrefvoid_bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx){ if (idx == 0 || idx == (bfd_size_type) -1) return; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (idx < tab->size); BFD_ASSERT (tab->array[idx]->refcount > 0); --tab->array[idx]->refcount;}
开发者ID:0mp,项目名称:freebsd,代码行数:10,
示例3: _bfd_elf_strtab_offsetbfd_size_type_bfd_elf_strtab_offset (struct elf_strtab_hash *tab, bfd_size_type idx){ struct elf_strtab_hash_entry *entry; if (idx == 0) return 0; BFD_ASSERT (idx < tab->size); BFD_ASSERT (tab->sec_size); entry = tab->array[idx]; BFD_ASSERT (entry->refcount > 0); entry->refcount--; return tab->array[idx]->u.index;}
开发者ID:0mp,项目名称:freebsd,代码行数:14,
示例4: bfd_plugin_object_pstatic const bfd_target *bfd_plugin_object_p (bfd *abfd){ int claimed = 0; int t = load_plugin (); struct ld_plugin_input_file file; if (!t) return NULL; file.name = abfd->filename; if (abfd->iostream) { file.fd = fileno ((FILE *) abfd->iostream); file.offset = 0; file.filesize = 0; /*FIXME*/ } else { bfd *archive = abfd->my_archive; BFD_ASSERT (archive); file.fd = fileno ((FILE *) archive->iostream); file.offset = abfd->origin; file.filesize = arelt_size (abfd); } file.handle = abfd; claim_file (&file, &claimed); if (!claimed) return NULL; return abfd->xvec;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:33,
示例5: _bfd_write_stab_stringsbfd_boolean_bfd_write_stab_strings (bfd *output_bfd, struct stab_info *sinfo){ if (bfd_is_abs_section (sinfo->stabstr->output_section)) /* The section was discarded from the link. */ return TRUE; BFD_ASSERT ((sinfo->stabstr->output_offset + _bfd_stringtab_size (sinfo->strings)) <= sinfo->stabstr->output_section->size); if (bfd_seek (output_bfd, (file_ptr) (sinfo->stabstr->output_section->filepos + sinfo->stabstr->output_offset), SEEK_SET) != 0) return FALSE; if (! _bfd_stringtab_emit (output_bfd, sinfo->strings)) return FALSE; /* We no longer need the stabs information. */ _bfd_stringtab_free (sinfo->strings); bfd_hash_table_free (&sinfo->includes); return TRUE;}
开发者ID:freebsd-riscv,项目名称:riscv-binutils-gdb,代码行数:26,
示例6: MYstatic bfd_booleanMY(write_object_contents) (bfd *abfd){ struct external_exec exec_bytes; struct internal_exec *execp = exec_hdr (abfd); obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k); switch (bfd_get_mach (abfd)) { case 32032: N_SET_MACHTYPE (execp, M_NS32032); break; case 32532: default: N_SET_MACHTYPE (execp, M_NS32532); break; } N_SET_FLAGS (execp, aout_backend_info (abfd)->exec_hdr_flags); WRITE_HEADERS (abfd, execp); return TRUE;}
开发者ID:eepp,项目名称:binutils-gdb,代码行数:25,
示例7: decompress_contentsstatic bfd_booleandecompress_contents (bfd_byte *compressed_buffer, bfd_size_type compressed_size, bfd_byte *uncompressed_buffer, bfd_size_type uncompressed_size){ z_stream strm; int rc; /* It is possible the section consists of several compressed buffers concatenated together, so we uncompress in a loop. */ strm.zalloc = NULL; strm.zfree = NULL; strm.opaque = NULL; strm.avail_in = compressed_size - 12; strm.next_in = (Bytef*) compressed_buffer + 12; strm.avail_out = uncompressed_size; BFD_ASSERT (Z_OK == 0); rc = inflateInit (&strm); while (strm.avail_in > 0 && strm.avail_out > 0) { if (rc != Z_OK) break; strm.next_out = ((Bytef*) uncompressed_buffer + (uncompressed_size - strm.avail_out)); rc = inflate (&strm, Z_FINISH); if (rc != Z_STREAM_END) break; rc = inflateReset (&strm); } rc |= inflateEnd (&strm); return rc == Z_OK && strm.avail_out == 0;}
开发者ID:5kg,项目名称:gdb,代码行数:34,
示例8: _bfd_elf_strtab_restore_size/* Downsizes strtab. Entries from IDX up to the current size are removed from the array. */void_bfd_elf_strtab_restore_size (struct elf_strtab_hash *tab, bfd_size_type idx){ bfd_size_type curr_size = tab->size; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (idx <= curr_size); tab->size = idx; for (; idx < curr_size; ++idx) { /* We don't remove entries from the hash table, just set their REFCOUNT to zero. Setting LEN zero will result in the size growing if the entry is added again. See _bfd_elf_strtab_add. */ tab->array[idx]->refcount = 0; tab->array[idx]->len = 0; }}
开发者ID:ChrisG0x20,项目名称:gdb,代码行数:19,
示例9: mcore_elf_set_private_flagsstatic bfd_booleanmcore_elf_set_private_flags (bfd * abfd, flagword flags){ BFD_ASSERT (! elf_flags_init (abfd) || elf_elfheader (abfd)->e_flags == flags); elf_elfheader (abfd)->e_flags = flags; elf_flags_init (abfd) = TRUE; return TRUE;}
开发者ID:5432935,项目名称:crossbridge,代码行数:10,
示例10: _bfd_elf_strtab_restorevoid_bfd_elf_strtab_restore (struct elf_strtab_hash *tab, void *buf){ size_t idx, curr_size = tab->size; struct strtab_save *save = (struct strtab_save *) buf; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (save->size <= curr_size); tab->size = save->size; for (idx = 1; idx < save->size; ++idx) tab->array[idx]->refcount = save->refcount[idx]; for (; idx < curr_size; ++idx) { /* We don't remove entries from the hash table, just set their REFCOUNT to zero. Setting LEN zero will result in the size growing if the entry is added again. See _bfd_elf_strtab_add. */ tab->array[idx]->refcount = 0; tab->array[idx]->len = 0; }}
开发者ID:T-J-Teru,项目名称:binutils-gdb,代码行数:21,
示例11: i370_elf_howto_initstatic voidi370_elf_howto_init (void){ unsigned int i, type; for (i = 0; i < sizeof (i370_elf_howto_raw) / sizeof (i370_elf_howto_raw[0]); i++) { type = i370_elf_howto_raw[i].type; BFD_ASSERT (type < sizeof (i370_elf_howto_table) / sizeof (i370_elf_howto_table[0])); i370_elf_howto_table[type] = &i370_elf_howto_raw[i]; }}
开发者ID:CromFr,项目名称:gdb,代码行数:12,
示例12: s390_got_pointerstatic inline bfd_vmas390_got_pointer (struct bfd_link_info *info){ struct elf_s390_link_hash_table *htab = elf_s390_hash_table (info); bfd_vma got_pointer; BFD_ASSERT (htab && htab->elf.hgot); got_pointer = (htab->elf.hgot->root.u.def.section->output_section->vma + htab->elf.hgot->root.u.def.section->output_offset); /* Our ABI requires the GOT pointer to point at the very beginning of the global offset table. */ BFD_ASSERT (got_pointer <= (htab->elf.sgot->output_section->vma + htab->elf.sgot->output_offset)); BFD_ASSERT (got_pointer <= (htab->elf.sgotplt->output_section->vma + htab->elf.sgotplt->output_offset)); return got_pointer;}
开发者ID:mattstock,项目名称:binutils-bexkat1,代码行数:21,
示例13: _bfd_elf_strtab_addbfd_size_type_bfd_elf_strtab_add (struct elf_strtab_hash *tab, const char *str, bfd_boolean copy){ register struct elf_strtab_hash_entry *entry; /* We handle this specially, since we don't want to do refcounting on it. */ if (*str == '/0') return 0; BFD_ASSERT (tab->sec_size == 0); entry = (struct elf_strtab_hash_entry *) bfd_hash_lookup (&tab->table, str, TRUE, copy); if (entry == NULL) return (bfd_size_type) -1; entry->refcount++; if (entry->len == 0) { entry->len = strlen (str) + 1; /* 2G strings lose. */ BFD_ASSERT (entry->len > 0); if (tab->size == tab->alloced) { bfd_size_type amt = sizeof (struct elf_strtab_hash_entry *); tab->alloced *= 2; tab->array = (struct elf_strtab_hash_entry **) bfd_realloc_or_free (tab->array, tab->alloced * amt); if (tab->array == NULL) return (bfd_size_type) -1; } entry->u.index = tab->size++; tab->array[entry->u.index] = entry; } return entry->u.index;}
开发者ID:ChrisG0x20,项目名称:gdb,代码行数:40,
示例14: bfd_seekintbfd_seek (bfd *abfd, file_ptr position, int direction){ int result; ufile_ptr offset = 0; while (abfd->my_archive != NULL && !bfd_is_thin_archive (abfd->my_archive)) { offset += abfd->origin; abfd = abfd->my_archive; } if (abfd->iovec == NULL) { bfd_set_error (bfd_error_invalid_operation); return -1; } /* For the time being, a BFD may not seek to it's end. The problem is that we don't easily have a way to recognize the end of an element in an archive. */ BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR); if (direction != SEEK_CUR) position += offset; if ((direction == SEEK_CUR && position == 0) || (direction == SEEK_SET && (ufile_ptr) position == abfd->where)) return 0; result = abfd->iovec->bseek (abfd, position, direction); if (result != 0) { /* An EINVAL error probably means that the file offset was absurd. */ if (errno == EINVAL) bfd_set_error (bfd_error_file_truncated); else bfd_set_error (bfd_error_system_call); } else { /* Adjust `where' field. */ if (direction == SEEK_CUR) abfd->where += position; else abfd->where = position; } return result;}
开发者ID:T-J-Teru,项目名称:binutils-gdb,代码行数:52,
示例15: s390_gotplt_offsetstatic inline bfd_vmas390_gotplt_offset (struct bfd_link_info *info){ struct elf_s390_link_hash_table *htab = elf_s390_hash_table (info); /* The absolute address of the .got.plt in the target image. */ bfd_vma gotplt_address = (htab->elf.sgotplt->output_section->vma + htab->elf.sgotplt->output_offset); /* GOT offset must not be negative. */ BFD_ASSERT (s390_got_pointer (info) <= gotplt_address); return gotplt_address - s390_got_pointer (info);}
开发者ID:mattstock,项目名称:binutils-bexkat1,代码行数:13,
示例16: spu_compatiblestatic const bfd_arch_info_type *spu_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b){ BFD_ASSERT (a->arch == bfd_arch_spu); switch (b->arch) { default: return NULL; case bfd_arch_spu: return bfd_default_compatible (a, b); } /*NOTREACHED*/}
开发者ID:0mp,项目名称:freebsd,代码行数:13,
示例17: bfd_cache_initbfd_booleanbfd_cache_init (bfd *abfd){ BFD_ASSERT (abfd->iostream != NULL); if (open_files >= BFD_CACHE_MAX_OPEN) { if (! close_one ()) return FALSE; } abfd->iovec = &cache_iovec; insert (abfd); ++open_files; return TRUE;}
开发者ID:davearrama,项目名称:gdb,代码行数:14,
示例18: bfd_perform_slipvoidbfd_perform_slip (bfd *abfd, unsigned int slip, asection *input_section, bfd_vma value){ asymbol **s; s = _bfd_generic_link_get_symbols (abfd); BFD_ASSERT (s != (asymbol **) NULL); /* Find all symbols past this point, and make them know what's happened. */ while (*s) { asymbol *p = *s; if (p->section == input_section) { /* This was pointing into this section, so mangle it. */ if (p->value > value) { p->value -= slip; if (p->udata.p != NULL) { struct generic_link_hash_entry *h; h = (struct generic_link_hash_entry *) p->udata.p; BFD_ASSERT (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak); h->root.u.def.value -= slip; BFD_ASSERT (h->root.u.def.value == p->value); } } } s++; }}
开发者ID:ChrisG0x20,项目名称:gdb,代码行数:37,
示例19: bfd_free_windowvoidbfd_free_window(bfd_window *windowp){ bfd_window_internal *i = windowp->i; windowp->i = 0; windowp->data = 0; if (i == 0) return; i->refcount--; if (debug_windows) fprintf(stderr, "freeing window @%p<%p,%lx,%p>/n", (void *)windowp, windowp->data, (unsigned long)windowp->size, (void *)windowp->i); if (i->refcount > 0) return; switch (i->mapped) { case 2: i->data = NULL; break; case 1:#if HAVE_MMAP munmap(i->data, (size_t)i->size); i->data = NULL;#else abort();#endif /* HAVE_MMAP */ case 0:#if defined(HAVE_MPROTECT) && HAVE_MPROTECT mprotect(i->data, i->size, (PROT_READ | PROT_WRITE));#endif /* HAVE_MPROTECT */ free(i->data); i->data = NULL; break; default: BFD_ASSERT((i->mapped == 0) || (i->mapped == 1) || (i->mapped == 2)); } /* There should be no more references to i at this point: */ free(i);}
开发者ID:dougmencken,项目名称:apple-gdb-1824,代码行数:48,
示例20: mcore_elf_howto_init/* Initialize the mcore_elf_howto_table, so that linear accesses can be done. */static voidmcore_elf_howto_init (){ unsigned int i; for (i = NUM_ELEM (mcore_elf_howto_raw); i--;) { unsigned int type; type = mcore_elf_howto_raw[i].type; BFD_ASSERT (type < NUM_ELEM (mcore_elf_howto_table)); mcore_elf_howto_table [type] = & mcore_elf_howto_raw [i]; }}
开发者ID:Rukanth,项目名称:dd-wrt,代码行数:17,
示例21: rs6000_compatiblestatic const bfd_arch_info_type *rs6000_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b){ BFD_ASSERT (a->arch == bfd_arch_rs6000); switch (b->arch) { default: return NULL; case bfd_arch_rs6000: return bfd_default_compatible (a, b); case bfd_arch_powerpc: if (a->mach == bfd_mach_rs6k) return b; return NULL; } /*NOTREACHED*/}
开发者ID:T-J-Teru,项目名称:binutils-gdb,代码行数:18,
示例22: real_fopenFILE *real_fopen (const char *filename, const char *modes){#ifdef VMS char vms_modes[4]; char *vms_attr; /* On VMS, fopen allows file attributes as optionnal arguments. We need to use them but we'd better to use the common prototype. In fopen-vms.h, they are separated from the mode with a comma. Split here. */ vms_attr = strchr (modes, ','); if (vms_attr == NULL) { /* No attributes. */ return close_on_exec (fopen (filename, modes)); } else { /* Attributes found. Split. */ size_t modes_len = strlen (modes) + 1; char attrs[modes_len + 1]; char *at[3]; int i; memcpy (attrs, modes, modes_len); at[0] = attrs; for (i = 0; i < 2; i++) { at[i + 1] = strchr (at[i], ','); BFD_ASSERT (at[i + 1] != NULL); *(at[i + 1]++) = 0; /* Replace ',' with a nul, and skip it. */ } return close_on_exec (fopen (filename, at[0], at[1], at[2])); }#else /* !VMS */#if defined (HAVE_FOPEN64) return close_on_exec (fopen64 (filename, modes));#else return close_on_exec (fopen (filename, modes));#endif#endif /* !VMS */}
开发者ID:davearrama,项目名称:gdb,代码行数:43,
示例23: lookup_howtostatic reloc_howto_type *lookup_howto (unsigned int rtype){ static int initialized = 0; int i; int howto_tbl_size = (int) (sizeof (elf32_i860_howto_table) / sizeof (elf32_i860_howto_table[0])); if (! initialized) { initialized = 1; memset (elf_code_to_howto_index, 0xff, sizeof (elf_code_to_howto_index)); for (i = 0; i < howto_tbl_size; i++) elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i; } BFD_ASSERT (rtype <= R_860_max); i = elf_code_to_howto_index[rtype]; if (i >= howto_tbl_size) return 0; return elf32_i860_howto_table + i;}
开发者ID:janfj,项目名称:dd-wrt,代码行数:23,
示例24: decompress_contentsstatic bfd_booleandecompress_contents (bfd_byte *compressed_buffer, bfd_size_type compressed_size, bfd_byte *uncompressed_buffer, bfd_size_type uncompressed_size){ z_stream strm; int rc; /* It is possible the section consists of several compressed buffers concatenated together, so we uncompress in a loop. */ /* PR 18313: The state field in the z_stream structure is supposed to be invisible to the user (ie us), but some compilers will still complain about it being used without initialisation. So we first zero the entire z_stream structure and then set the fields that we need. */ memset (& strm, 0, sizeof strm); strm.avail_in = compressed_size - 12; strm.next_in = (Bytef*) compressed_buffer + 12; strm.avail_out = uncompressed_size; BFD_ASSERT (Z_OK == 0); rc = inflateInit (&strm); while (strm.avail_in > 0 && strm.avail_out > 0) { if (rc != Z_OK) break; strm.next_out = ((Bytef*) uncompressed_buffer + (uncompressed_size - strm.avail_out)); rc = inflate (&strm, Z_FINISH); if (rc != Z_STREAM_END) break; rc = inflateReset (&strm); } rc |= inflateEnd (&strm); return rc == Z_OK && strm.avail_out == 0;}
开发者ID:randomstuff,项目名称:binutils-gdb,代码行数:37,
示例25: _bfd_elf_link_setup_gnu_propertiesbfd *_bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info){ bfd *abfd, *first_pbfd = NULL; elf_property_list *list; asection *sec; bfd_boolean has_properties = FALSE; const struct elf_backend_data *bed = get_elf_backend_data (info->output_bfd); unsigned int elfclass = bed->s->elfclass; int elf_machine_code = bed->elf_machine_code; /* Find the first relocatable ELF input with GNU properties. */ for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) if (bfd_get_flavour (abfd) == bfd_target_elf_flavour && (abfd->flags & DYNAMIC) == 0 && elf_properties (abfd) != NULL) { has_properties = TRUE; /* Ignore GNU properties from ELF objects with different machine code or class. Also skip objects without a GNU_PROPERTY note section. */ if ((elf_machine_code == get_elf_backend_data (abfd)->elf_machine_code) && (elfclass == get_elf_backend_data (abfd)->s->elfclass) && bfd_get_section_by_name (abfd, NOTE_GNU_PROPERTY_SECTION_NAME) != NULL ) { /* Keep .note.gnu.property section in FIRST_PBFD. */ first_pbfd = abfd; break; } } /* Do nothing if there is no .note.gnu.property section. */ if (!has_properties) return NULL; /* Merge .note.gnu.property sections. */ for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) if (abfd != first_pbfd && (abfd->flags & DYNAMIC) == 0) { elf_property_list *null_ptr = NULL; elf_property_list **listp = &null_ptr; /* Merge .note.gnu.property section in relocatable ELF input. */ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) { list = elf_properties (abfd); /* Ignore GNU properties from ELF objects with different machine code. */ if (list != NULL && (elf_machine_code == get_elf_backend_data (abfd)->elf_machine_code)) listp = &elf_properties (abfd); } else list = NULL; /* Merge properties with FIRST_PBFD. FIRST_PBFD can be NULL when all properties are from ELF objects with different machine code or class. */ if (first_pbfd != NULL) elf_merge_gnu_property_list (info, first_pbfd, listp); if (list != NULL) { /* Discard the .note.gnu.property section in this bfd. */ sec = bfd_get_section_by_name (abfd, NOTE_GNU_PROPERTY_SECTION_NAME); if (sec != NULL) sec->output_section = bfd_abs_section_ptr; } } /* Rewrite .note.gnu.property section so that GNU properties are always sorted by type even if input GNU properties aren't sorted. */ if (first_pbfd != NULL) { bfd_size_type size; bfd_byte *contents; unsigned int align_size = elfclass == ELFCLASS64 ? 8 : 4; sec = bfd_get_section_by_name (first_pbfd, NOTE_GNU_PROPERTY_SECTION_NAME); BFD_ASSERT (sec != NULL); /* Update stack size in .note.gnu.property with -z stack-size=N if N > 0. */ if (info->stacksize > 0) { elf_property *p; bfd_vma stacksize = info->stacksize; p = _bfd_elf_get_property (first_pbfd, GNU_PROPERTY_STACK_SIZE, align_size);//.........这里部分代码省略.........
开发者ID:mattstock,项目名称:binutils-bexkat1,代码行数:101,
示例26: nacl_modify_segment_map/* We permute the segment_map to get BFD to do the file layout we want: The first non-executable PT_LOAD segment appears first in the file and contains the ELF file header and phdrs. */bfd_booleannacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info){ const struct elf_backend_data *const bed = get_elf_backend_data (abfd); 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; int sizeof_headers; if (info != NULL && info->user_phdrs) /* The linker script used PHDRS explicitly, so don't change what the user asked for. */ return TRUE; if (info != NULL) /* We're doing linking, so evalute SIZEOF_HEADERS as in a linker script. */ sizeof_headers = bfd_sizeof_headers (abfd, info); else { /* We're not doing linking, so this is objcopy or suchlike. We just need to collect the size of the existing headers. */ struct elf_segment_map *seg; sizeof_headers = bed->s->sizeof_ehdr; for (seg = *m; seg != NULL; seg = seg->next) sizeof_headers += bed->s->sizeof_phdr; } while (*m != NULL) { struct elf_segment_map *seg = *m; if (seg->p_type == PT_LOAD) { bfd_boolean executable = segment_executable (seg); if (executable && seg->count > 0 && seg->sections[0]->vma % bed->minpagesize == 0) { asection *lastsec = seg->sections[seg->count - 1]; bfd_vma end = lastsec->vma + lastsec->size; if (end % bed->minpagesize != 0) { /* This is an executable segment that starts on a page boundary but does not end on a page boundary. Fill it out to a whole page with code fill (the tail of the segment will not be within any section). Thus the entire code segment can be mapped from the file as whole pages and that mapping will contain only valid instructions. To accomplish this, we must fake out the code in assign_file_positions_for_load_sections (elf.c) so that it advances past the rest of the final page, rather than trying to put the next (unaligned, or unallocated) section. We do this by appending a dummy section record to this element in the segment map. No such output section ever actually exists, but this gets the layout logic to advance the file positions past this partial page. Since we are lying to BFD like this, nothing will ever know to write the section contents. So we do that by hand after the fact, in nacl_final_write_processing, below. */ struct elf_segment_map *newseg; asection *sec; struct bfd_elf_section_data *secdata; BFD_ASSERT (!seg->p_size_valid); secdata = bfd_zalloc (abfd, sizeof *secdata); if (secdata == NULL) return FALSE; sec = bfd_zalloc (abfd, sizeof *sec); if (sec == NULL) return FALSE; /* Fill in only the fields that actually affect the logic in assign_file_positions_for_load_sections. */ sec->vma = end; sec->lma = lastsec->lma + lastsec->size; sec->size = bed->minpagesize - (end % bed->minpagesize); sec->flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_LINKER_CREATED); sec->used_by_bfd = secdata; secdata->this_hdr.sh_type = SHT_PROGBITS; secdata->this_hdr.sh_flags = SHF_ALLOC | SHF_EXECINSTR; secdata->this_hdr.sh_addr = sec->vma; secdata->this_hdr.sh_size = sec->size; newseg = bfd_alloc (abfd, sizeof *newseg + ((seg->count + 1) * sizeof (asection *))); if (newseg == NULL)//.........这里部分代码省略.........
开发者ID:fengyanzhao,项目名称:binutils-2.25,代码行数:101,
示例27: _bfd_link_section_stabs//.........这里部分代码省略......... ++nest; else if (nest == 0) { const char *str; str = ((char *) stabstrbuf + stroff + bfd_get_32 (abfd, incl_sym + STRDXOFF)); for (; *str != '/0'; str++) { if (num_chars >= buf_len) { buf_len += 32 * 1024; symb = (char *) bfd_realloc_or_free (symb, buf_len); if (symb == NULL) goto error_return; symb_rover = symb + num_chars; } * symb_rover ++ = * str; sum_chars += *str; num_chars ++; if (*str == '(') { /* Skip the file number. */ ++str; while (ISDIGIT (*str)) ++str; --str; } } } } BFD_ASSERT (num_chars == (bfd_vma) (symb_rover - symb)); /* If we have already included a header file with the same value, then replaced this one with an N_EXCL symbol. */ incl_entry = (struct stab_link_includes_entry * ) bfd_hash_lookup (&sinfo->includes, string, TRUE, TRUE); if (incl_entry == NULL) goto error_return; for (t = incl_entry->totals; t != NULL; t = t->next) if (t->sum_chars == sum_chars && t->num_chars == num_chars && memcmp (t->symb, symb, num_chars) == 0) break; /* Record this symbol, so that we can set the value correctly. */ amt = sizeof *ne; ne = (struct stab_excl_list *) bfd_alloc (abfd, amt); if (ne == NULL) goto error_return; ne->offset = sym - stabbuf; ne->val = sum_chars; ne->type = (int) N_BINCL; ne->next = secinfo->excls; secinfo->excls = ne; if (t == NULL) { /* This is the first time we have seen this header file with this set of stabs strings. */ t = (struct stab_link_includes_totals *) bfd_hash_allocate (&sinfo->includes, sizeof *t);
开发者ID:freebsd-riscv,项目名称:riscv-binutils-gdb,代码行数:67,
示例28: _bfd_discard_section_stabs//.........这里部分代码省略......... skip = 0; deleting = -1; symend = stabbuf + stabsec->rawsize; for (sym = stabbuf, pstridx = secinfo->stridxs; sym < symend; sym += STABSIZE, ++pstridx) { int type; if (*pstridx == (bfd_size_type) -1) /* This stab was deleted in a previous pass. */ continue; type = sym[TYPEOFF]; if (type == (int) N_FUN) { int strx = bfd_get_32 (abfd, sym + STRDXOFF); if (strx == 0) { if (deleting) { skip++; *pstridx = -1; } deleting = -1; continue; } deleting = 0; if ((*reloc_symbol_deleted_p) (sym + VALOFF - stabbuf, cookie)) deleting = 1; } if (deleting == 1) { *pstridx = -1; skip++; } else if (deleting == -1) { /* Outside of a function. Check for deleted variables. */ if (type == (int) N_STSYM || type == (int) N_LCSYM) if ((*reloc_symbol_deleted_p) (sym + VALOFF - stabbuf, cookie)) { *pstridx = -1; skip ++; } /* We should also check for N_GSYM entries which reference a deleted global, but those are less harmful to debuggers and would require parsing the stab strings. */ } } free (stabbuf); stabbuf = NULL; /* Shrink the stabsec as needed. */ stabsec->size -= skip * STABSIZE; if (stabsec->size == 0) stabsec->flags |= SEC_EXCLUDE | SEC_KEEP; /* Recalculate the `cumulative_skips' array now that stabs have been deleted for this section. */ if (skip != 0) { bfd_size_type i, offset; bfd_size_type *pskips; if (secinfo->cumulative_skips == NULL) { amt = count * sizeof (bfd_size_type); secinfo->cumulative_skips = (bfd_size_type *) bfd_alloc (abfd, amt); if (secinfo->cumulative_skips == NULL) goto error_return; } pskips = secinfo->cumulative_skips; pstridx = secinfo->stridxs; offset = 0; for (i = 0; i < count; i++, pskips++, pstridx++) { *pskips = offset; if (*pstridx == (bfd_size_type) -1) offset += STABSIZE; } BFD_ASSERT (offset != 0); } return skip > 0; error_return: if (stabbuf != NULL) free (stabbuf); return FALSE;}
开发者ID:freebsd-riscv,项目名称:riscv-binutils-gdb,代码行数:101,
示例29: _bfd_write_section_stabsbfd_boolean_bfd_write_section_stabs (bfd *output_bfd, struct stab_info *sinfo, asection *stabsec, void * *psecinfo, bfd_byte *contents){ struct stab_section_info *secinfo; struct stab_excl_list *e; bfd_byte *sym, *tosym, *symend; bfd_size_type *pstridx; secinfo = (struct stab_section_info *) *psecinfo; if (secinfo == NULL) return bfd_set_section_contents (output_bfd, stabsec->output_section, contents, stabsec->output_offset, stabsec->size); /* Handle each N_BINCL entry. */ for (e = secinfo->excls; e != NULL; e = e->next) { bfd_byte *excl_sym; BFD_ASSERT (e->offset < stabsec->rawsize); excl_sym = contents + e->offset; bfd_put_32 (output_bfd, e->val, excl_sym + VALOFF); excl_sym[TYPEOFF] = e->type; } /* Copy over all the stabs symbols, omitting the ones we don't want, and correcting the string indices for those we do want. */ tosym = contents; symend = contents + stabsec->rawsize; for (sym = contents, pstridx = secinfo->stridxs; sym < symend; sym += STABSIZE, ++pstridx) { if (*pstridx != (bfd_size_type) -1) { if (tosym != sym) memcpy (tosym, sym, STABSIZE); bfd_put_32 (output_bfd, *pstridx, tosym + STRDXOFF); if (sym[TYPEOFF] == 0) { /* This is the header symbol for the stabs section. We don't really need one, since we have merged all the input stabs sections into one, but we generate one for the benefit of readers which expect to see one. */ BFD_ASSERT (sym == contents); bfd_put_32 (output_bfd, _bfd_stringtab_size (sinfo->strings), tosym + VALOFF); bfd_put_16 (output_bfd, stabsec->output_section->size / STABSIZE - 1, tosym + DESCOFF); } tosym += STABSIZE; } } BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->size); return bfd_set_section_contents (output_bfd, stabsec->output_section, contents, (file_ptr) stabsec->output_offset, stabsec->size);}
开发者ID:freebsd-riscv,项目名称:riscv-binutils-gdb,代码行数:68,
示例30: bfd_seekintbfd_seek (bfd *abfd, file_ptr position, int direction){ int result; file_ptr file_position; /* For the time being, a BFD may not seek to it's end. The problem is that we don't easily have a way to recognize the end of an element in an archive. */ BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR); if (direction == SEEK_CUR && position == 0) return 0; if ((abfd->flags & BFD_IN_MEMORY) != 0) { struct bfd_in_memory *bim; bim = abfd->iostream; if (direction == SEEK_SET) abfd->where = position; else abfd->where += position; if (abfd->where > bim->size) { if ((abfd->direction == write_direction) || (abfd->direction == both_direction)) { bfd_size_type newsize, oldsize; oldsize = (bim->size + 127) & ~(bfd_size_type) 127; bim->size = abfd->where; /* Round up to cut down on memory fragmentation */ newsize = (bim->size + 127) & ~(bfd_size_type) 127; if (newsize > oldsize) { bim->buffer = bfd_realloc_or_free (bim->buffer, newsize); if (bim->buffer == NULL) { bim->size = 0; return -1; } } } else { abfd->where = bim->size; bfd_set_error (bfd_error_file_truncated); return -1; } } return 0; } if (abfd->format != bfd_archive && abfd->my_archive == 0) { if (direction == SEEK_SET && (bfd_vma) position == abfd->where) return 0; } else { /* We need something smarter to optimize access to archives. Currently, anything inside an archive is read via the file handle for the archive. Which means that a bfd_seek on one component affects the `current position' in the archive, as well as in any other component. It might be sufficient to put a spike through the cache abstraction, and look to the archive for the file position, but I think we should try for something cleaner. In the meantime, no optimization for archives. */ } file_position = position; if (direction == SEEK_SET && abfd->my_archive != NULL) file_position += abfd->origin; if (abfd->iovec) result = abfd->iovec->bseek (abfd, file_position, direction); else result = -1; if (result != 0) { int hold_errno = errno; /* Force redetermination of `where' field. */ bfd_tell (abfd); /* An EINVAL error probably means that the file offset was absurd. */ if (hold_errno == EINVAL) bfd_set_error (bfd_error_file_truncated); else { bfd_set_error (bfd_error_system_call); errno = hold_errno;//.........这里部分代码省略.........
开发者ID:BGmot,项目名称:playbook-dev-tools,代码行数:101,
注:本文中的BFD_ASSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BFS函数代码示例 C++ BF函数代码示例 |