26 #include "readline/tilde.h"
51 head_new->
next = *headp;
121 if (sect->output_section == NULL)
122 sect->output_section = sect;
124 if ((bfd_get_section_flags (abfd, sect) & SEC_ALLOC) == 0)
129 if ((bfd_get_section_flags (abfd, sect) & SEC_READONLY) == 0)
131 if ((bfd_get_section_flags (abfd, sect) & SEC_CODE) != 0)
136 "module \"%s\" section \"%s\" size %s prot %u\n",
137 bfd_get_filename (abfd),
138 bfd_get_section_name (abfd, sect),
140 bfd_get_section_size (sect)),
147 || (data->
last_prot != prot && bfd_get_section_size (sect) != 0))
159 "allocated %s bytes at %s prot %u\n",
168 error (
_(
"Inferior compiled module address %s "
169 "is not aligned to BFD required %s."),
174 sect_iter = sect_iter->next)
175 if ((bfd_get_section_flags (abfd, sect_iter) & SEC_ALLOC) != 0)
176 bfd_set_section_vma (abfd, sect_iter,
177 addr + bfd_get_section_vma (abfd, sect_iter));
188 alignment = ((
CORE_ADDR) 1) << bfd_get_section_alignment (abfd, sect);
193 bfd_set_section_vma (abfd, sect, data->
last_size);
195 data->
last_size += bfd_get_section_size (sect);
203 struct bfd_link_hash_entry *h, bfd *nbfd,
204 asection *nsec, bfd_vma nval)
206 bfd *abfd = link_info->input_bfds;
208 if (link_info->allow_multiple_definition)
210 warning (
_(
"Compiled module \"%s\": multiple symbol definitions: %s"),
211 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),
233 const char *
name, bfd *abfd, asection *section,
234 bfd_vma address, bfd_boolean is_fatal)
236 warning (
_(
"Cannot resolve relocation to \"%s\" "
237 "from compiled module \"%s\" section \"%s\"."),
238 name, bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
246 struct bfd_link_hash_entry *entry,
247 const char *
name,
const char *reloc_name,
248 bfd_vma addend, bfd *abfd, asection *section,
259 const char *message, bfd *abfd,
260 asection *section, bfd_vma address)
262 warning (
_(
"Compiled module \"%s\" section \"%s\": dangerous "
264 bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
273 const char *
name, bfd *abfd, asection *section,
276 warning (
_(
"Compiled module \"%s\" section \"%s\": unattached "
278 bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
300 warning (
_(
"Compile module: warning: %s"), str);
341 if (data->
abfd->is_linker_output)
342 (*data->
abfd->link.hash->hash_table_free) (data->
abfd);
351 asymbol **symbol_table = data;
352 bfd_byte *sect_data, *sect_data_got;
354 struct bfd_link_info link_info;
355 struct bfd_link_order link_order;
359 if ((bfd_get_section_flags (abfd, sect) & (SEC_ALLOC | SEC_LOAD))
360 != (SEC_ALLOC | SEC_LOAD))
363 if (bfd_get_section_size (sect) == 0)
368 memset (&link_info, 0,
sizeof (link_info));
369 link_info.output_bfd =
abfd;
370 link_info.input_bfds =
abfd;
371 link_info.input_bfds_tail = &abfd->link.next;
374 cleanup_data.
link_next = abfd->link.next;
376 abfd->link.next = NULL;
377 link_info.hash = bfd_link_hash_table_create (abfd);
382 memset (&link_order, 0,
sizeof (link_order));
383 link_order.next = NULL;
384 link_order.type = bfd_indirect_link_order;
385 link_order.offset = 0;
386 link_order.size = bfd_get_section_size (sect);
387 link_order.u.indirect.section = sect;
389 sect_data =
xmalloc (bfd_get_section_size (sect));
392 sect_data_got = bfd_get_relocated_section_contents (abfd, &link_info,
393 &link_order, sect_data,
394 FALSE, symbol_table);
396 if (sect_data_got == NULL)
397 error (
_(
"Cannot map compiled module \"%s\" section \"%s\": %s"),
398 bfd_get_filename (abfd), bfd_get_section_name (abfd, sect),
399 bfd_errmsg (bfd_get_error ()));
402 inferior_addr = bfd_get_section_vma (abfd, sect);
404 bfd_get_section_size (sect)))
405 error (
_(
"Cannot write compiled module \"%s\" section \"%s\" "
406 "to inferior memory range %s-%s."),
407 bfd_get_filename (abfd), bfd_get_section_name (abfd, sect),
410 inferior_addr + bfd_get_section_size (sect)));
431 struct symbol *gdb_ptr_type_sym;
433 struct symbol *gdb_val_sym = NULL;
434 struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type, *retval;
444 gdb_ptr_type_sym = NULL;
445 for (block_loop = 0; block_loop <
nblocks; block_loop++)
447 struct symbol *
function = NULL;
448 const struct block *function_block;
454 if (gdb_val_sym == NULL)
457 function_block = block;
463 if (
function != NULL)
473 if (block_loop == nblocks)
481 if (gdb_ptr_type_sym == NULL)
492 error (
_(
"Expected address scope in compiled module \"%s\"."),
498 error (
_(
"Invalid type code %d of symbol \"%s\" "
499 "in compiled module \"%s\"."),
503 retval = gdb_type_from_ptr;
512 error (
_(
"Invalid type code %d of symbol \"%s\" "
513 "in compiled module \"%s\"."),
519 error (
_(
"Referenced types do not match for symbols \"%s\" and \"%s\" "
520 "in compiled module \"%s\"."),
535 struct type *regsp_type, *regs_type;
543 error (
_(
"Invalid type code %d of first parameter of function \"%s\" "
544 "in compiled module \"%s\"."),
545 TYPE_CODE (regsp_type), GCC_FE_WRAPPER_FUNCTION,
550 error (
_(
"Invalid type code %d of dereferenced first parameter "
551 "of function \"%s\" in compiled module \"%s\"."),
552 TYPE_CODE (regs_type), GCC_FE_WRAPPER_FUNCTION,
568 for (fieldno = 0; fieldno <
TYPE_NFIELDS (regs_type); fieldno++)
578 struct value *regval;
584 if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)
585 error (
_(
"Invalid register \"%s\" position %s bits or size %s bits"),
587 reg_offset = reg_bitpos / 8;
591 error (
_(
"Invalid register \"%s\" type code %d"), reg_name,
598 error (
_(
"Register \"%s\" is optimized out."), reg_name);
600 error (
_(
"Register \"%s\" is not available."), reg_name);
605 error (
_(
"Cannot write register \"%s\" to inferior memory at %s."),
606 reg_name,
paddress (gdbarch, inferior_addr));
622 struct cleanup *cleanups, *cleanups_free_objfile;
625 CORE_ADDR addr, regs_addr, out_value_addr = 0;
630 asymbol **symbol_table, **symp;
631 long number_of_symbols, missing_symbols;
635 struct type *regs_type, *out_value_type = NULL;
636 char *filename, **matching;
638 int expect_parameters;
639 struct type *expect_return_type;
642 filename = tilde_expand (object_file);
647 error (
_(
"\"%s\": could not open as compiled module: %s"),
648 filename, bfd_errmsg (bfd_get_error ()));
651 if (!bfd_check_format_matches (abfd, bfd_object, &matching))
652 error (
_(
"\"%s\": not in loadable format: %s"),
655 if ((bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC)) != 0)
656 error (
_(
"\"%s\": not in object format."), filename);
664 bfd_map_over_sections (abfd,
setup_sections, &setup_sections_data);
667 storage_needed = bfd_get_symtab_upper_bound (abfd);
668 if (storage_needed < 0)
669 error (
_(
"Cannot read symbols of compiled module \"%s\": %s"),
670 filename, bfd_errmsg (bfd_get_error ()));
678 GCC_FE_WRAPPER_FUNCTION,
680 if (func_sym == NULL)
681 error (
_(
"Cannot find function \"%s\" in compiled module \"%s\"."),
685 error (
_(
"Invalid type code %d of function \"%s\" in compiled "
687 TYPE_CODE (func_type), GCC_FE_WRAPPER_FUNCTION,
693 expect_parameters = 1;
697 expect_parameters = 0;
702 expect_parameters = 2;
709 error (
_(
"Invalid %d parameters of function \"%s\" in compiled "
714 error (
_(
"Invalid return type of function \"%s\" in compiled "
721 symbol_table = obstack_alloc (&objfile->
objfile_obstack, storage_needed);
722 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
723 if (number_of_symbols < 0)
724 error (
_(
"Cannot parse symbols of compiled module \"%s\": %s"),
725 filename, bfd_errmsg (bfd_get_error ()));
728 for (symp = symbol_table; symp < symbol_table + number_of_symbols; symp++)
730 asymbol *sym = *symp;
734 sym->flags = BSF_GLOBAL;
735 sym->section = bfd_abs_section_ptr;
736 if (strcmp (sym->name,
"_GLOBAL_OFFSET_TABLE_") == 0)
740 "ELF symbol \"%s\" relocated to zero\n",
750 switch (bmsym.
minsym == NULL
757 "ELF mst_text symbol \"%s\" relocated to %s\n",
766 "ELF mst_text_gnu_ifunc symbol \"%s\" "
772 warning (
_(
"Could not find symbol \"%s\" "
773 "for compiled module \"%s\"."),
774 sym->name, filename);
779 error (
_(
"%ld symbols were missing, cannot continue."), missing_symbols);
784 if (regs_type == NULL)
796 "allocated %s bytes at %s for registers\n",
807 if (out_value_type == NULL)
822 "allocated %s bytes at %s for printed value\n",
830 retval =
xmalloc (
sizeof (*retval));
835 retval->
scope = scope;
842 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)
#define TYPE_FIELD_NAME(thistype, n)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
struct compile_module * compile_object_load(const char *object_file, const char *source_file, enum compile_i_scope_types scope, void *scope_data)
struct regcache * get_thread_regcache(ptid_t ptid)
struct objfile * symbol_file_add_from_bfd(bfd *abfd, const char *name, int add_flags, struct section_addr_info *addrs, int flags, struct objfile *parent)
char * xstrvprintf(const char *format, va_list ap)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
void warning(const char *fmt,...)
struct type ** const(pascal_builtin_types[])
struct munmap_list * munmap_list_head
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void internal_error(const char *file, int line, const char *fmt,...)
static bfd_boolean link_callbacks_reloc_dangerous(struct bfd_link_info *link_info, const char *message, bfd *abfd, asection *section, bfd_vma address)
struct symbol * lookup_global_symbol_from_objfile(struct objfile *main_objfile, const char *name, const domain_enum domain)
#define BLOCKVECTOR_BLOCK(blocklist, n)
struct bfd * gdb_bfd_open(const char *name, const char *target, int fd)
static bfd_boolean link_callbacks_undefined_symbol(struct bfd_link_info *link_info, const char *name, bfd *abfd, asection *section, bfd_vma address, bfd_boolean is_fatal)
#define TYPE_FIELD_TYPE(thistype, n)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
#define BLOCK_FUNCTION(bl)
struct obstack objfile_obstack
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)
#define SYMTAB_BLOCKVECTOR(symtab)
struct type * check_typedef(struct type *type)
const gdb_byte * value_contents(struct value *value)
struct cleanup * make_cleanup_free_objfile(struct objfile *obj)
static const struct bfd_link_callbacks link_callbacks
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
struct symbol * block_lookup_symbol(const struct block *block, const char *name, const domain_enum domain)
const char * gdb_bfd_errmsg(bfd_error_type error_tag, char **matching)
const char * objfile_name(const struct objfile *objfile)
struct cleanup * make_cleanup_bfd_unref(bfd *abfd)
struct ui_file * gdb_stdlog
#define TYPE_FIELD_BITSIZE(thistype, n)
#define TYPE_FIELD_BITPOS(thistype, n)
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)
void discard_cleanups(struct cleanup *old_chain)
int value_optimized_out(struct value *value)
#define TYPE_TARGET_TYPE(thistype)
static bfd_boolean link_callbacks_multiple_definition(struct bfd_link_info *link_info, struct bfd_link_hash_entry *h, bfd *nbfd, asection *nsec, bfd_vma nval)
static bfd_boolean 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 TYPE_CODE(thistype)
struct type * builtin_data_ptr
struct minimal_symbol * minsym
void munmap_list_free(struct munmap_list *head)
#define TYPE_NFIELDS(thistype)
static bfd_boolean link_callbacks_warning(struct bfd_link_info *link_info, const char *xwarning, const char *symbol, bfd *abfd, asection *section, bfd_vma address)
#define CHECK_TYPEDEF(TYPE)
#define BLOCKVECTOR_NBLOCKS(blocklist)
static void setup_sections(bfd *abfd, asection *sect, void *data_voidp)
unsigned long long ULONGEST
static bfd_boolean link_callbacks_unattached_reloc(struct bfd_link_info *link_info, const char *name, bfd *abfd, asection *section, bfd_vma address)
static void ATTRIBUTE_PRINTF(6, 0)
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 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
void error(const char *fmt,...)
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)