Пример #1
0
bool
rtems_rtl_obj_load (rtems_rtl_obj_t* obj)
{
  int fd;

  if (!rtems_rtl_obj_fname_valid (obj))
  {
    rtems_rtl_set_error (ENOMEM, "invalid object file name path");
    return false;
  }

  fd = open (rtems_rtl_obj_fname (obj), O_RDONLY);
  if (fd < 0)
  {
    rtems_rtl_set_error (ENOMEM, "opening for object file");
    return false;
  }

  /*
   * Find the object file in the archive if it is an archive that
   * has been opened.
   */
  if (rtems_rtl_obj_aname_valid (obj))
  {
    if (!rtems_rtl_obj_archive_find (obj, fd))
    {
      rtems_rtl_obj_caches_flush ();
      close (fd);
      return false;
    }
  }

  /*
   * Call the format specific loader. Currently this is a call to the ELF
   * loader. This call could be changed to allow probes then calls if more than
   * one format is supported.
   */
  if (!rtems_rtl_obj_file_load (obj, fd))
  {
    rtems_rtl_obj_caches_flush ();
    close (fd);
    return false;
  }

  if (!_rtld_linkmap_add (obj)) /* For GDB */
  {
    close (fd);
    return false;
  }

  rtems_rtl_obj_caches_flush ();

  close (fd);

  return true;
}
Пример #2
0
/**
 * Object printer.
 */
static bool
rtems_rtl_obj_printer (rtems_rtl_obj_print_t* print, rtems_rtl_obj_t* obj)
{
    char flags_str[33];

    /*
     * Skip the base module unless asked to show it.
     */
    if (!print->base && (obj == print->rtl->base))
        return true;

    if (print->oname)
    {
        printf ("%-*cobject name   : %s\n",
                print->indent, ' ', rtems_rtl_obj_oname (obj));
    }
    if (print->names)
    {
        printf ("%-*cfile name     : %s\n",
                print->indent, ' ', rtems_rtl_obj_fname (obj));
        printf ("%-*carchive name  : %s\n",
                print->indent, ' ', rtems_rtl_obj_aname (obj));
        strcpy (flags_str, "--");
        if (obj->flags & RTEMS_RTL_OBJ_LOCKED)
            flags_str[0] = 'L';
        if (obj->flags & RTEMS_RTL_OBJ_UNRESOLVED)
            flags_str[1] = 'U';
        printf ("%-*cflags         : %s\n", print->indent, ' ', flags_str);
        printf ("%-*cfile offset   : %" PRIdoff_t "\n", print->indent, ' ', obj->ooffset);
        printf ("%-*cfile size     : %zi\n", print->indent, ' ', obj->fsize);
    }
    if (print->memory_map)
    {
        printf ("%-*cexec size     : %zi\n", print->indent, ' ', obj->exec_size);
        printf ("%-*ctext base     : %p (%zi)\n", print->indent, ' ',
                obj->text_base, rtems_rtl_delta_voids (obj->const_base, obj->text_base));
        printf ("%-*cconst base    : %p (%zi)\n", print->indent, ' ',
                obj->const_base, rtems_rtl_delta_voids (obj->data_base, obj->const_base));
        printf ("%-*cdata base     : %p (%zi)\n", print->indent, ' ',
                obj->data_base, rtems_rtl_delta_voids (obj->bss_base, obj->data_base));
        printf ("%-*cbss base      : %p (%zi)\n", print->indent, ' ',
                obj->bss_base, obj->bss_size);
    }
    printf ("%-*cunresolved    : %lu\n", print->indent, ' ', obj->unresolved);
    printf ("%-*csymbols       : %zi\n", print->indent, ' ', obj->global_syms);
    printf ("%-*csymbol memory : %zi\n", print->indent, ' ', obj->global_size);
    if (print->symbols)
    {
        int max_len = 0;
        int s;
        for (s = 0; s < obj->global_syms; ++s)
        {
            int len = strlen (obj->global_table[s].name);
            if (len > max_len)
                max_len = len;
        }
        for (s = 0; s < obj->global_syms; ++s)
            printf ("%-*c%-*s = %p\n", print->indent + 2, ' ',
                    max_len, obj->global_table[s].name, obj->global_table[s].value);
    }
    printf ("\n");
    return true;
}