static void bfdsec_to_vmap (struct bfd *abfd, struct bfd_section *sect, void *arg3) { struct vmap_and_bfd *vmap_bfd = (struct vmap_and_bfd *) arg3; struct vmap *vp; vp = vmap_bfd->pvmap; if ((bfd_get_section_flags (abfd, sect) & SEC_LOAD) == 0) return; if (strcmp (bfd_section_name (abfd, sect), ".text") == 0) { vp->tstart = bfd_section_vma (abfd, sect); vp->tend = vp->tstart + bfd_section_size (abfd, sect); vp->tvma = bfd_section_vma (abfd, sect); vp->toffs = sect->filepos; } else if (strcmp (bfd_section_name (abfd, sect), ".data") == 0) { vp->dstart = bfd_section_vma (abfd, sect); vp->dend = vp->dstart + bfd_section_size (abfd, sect); vp->dvma = bfd_section_vma (abfd, sect); } /* Silently ignore other types of sections. (FIXME?) */ }
uint64_t i386_linux_core_read_xcr0 (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate"); uint64_t xcr0; if (xstate) { size_t size = bfd_section_size (abfd, xstate); /* Check extended state size. */ if (size < I386_XSTATE_AVX_SIZE) xcr0 = I386_XSTATE_SSE_MASK; else { char contents[8]; if (! bfd_get_section_contents (abfd, xstate, contents, I386_LINUX_XSAVE_XCR0_OFFSET, 8)) { warning (_("Couldn't read `xcr0' bytes from " "`.reg-xstate' section in core file.")); return 0; } xcr0 = bfd_get_64 (abfd, contents); } } else xcr0 = 0; return xcr0; }
uv_err_t UVDBFDPatSection::setFunctionSizes() { //Functions were sorted into modules, but we need a contiguous list to determine sizes std::vector<UVDBFDPatFunction *> allSectionFunctions; int sectionSize = 0; for( std::vector<UVDBFDPatModule *>::iterator iter = m_modules.begin(); iter != m_modules.end(); ++iter ) { UVDBFDPatModule *module = *iter; uv_assert_ret(module); //std::vector<UVDBFDPatFunction *> m_functions allSectionFunctions.insert(allSectionFunctions.end(), module->m_functions.begin(), module->m_functions.end()); } sectionSize = bfd_section_size(m_core->m_bfd, m_section); //Iterate over all functions within that section for( std::vector<UVDBFDPatFunction *>::iterator iter = allSectionFunctions.begin(); iter != allSectionFunctions.end(); ) { UVDBFDPatFunction *function = NULL; std::vector<UVDBFDPatFunction *>::iterator iterStart = iter; /* What if we have a 0 sized symbol in the section? Special case: symbol is at the end of the section */ do { function = *iter; ++iter; //Get the next size //Did we reach the section end? if( iter == allSectionFunctions.end() ) { function->m_size = sectionSize - function->m_offset; //Even if we still have 0 size, we need to break break; } else { UVDBFDPatFunction *functionNext = NULL; functionNext = *iter; function->m_size = functionNext->m_offset - function->m_offset; } } while( function->m_size == 0 ); //And set any previously skipped elements from same symbol position while( iterStart != iter ) { (*iterStart)->m_size = function->m_size; ++iterStart; } printf_flirt_debug("early func size %s is 0x%04X\n", bfd_asymbol_name(function->m_bfdAsymbol), function->m_size); } return UV_ERR_OK; }
uint64_t i386fbsd_core_read_xcr0 (bfd *abfd) { asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate"); uint64_t xcr0; if (xstate) { size_t size = bfd_section_size (abfd, xstate); /* Check extended state size. */ if (size < X86_XSTATE_AVX_SIZE) xcr0 = X86_XSTATE_SSE_MASK; else { char contents[8]; if (! bfd_get_section_contents (abfd, xstate, contents, I386_FBSD_XSAVE_XCR0_OFFSET, 8)) { warning (_("Couldn't read `xcr0' bytes from " "`.reg-xstate' section in core file.")); return X86_XSTATE_SSE_MASK; } xcr0 = bfd_get_64 (abfd, contents); } } else xcr0 = X86_XSTATE_SSE_MASK; return xcr0; }
/* Look for an address in a section. * This is called via bfd_map_over_sections. */ static void find_address_in_section (bfd *abfd, asection *section, void *data) { bfd_vma vma; bfd_size_type size; struct symbol *symbol = data; struct symtab *symtab = symbol->symtab; if (symbol->found) return; if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0) return; vma = bfd_get_section_vma (symtab->bfd, section); if (symbol->pc < vma) return; size = bfd_section_size (symtab->bfd, section); if (symbol->pc >= vma + size) return; symbol->found = bfd_find_nearest_line (symtab->bfd, section, symtab->syms, symbol->pc - vma, &symbol->filename, &symbol->functionname, &symbol->line); }
static int check_note (bfd *abfd, asection *sect, const char *note, const char *name, unsigned long descsz, unsigned long type) { unsigned long notesz; /* Calculate the size of this note. */ notesz = strlen (name) + 1; notesz = ((notesz + 3) & ~3); notesz += descsz; notesz = ((notesz + 3) & ~3); /* If this assertion triggers, increase MAX_NOTESZ. */ gdb_assert (notesz <= MAX_NOTESZ); /* Check whether SECT is big enough to comtain the complete note. */ if (notesz > bfd_section_size (abfd, sect)) return 0; /* Check the note name. */ if (bfd_h_get_32 (abfd, note) != (strlen (name) + 1) || strcmp (note + 12, name) != 0) return 0; /* Check the descriptor size. */ if (bfd_h_get_32 (abfd, note + 4) != descsz) return 0; /* Check the note type. */ if (bfd_h_get_32 (abfd, note + 8) != type) return 0; return 1; }
static bfd_boolean read_ieee_debugging_info (bfd *abfd, void *dhandle, bfd_boolean *pfound) { asection *dsec; bfd_size_type size; bfd_byte *contents; /* The BFD backend puts the debugging information into a section named .debug. */ dsec = bfd_get_section_by_name (abfd, ".debug"); if (dsec == NULL) return TRUE; size = bfd_section_size (abfd, dsec); contents = (bfd_byte *) xmalloc (size); if (! bfd_get_section_contents (abfd, dsec, contents, 0, size)) return FALSE; if (! parse_ieee (dhandle, abfd, contents, size)) return FALSE; free (contents); *pfound = TRUE; return TRUE; }
void stacktrace::find_address_in_section (bfd* abfd, asection* section, void* data) { stacktrace* self = static_cast<stacktrace*> (data); bfd_vma vma; bfd_size_type size; if (self->found) return; if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0) return; vma = bfd_get_section_vma (abfd, section); if (self->pc < vma) return; size = bfd_section_size (abfd, section); if (self->pc >= vma + size) return; self->found = bfd_find_nearest_line (abfd, section, self->syms, self->pc - vma, &self->filename, &self->funcname, &self->line); }
static void flash_section(bfd * ibfd, sec_ptr isection, void *arg) { bfd_size_type size = bfd_section_size(ibfd, isection); /* bfd_vma vma = bfd_section_vma(ibfd, isection); */ bfd_vma lma = bfd_section_lma(ibfd, isection); const char *section_name = bfd_section_name(ibfd, isection); bfd_byte *data = 0; struct flash_section_data *fsdata = arg; struct c2tool_state *state = fsdata->state; unsigned int offset = fsdata->offset; unsigned int flash_addr = lma + offset; printf("section %s: lma %016" BFD_VMA_FMT "x, size %d -> flash %08x\n", section_name, lma, (int)size, flash_addr); if (!bfd_get_full_section_contents (ibfd,isection, &data)) { fprintf(stderr, "Reading section failed\n"); return; } while (size) { int res; res = flash_chunk(state, flash_addr, size, data); if (res < 0) { fprintf(stderr, "flash chunk at %08x failed.\n", flash_addr); break; } flash_addr += res; size -= res; data += res; } }
void core_target::get_core_register_section (struct regcache *regcache, const struct regset *regset, const char *name, int section_min_size, int which, const char *human_name, bool required) { struct bfd_section *section; bfd_size_type size; char *contents; bool variable_size_section = (regset != NULL && regset->flags & REGSET_VARIABLE_SIZE); thread_section_name section_name (name, regcache->ptid ()); section = bfd_get_section_by_name (core_bfd, section_name.c_str ()); if (! section) { if (required) warning (_("Couldn't find %s registers in core file."), human_name); return; } size = bfd_section_size (core_bfd, section); if (size < section_min_size) { warning (_("Section `%s' in core file too small."), section_name.c_str ()); return; } if (size != section_min_size && !variable_size_section) { warning (_("Unexpected size of section `%s' in core file."), section_name.c_str ()); } contents = (char *) alloca (size); if (! bfd_get_section_contents (core_bfd, section, contents, (file_ptr) 0, size)) { warning (_("Couldn't read %s registers from `%s' section in core file."), human_name, section_name.c_str ()); return; } if (regset != NULL) { regset->supply_regset (regset, regcache, -1, contents, size); return; } gdb_assert (m_core_vec != nullptr); m_core_vec->core_read_registers (regcache, contents, size, which, ((CORE_ADDR) bfd_section_vma (core_bfd, section))); }
uv_err_t UVDBFDPatSection::size(uint32_t *out) { uv_assert_ret(m_core); uv_assert_ret(m_section); *out = bfd_section_size(m_core->m_bfd, m_section); return UV_ERR_OK; }
void coff_solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms) { asection *libsect; if (!readsyms) return; libsect = bfd_get_section_by_name (exec_bfd, ".lib"); if (libsect) { int libsize; unsigned char *lib; struct libent { bfd_byte len[4]; bfd_byte nameoffset[4]; }; libsize = bfd_section_size (exec_bfd, libsect); lib = (unsigned char *) alloca (libsize); bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize); while (libsize > 0) { struct libent *ent; struct objfile *objfile; int len, nameoffset; char *filename; ent = (struct libent *) lib; len = bfd_get_32 (exec_bfd, ent->len); nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset); if (len <= 0) break; filename = (char *) ent + nameoffset * 4; objfile = symbol_file_add (filename, from_tty, NULL, /* no offsets */ 0, /* not mainline */ OBJF_SHARED); /* flags */ libsize -= len * 4; lib += len * 4; } /* Getting new symbols may change our opinion about what is frameless. */ reinit_frame_cache (); } }
static void add_to_section_table (bfd *abfd, struct bfd_section *asect, void *table_pp_char) { struct section_table **table_pp = (struct section_table **) table_pp_char; flagword aflag; aflag = bfd_get_section_flags (abfd, asect); if (!(aflag & SEC_ALLOC)) return; if (0 == bfd_section_size (abfd, asect)) return; (*table_pp)->bfd = abfd; (*table_pp)->the_bfd_section = asect; (*table_pp)->addr = bfd_section_vma (abfd, asect); (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect); (*table_pp)++; }
static void add_to_section_table (struct bfd *abfd, struct bfd_section *asect, void *closure) { struct section_closure *pp = closure; flagword aflag; /* NOTE: cagney/2003-10-22: Is this pruning useful? */ aflag = bfd_get_section_flags (abfd, asect); if (!(aflag & SEC_ALLOC)) return; if (bfd_section_size (abfd, asect) == 0) return; pp->end->bfd = abfd; pp->end->the_bfd_section = asect; pp->end->addr = bfd_section_vma (abfd, asect); pp->end->endaddr = pp->end->addr + bfd_section_size (abfd, asect); pp->end++; }
static void secscan (bfd *file, sec_ptr sec, void *userParam) { SecScanParam *param = (SecScanParam *) userParam; if (strcmp(param->sectionName, bfd_section_name (file, sec))==0) { bfd_size_type size = bfd_section_size (file, sec); void *data = (void *) param->result.reserve(size); bfd_get_section_contents(file, sec, data, 0, size); } }
static void som_solib_create_inferior_hook (int from_tty) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); struct minimal_symbol *msymbol; unsigned int dld_flags, status, have_endo; asection *shlib_info; char buf[4]; CORE_ADDR anaddr; /* First, remove all the solib event breakpoints. Their addresses may have changed since the last time we ran the program. */ remove_solib_event_breakpoints (); if (symfile_objfile == NULL) return; /* First see if the objfile was dynamically linked. */ shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$"); if (!shlib_info) return; /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */ if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0) return; /* Read the DL header. */ bfd_get_section_contents (symfile_objfile->obfd, shlib_info, (char *) &dl_header, 0, sizeof (dl_header)); have_endo = 0; /* Slam the pid of the process into __d_pid. We used to warn when this failed, but that warning is only useful on very old HP systems (hpux9 and older). The warnings are an annoyance to users of modern systems and foul up the testsuite as well. As a result, the warnings have been disabled. */ msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile); if (msymbol == NULL) goto keep_going; anaddr = SYMBOL_VALUE_ADDRESS (msymbol); store_unsigned_integer (buf, 4, byte_order, PIDGET (inferior_ptid)); status = target_write_memory (anaddr, buf, 4); if (status != 0) { warning (_("\ Unable to write __d_pid.\n\ Suggest linking with /opt/langtools/lib/end.o.\n\ GDB will be unable to track shl_load/shl_unload calls")); goto keep_going; }
static bfd *find_debug_file(bfd *lib, const char *aFileName) { // check for a separate debug file with symbols asection *sect = bfd_get_section_by_name(lib, ".gnu_debuglink"); if (!sect) return nullptr; bfd_size_type debuglinkSize = bfd_section_size (objfile->obfd, sect); char *debuglink = new char[debuglinkSize]; bfd_get_section_contents(lib, sect, debuglink, 0, debuglinkSize); // crc checksum is aligned to 4 bytes, and after the NUL. int crc_offset = (int(strlen(debuglink)) & ~3) + 4; unsigned long crc32 = bfd_get_32(lib, debuglink + crc_offset); // directory component char *dirbuf = strdup(aFileName); const char *dir = dirname(dirbuf); static const char debug_subdir[] = ".debug"; // This is gdb's default global debugging info directory, but gdb can // be instructed to use a different directory. static const char global_debug_dir[] = "/usr/lib/debug"; char *filename = new char[strlen(global_debug_dir) + strlen(dir) + crc_offset + 3]; // /path/debuglink sprintf(filename, "%s/%s", dir, debuglink); bfd *debugFile = try_debug_file(filename, crc32); if (!debugFile) { // /path/.debug/debuglink sprintf(filename, "%s/%s/%s", dir, debug_subdir, debuglink); debugFile = try_debug_file(filename, crc32); if (!debugFile) { // /usr/lib/debug/path/debuglink sprintf(filename, "%s/%s/%s", global_debug_dir, dir, debuglink); debugFile = try_debug_file(filename, crc32); } } delete[] filename; free(dirbuf); delete[] debuglink; return debugFile; }
enum sh64_elf_cr_type sh64_get_contents_type (asection *sec, bfd_vma addr, sh64_elf_crange *rangep) { asection *cranges; /* Fill in the range with the boundaries of the section as a default. */ if (bfd_get_flavour (sec->owner) == bfd_target_elf_flavour && elf_elfheader (sec->owner)->e_type == ET_EXEC) { rangep->cr_addr = bfd_get_section_vma (sec->owner, sec); rangep->cr_size = bfd_section_size (sec->owner, sec); rangep->cr_type = CRT_NONE; } else return FALSE; /* If none of the pertinent bits are set, then it's a SHcompact (or at least not SHmedia). */ if ((elf_section_data (sec)->this_hdr.sh_flags & (SHF_SH5_ISA32 | SHF_SH5_ISA32_MIXED)) == 0) { enum sh64_elf_cr_type cr_type = ((bfd_get_section_flags (sec->owner, sec) & SEC_CODE) != 0 ? CRT_SH5_ISA16 : CRT_DATA); rangep->cr_type = cr_type; return cr_type; } /* If only the SHF_SH5_ISA32 bit is set, then we have SHmedia. */ if ((elf_section_data (sec)->this_hdr.sh_flags & (SHF_SH5_ISA32 | SHF_SH5_ISA32_MIXED)) == SHF_SH5_ISA32) { rangep->cr_type = CRT_SH5_ISA32; return CRT_SH5_ISA32; } /* Otherwise, we have to look up the .cranges section. */ cranges = bfd_get_section_by_name (sec->owner, SH64_CRANGES_SECTION_NAME); if (cranges == NULL) /* A mixed section but there's no .cranges section. This is probably bad input; it does not comply to specs. */ return CRT_NONE; /* If this call fails, we will still have CRT_NONE in rangep->cr_type and that will be suitable to return. */ sh64_address_in_cranges (cranges, addr, rangep); return rangep->cr_type; }
static void add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect, void *objfile_p_char) { struct objfile *objfile = (struct objfile *) objfile_p_char; struct obj_section section; flagword aflag; aflag = bfd_get_section_flags (abfd, asect); if (!(aflag & SEC_ALLOC) && !(TARGET_KEEP_SECTION (asect))) return; if (0 == bfd_section_size (abfd, asect)) return; section.offset = 0; section.objfile = objfile; section.the_bfd_section = asect; section.ovly_mapped = 0; section.addr = bfd_section_vma (abfd, asect); section.endaddr = section.addr + bfd_section_size (abfd, asect); obstack_grow (&objfile->objfile_obstack, (char *) §ion, sizeof (section)); objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1); }
/* Open shared library BFD. */ static bfd * spu_bfd_open (char *pathname) { char *original_name = strrchr (pathname, '@'); bfd *abfd; asection *spu_name; unsigned long long addr; int fd; /* Handle regular SVR4 libraries. */ if (!original_name) return svr4_so_ops.bfd_open (pathname); /* Decode object ID. */ if (sscanf (original_name, "@0x%llx <%d>", &addr, &fd) != 2) internal_error (__FILE__, __LINE__, "bad object ID"); /* Open BFD representing SPE executable. */ abfd = spu_bfd_fopen (original_name, (CORE_ADDR) addr); if (!abfd) error (_("Cannot read SPE executable at %s"), original_name); /* Retrieve SPU name note. */ spu_name = bfd_get_section_by_name (abfd, ".note.spu_name"); if (spu_name) { int sect_size = bfd_section_size (abfd, spu_name); if (sect_size > 20) { char *buf = (char *) alloca (sect_size - 20 + strlen (original_name) + 1); bfd_get_section_contents (abfd, spu_name, buf, 20, sect_size - 20); buf[sect_size - 20] = '\0'; strcat (buf, original_name); xfree ((char *)abfd->filename); abfd->filename = xstrdup (buf); } } return abfd; }
static void mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, void *obj) { enum gdb_osabi *os_ident_ptr = obj; const char *name; unsigned int sectsize; name = bfd_get_section_name (abfd, sect); sectsize = bfd_section_size (abfd, sect); if (strncmp (name, ".MIPS.", 6) == 0 && sectsize > 0) { /* The presence of a section named with a ".MIPS." prefix is indicative of an IRIX binary. */ *os_ident_ptr = GDB_OSABI_IRIX; } }
static void print_bfd_section_info(bfd *abfd, asection *asect, void *arg) { flagword flags = bfd_get_section_flags(abfd, asect); const char *name = bfd_section_name(abfd, asect); if ((arg == NULL) || (*((char *)arg) == '\0') || match_substring((char *)arg, name) || match_bfd_flags((char *)arg, flags)) { CORE_ADDR addr, endaddr; addr = bfd_section_vma(abfd, asect); endaddr = (addr + bfd_section_size(abfd, asect)); maint_print_section_info(name, flags, addr, endaddr, (unsigned long)asect->filepos); } }
static VALUE cls_section_contents(VALUE instance) { /* lazy-loading of section list */ VALUE var = rb_iv_get(instance, IVAR(SEC_ATTR_CONTENTS)); if ( var == Qnil ) { unsigned char * buf; unsigned int size; asection * sec; var = Qnil; Data_Get_Struct(instance, asection, sec); size = bfd_section_size( sec->owner, sec ); buf = calloc( size, 1 ); if ( buf && bfd_get_section_contents(sec->owner, sec, buf, 0, size) ) { var = rb_str_new( (const char *) buf, size ); rb_iv_set(instance, IVAR(SEC_ATTR_CONTENTS), var); } } return var; }
static enum gdb_osabi i386_cygwin_osabi_sniffer (bfd *abfd) { char *target_name = bfd_get_target (abfd); if (strcmp (target_name, "pei-i386") == 0) return GDB_OSABI_CYGWIN; /* Cygwin uses elf core dumps. Do not claim all ELF executables, check whether there is a .reg section of proper size. */ if (strcmp (target_name, "elf32-i386") == 0) { asection *section = bfd_get_section_by_name (abfd, ".reg"); if (section && bfd_section_size (abfd, section) == I386_WINDOWS_SIZEOF_GREGSET) return GDB_OSABI_CYGWIN; } return GDB_OSABI_UNKNOWN; }
/// Examines the bfd in order to find the sections containing data to be loaded. /// Also fills the program_data array. void trap::ExecLoader::load_program_data() { bfd_section* p = NULL; std::map<unsigned long, unsigned char> mem_map; for (p = this->exec_image->sections; p != NULL; p = p->next) { flagword flags = bfd_get_section_flags(this->exec_image, p); if ((flags & SEC_ALLOC) != 0 && (flags & SEC_DEBUGGING) == 0 && (flags & SEC_THREAD_LOCAL) == 0) { //Ok, this is a section which must be in the final executable; //Lets see if it has content: if not I have to pad the section with zeros, //otherwise I load it bfd_size_type datasize = bfd_section_size(this->exec_image, p); bfd_vma vma = bfd_get_section_vma(this->exec_image, p); std::map<unsigned long, unsigned char>::iterator mem_it = mem_map.begin(); if ((flags & SEC_HAS_CONTENTS) != 0) { /*#ifndef NDEBUG std::cerr << "Loading data fom section " << p->name << " Start Address " << std::showbase << std::hex << vma << " Size " << std::hex << datasize << " End Address " << std::hex << datasize + vma << std::dec << " Swap Endianess " << swap_endianess << " flags " << std::hex << std::showbase << flags << std::dec << std::endl; #endif*/ bfd_byte* data = new bfd_byte[datasize]; bfd_get_section_contents (this->exec_image, p, data, 0, datasize); for (unsigned i = 0; i < datasize; i++) { mem_it = mem_map.insert(mem_it, std::pair<unsigned long, unsigned char>(vma + i, data[i])); } delete [] data; } else { /*#ifndef NDEBUG std::cerr << "Filling with 0s section " << p->name << " Start Address " << std::showbase << std::hex << vma << " Size " << std::hex << datasize << " End Address " << std::hex << datasize + vma << std::dec << std::endl; #endif*/ for (unsigned i = 0; i < datasize; i++) mem_it = mem_map.insert(mem_it, std::pair<unsigned long, unsigned char>(vma + i, 0)); } } } //ok, I now have all the map of the memory; I simply have to fill in the //this->program_data array this->data_start = mem_map.begin()->first; this->program_dim = mem_map.rbegin()->first - this->data_start + 1; this->program_data = new unsigned char[this->program_dim]; std::map<unsigned long, unsigned char>::iterator mem_it, mem_end; for (mem_it = mem_map.begin(), mem_end = mem_map.end(); mem_it != mem_end; mem_it++) { this->program_data[mem_it->first - this->data_start] = mem_it->second; } } // ExecLoader::load_program_data()
static const struct target_desc * mips_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { asection *section = bfd_get_section_by_name (abfd, ".reg"); if (! section) return NULL; switch (bfd_section_size (abfd, section)) { case sizeof (mips_elf_gregset_t): return mips_tdesc_gp32; case sizeof (mips64_elf_gregset_t): return mips_tdesc_gp64; default: return NULL; } }
static void add_to_section_table (bfd *abfd, struct bfd_section *asect, void *table_pp_char) { struct target_section **table_pp = (struct target_section **) table_pp_char; flagword aflag; /* Check the section flags, but do not discard zero-length sections, since some symbols may still be attached to this section. For instance, we encountered on sparc-solaris 2.10 a shared library with an empty .bss section to which a symbol named "_end" was attached. The address of this symbol still needs to be relocated. */ aflag = bfd_get_section_flags (abfd, asect); if (!(aflag & SEC_ALLOC)) return; (*table_pp)->bfd = abfd; (*table_pp)->the_bfd_section = asect; (*table_pp)->addr = bfd_section_vma (abfd, asect); (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect); (*table_pp)++; }
static void print_bfd_section_info (bfd *abfd, asection *asect, void *arg) { flagword flags = bfd_get_section_flags (abfd, asect); const char *name = bfd_section_name (abfd, asect); if (arg == NULL || *((char *) arg) == '\0' || match_substring ((char *) arg, name) || match_bfd_flags ((char *) arg, flags)) { struct gdbarch *gdbarch = gdbarch_from_bfd (abfd); int addr_size = gdbarch_addr_bit (gdbarch) / 8; CORE_ADDR addr, endaddr; addr = bfd_section_vma (abfd, asect); endaddr = addr + bfd_section_size (abfd, asect); maint_print_section_info (name, flags, addr, endaddr, asect->filepos, addr_size); } }
static char * fbsd_thread_get_name (lwpid_t lwpid) { static char last_thr_name[MAXCOMLEN + 1]; char section_name[32]; struct ptrace_lwpinfo lwpinfo; bfd_size_type size; struct bfd_section *section; if (target_has_execution) { if (ptrace (PT_LWPINFO, lwpid, (caddr_t)&lwpinfo, sizeof (lwpinfo)) == -1) goto fail; strncpy (last_thr_name, lwpinfo.pl_tdname, sizeof (last_thr_name) - 1); } else { snprintf (section_name, sizeof (section_name), ".tname/%u", lwpid); section = bfd_get_section_by_name (core_bfd, section_name); if (! section) goto fail; /* Section size fix-up. */ size = bfd_section_size (core_bfd, section); if (size > sizeof (last_thr_name)) size = sizeof (last_thr_name); if (! bfd_get_section_contents (core_bfd, section, last_thr_name, (file_ptr)0, size)) goto fail; if (last_thr_name[0] == '\0') goto fail; } last_thr_name[sizeof (last_thr_name) - 1] = '\0'; return last_thr_name; fail: strcpy (last_thr_name, "<unknown>"); return last_thr_name; }
static const struct target_desc * ppc_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { asection *cell = bfd_sections_find_if (abfd, ppc_linux_spu_section, NULL); asection *altivec = bfd_get_section_by_name (abfd, ".reg-ppc-vmx"); asection *vsx = bfd_get_section_by_name (abfd, ".reg-ppc-vsx"); asection *section = bfd_get_section_by_name (abfd, ".reg"); if (! section) return NULL; switch (bfd_section_size (abfd, section)) { case 48 * 4: if (cell) return tdesc_powerpc_cell32l; else if (vsx) return tdesc_powerpc_vsx32l; else if (altivec) return tdesc_powerpc_altivec32l; else return tdesc_powerpc_32l; case 48 * 8: if (cell) return tdesc_powerpc_cell64l; else if (vsx) return tdesc_powerpc_vsx64l; else if (altivec) return tdesc_powerpc_altivec64l; else return tdesc_powerpc_64l; default: return NULL; } }