26 #include "readline/tilde.h" 52 head_new->
next = *headp;
122 if (sect->output_section == NULL)
123 sect->output_section = sect;
125 if ((bfd_get_section_flags (abfd, sect) & SEC_ALLOC) == 0)
130 if ((bfd_get_section_flags (abfd, sect) & SEC_READONLY) == 0)
132 if ((bfd_get_section_flags (abfd, sect) & SEC_CODE) != 0)
137 "module \"%s\" section \"%s\" size %s prot %u\n",
138 bfd_get_filename (abfd),
139 bfd_get_section_name (abfd, sect),
141 bfd_get_section_size (sect)),
148 || (data->
last_prot != prot && bfd_get_section_size (sect) != 0))
160 "allocated %s bytes at %s prot %u\n",
169 error (
_(
"Inferior compiled module address %s " 170 "is not aligned to BFD required %s."),
175 sect_iter = sect_iter->next)
176 if ((bfd_get_section_flags (abfd, sect_iter) & SEC_ALLOC) != 0)
177 bfd_set_section_vma (abfd, sect_iter,
178 addr + bfd_get_section_vma (abfd, sect_iter));
189 alignment = ((
CORE_ADDR) 1) << bfd_get_section_alignment (abfd, sect);
194 bfd_set_section_vma (abfd, sect, data->
last_size);
196 data->
last_size += bfd_get_section_size (sect);
204 struct bfd_link_hash_entry *h, bfd *nbfd,
205 asection *nsec, bfd_vma nval)
207 bfd *abfd = link_info->input_bfds;
209 if (link_info->allow_multiple_definition)
211 warning (
_(
"Compiled module \"%s\": multiple symbol definitions: %s"),
212 bfd_get_filename (abfd), h->root.string);
219 const char *
symbol, bfd *abfd, asection *section,
222 warning (
_(
"Compiled module \"%s\" section \"%s\": warning: %s"),
223 bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
231 const char *
name, bfd *abfd, asection *section,
232 bfd_vma address, bfd_boolean is_fatal)
234 warning (
_(
"Cannot resolve relocation to \"%s\" " 235 "from compiled module \"%s\" section \"%s\"."),
236 name, bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
243 struct bfd_link_hash_entry *entry,
244 const char *
name,
const char *reloc_name,
245 bfd_vma addend, bfd *abfd, asection *section,
254 const char *message, bfd *abfd,
255 asection *section, bfd_vma address)
257 warning (
_(
"Compiled module \"%s\" section \"%s\": dangerous " 259 bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
267 const char *
name, bfd *abfd, asection *section,
270 warning (
_(
"Compiled module \"%s\" section \"%s\": unattached " 272 bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
290 warning (
_(
"Compile module: warning: %s"), str.c_str ());
330 if (data->
abfd->is_linker_output)
331 (*data->
abfd->link.hash->hash_table_free) (data->
abfd);
340 asymbol **symbol_table = (asymbol **) data;
341 bfd_byte *sect_data, *sect_data_got;
343 struct bfd_link_info link_info;
344 struct bfd_link_order link_order;
348 if ((bfd_get_section_flags (
abfd, sect) & (SEC_ALLOC | SEC_LOAD))
349 != (SEC_ALLOC | SEC_LOAD))
352 if (bfd_get_section_size (sect) == 0)
357 memset (&link_info, 0,
sizeof (link_info));
358 link_info.output_bfd =
abfd;
359 link_info.input_bfds =
abfd;
360 link_info.input_bfds_tail = &
abfd->link.next;
365 abfd->link.next = NULL;
366 link_info.hash = bfd_link_hash_table_create (
abfd);
371 memset (&link_order, 0,
sizeof (link_order));
372 link_order.next = NULL;
373 link_order.type = bfd_indirect_link_order;
374 link_order.offset = 0;
375 link_order.size = bfd_get_section_size (sect);
376 link_order.u.indirect.section = sect;
378 sect_data = (bfd_byte *)
xmalloc (bfd_get_section_size (sect));
381 sect_data_got = bfd_get_relocated_section_contents (
abfd, &link_info,
382 &link_order, sect_data,
383 FALSE, symbol_table);
385 if (sect_data_got == NULL)
386 error (
_(
"Cannot map compiled module \"%s\" section \"%s\": %s"),
387 bfd_get_filename (
abfd), bfd_get_section_name (
abfd, sect),
388 bfd_errmsg (bfd_get_error ()));
391 inferior_addr = bfd_get_section_vma (
abfd, sect);
393 bfd_get_section_size (sect)))
394 error (
_(
"Cannot write compiled module \"%s\" section \"%s\" " 395 "to inferior memory range %s-%s."),
396 bfd_get_filename (
abfd), bfd_get_section_name (
abfd, sect),
399 inferior_addr + bfd_get_section_size (sect)));
420 struct symbol *gdb_ptr_type_sym;
422 struct symbol *gdb_val_sym = NULL;
423 struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type, *retval;
433 gdb_ptr_type_sym = NULL;
434 for (block_loop = 0; block_loop <
nblocks; block_loop++)
436 struct symbol *
function = NULL;
437 const struct block *function_block;
446 if (gdb_val_sym == NULL)
449 function_block =
block;
455 if (
function != NULL)
465 if (block_loop == nblocks)
474 if (gdb_ptr_type_sym == NULL)
485 error (
_(
"Expected address scope in compiled module \"%s\"."),
491 error (
_(
"Invalid type code %d of symbol \"%s\" " 492 "in compiled module \"%s\"."),
496 retval = gdb_type_from_ptr;
505 error (
_(
"Invalid type code %d of symbol \"%s\" " 506 "in compiled module \"%s\"."),
512 error (
_(
"Referenced types do not match for symbols \"%s\" and \"%s\" " 513 "in compiled module \"%s\"."),
528 struct type *regsp_type, *regs_type;
536 error (
_(
"Invalid type code %d of first parameter of function \"%s\" " 537 "in compiled module \"%s\"."),
538 TYPE_CODE (regsp_type), GCC_FE_WRAPPER_FUNCTION,
543 error (
_(
"Invalid type code %d of dereferenced first parameter " 544 "of function \"%s\" in compiled module \"%s\"."),
545 TYPE_CODE (regs_type), GCC_FE_WRAPPER_FUNCTION,
561 for (fieldno = 0; fieldno <
TYPE_NFIELDS (regs_type); fieldno++)
571 struct value *regval;
577 if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)
578 error (
_(
"Invalid register \"%s\" position %s bits or size %s bits"),
584 error (
_(
"Invalid register \"%s\" type code %d"), reg_name,
591 error (
_(
"Register \"%s\" is optimized out."), reg_name);
593 error (
_(
"Register \"%s\" is not available."), reg_name);
598 error (
_(
"Cannot write register \"%s\" to inferior memory at %s."),
620 asymbol **symbol_table, **symp;
621 long number_of_symbols, missing_symbols;
623 struct type *regs_type, *out_value_type = NULL;
626 int expect_parameters;
627 struct type *expect_return_type;
635 error (
_(
"\"%s\": could not open as compiled module: %s"),
636 filename.get (), bfd_errmsg (bfd_get_error ()));
638 if (!bfd_check_format_matches (abfd.
get (), bfd_object, &matching))
639 error (
_(
"\"%s\": not in loadable format: %s"),
642 if ((bfd_get_file_flags (abfd.
get ()) & (EXEC_P | DYNAMIC)) != 0)
643 error (
_(
"\"%s\": not in object format."), filename.get ());
654 storage_needed = bfd_get_symtab_upper_bound (abfd.
get ());
655 if (storage_needed < 0)
656 error (
_(
"Cannot read symbols of compiled module \"%s\": %s"),
657 filename.get (), bfd_errmsg (bfd_get_error ()));
661 std::unique_ptr<struct objfile> objfile_holder
664 objfile = objfile_holder.get ();
667 GCC_FE_WRAPPER_FUNCTION,
669 if (func_sym == NULL)
670 error (
_(
"Cannot find function \"%s\" in compiled module \"%s\"."),
674 error (
_(
"Invalid type code %d of function \"%s\" in compiled " 682 expect_parameters = 1;
686 expect_parameters = 0;
691 expect_parameters = 2;
698 error (
_(
"Invalid %d parameters of function \"%s\" in compiled " 703 error (
_(
"Invalid return type of function \"%s\" in compiled " 712 number_of_symbols = bfd_canonicalize_symtab (abfd.
get (), symbol_table);
713 if (number_of_symbols < 0)
714 error (
_(
"Cannot parse symbols of compiled module \"%s\": %s"),
715 filename.get (), bfd_errmsg (bfd_get_error ()));
718 for (symp = symbol_table; symp < symbol_table + number_of_symbols; symp++)
720 asymbol *sym = *symp;
724 sym->flags = BSF_GLOBAL;
725 sym->section = bfd_abs_section_ptr;
726 if (strcmp (sym->name,
"_GLOBAL_OFFSET_TABLE_") == 0)
730 "ELF symbol \"%s\" relocated to zero\n",
740 switch (bmsym.
minsym == NULL
747 "ELF mst_text symbol \"%s\" relocated to %s\n",
756 "ELF mst_text_gnu_ifunc symbol \"%s\" " 762 warning (
_(
"Could not find symbol \"%s\" " 763 "for compiled module \"%s\"."),
764 sym->name, filename.get ());
769 error (
_(
"%ld symbols were missing, cannot continue."), missing_symbols);
774 if (regs_type == NULL)
786 "allocated %s bytes at %s for registers\n",
797 if (out_value_type == NULL)
812 "allocated %s bytes at %s for printed value\n",
819 retval->
objfile = objfile_holder.release ();
823 retval->
scope = scope;
830 munmap_list_head = NULL;
struct gdbarch * target_gdbarch(void)
#define COMPILE_I_EXPR_PTR_TYPE
void gdbarch_infcall_munmap(struct gdbarch *gdbarch, CORE_ADDR addr, CORE_ADDR size)
static void copy_sections(bfd *abfd, asection *sect, void *data)
struct frame_info * get_current_frame(void)
static void link_callbacks_unattached_reloc(struct bfd_link_info *link_info, const char *name, bfd *abfd, asection *section, bfd_vma address)
#define TYPE_FIELD_NAME(thistype, n)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
static void link_callbacks_multiple_definition(struct bfd_link_info *link_info, struct bfd_link_hash_entry *h, bfd *nbfd, asection *nsec, bfd_vma nval)
struct regcache * get_thread_regcache(ptid_t ptid)
static void link_callbacks_reloc_dangerous(struct bfd_link_info *link_info, const char *message, bfd *abfd, asection *section, bfd_vma address)
const char * source_file() const
#define BMSYMBOL_VALUE_ADDRESS(symbol)
void warning(const char *fmt,...)
struct munmap_list * munmap_list_head
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
#define BLOCKVECTOR_BLOCK(blocklist, n)
#define TYPE_FIELD_TYPE(thistype, n)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
#define BLOCK_FUNCTION(bl)
int types_deeply_equal(struct type *type1, struct type *type2)
struct munmap_list ** munmap_list_headp
struct value * value_from_register(struct type *type, int regnum, struct frame_info *frame)
static void link_callbacks_reloc_overflow(struct bfd_link_info *link_info, struct bfd_link_hash_entry *entry, const char *name, const char *reloc_name, bfd_vma addend, bfd *abfd, asection *section, bfd_vma address)
#define SYMTAB_BLOCKVECTOR(symtab)
struct objfile * symbol_file_add_from_bfd(bfd *abfd, const char *name, symfile_add_flags add_flags, struct section_addr_info *addrs, objfile_flags flags, struct objfile *parent)
struct type * check_typedef(struct type *type)
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd)
const gdb_byte * value_contents(struct value *value)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
std::string string_vprintf(const char *fmt, va_list args)
static const struct bfd_link_callbacks link_callbacks
objfile(bfd *, const char *, objfile_flags)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
#define COMPILE_I_SIMPLE_REGISTER_DUMMY
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
char * pulongest(ULONGEST u)
#define COMPILE_I_EXPR_VAL
CORE_ADDR gdbarch_infcall_mmap(struct gdbarch *gdbarch, CORE_ADDR size, unsigned prot)
#define BLOCK_SUPERBLOCK(bl)
static void link_callbacks_einfo(const char *fmt,...) ATTRIBUTE_PRINTF(1
#define GDB_MMAP_PROT_READ
#define GDB_MMAP_PROT_WRITE
#define SYMBOL_LINKAGE_NAME(symbol)
#define GDB_MMAP_PROT_EXEC
const char * gdb_bfd_errmsg(bfd_error_type error_tag, char **matching)
const char * objfile_name(const struct objfile *objfile)
#define TYPE_FIELD_BITSIZE(thistype, n)
#define TYPE_FIELD_BITPOS(thistype, n)
static void link_callbacks_undefined_symbol(struct bfd_link_info *link_info, const char *name, bfd *abfd, asection *section, bfd_vma address, bfd_boolean is_fatal)
struct compile_module * compile_object_load(const compile_file_names &file_names, enum compile_i_scope_types scope, void *scope_data)
enum compile_i_scope_types scope
asection * last_section_first
int value_entirely_available(struct value *value)
static void store_regs(struct type *regs_type, CORE_ADDR regs_base)
#define MSYMBOL_TYPE(msymbol)
int value_optimized_out(struct value *value)
#define TYPE_TARGET_TYPE(thistype)
struct block_symbol lookup_global_symbol_from_objfile(struct objfile *main_objfile, const char *name, const domain_enum domain)
#define TYPE_CODE(thistype)
struct minimal_symbol * minsym
void munmap_list_free(struct munmap_list *head)
#define TYPE_NFIELDS(thistype)
#define BLOCKVECTOR_NBLOCKS(blocklist)
static void setup_sections(bfd *abfd, asection *sect, void *data_voidp)
unsigned long long ULONGEST
struct munmap_list * next
#define SYMBOL_TYPE(symbol)
#define TYPE_LENGTH(thistype)
static void munmap_list_add(struct munmap_list **headp, CORE_ADDR addr, CORE_ADDR size)
CORE_ADDR last_max_alignment
static struct type * get_regs_type(struct symbol *func_sym, struct objfile *objfile)
struct symbol * block_lookup_symbol(const struct block *block, const char *name, symbol_name_match_type match_type, const domain_enum domain)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static void munmap_listp_free_cleanup(void *headp_voidp)
static void link_hash_table_free(void *d)
struct type * builtin_void
const char * object_file() const
void error(const char *fmt,...)
static void link_callbacks_warning(struct bfd_link_info *link_info, const char *xwarning, const char *symbol, bfd *abfd, asection *section, bfd_vma address)
int compile_register_name_demangle(struct gdbarch *gdbarch, const char *reg_name)
struct type * out_value_type
#define gnu_ifunc_resolve_addr
void do_cleanups(struct cleanup *old_chain)
static struct type * get_out_value_type(struct symbol *func_sym, struct objfile *objfile, enum compile_i_scope_types scope)