Exemple #1
0
bool
rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name)
{
  const char*       pname;
  rtems_rtl_data_t* rtl;

  /*
   * Parse the name. The object descriptor will have the archive name and/or
   * object name fields filled in. A find of the file will result in the file
   * name (fname) field pointing to the actual file if present on the file
   * system.
   */
  if (!rtems_rtl_obj_parse_name (obj, name))
    return false;

  /*
   * If the archive field (aname) is set we use that name else we use the
   * object field (oname). If selected name is absolute we just point the aname
   * field to the fname field to that name. If the field is relative we search
   * the paths set in the RTL for the file.
   */
  if (rtems_rtl_obj_aname_valid (obj))
    pname = rtems_rtl_obj_aname (obj);
  else
    pname = rtems_rtl_obj_oname (obj);

  rtl = rtems_rtl_lock ();

  if (!rtems_rtl_find_file (pname, rtl->paths, &obj->fname, &obj->fsize))
  {
    rtems_rtl_set_error (ENOENT, "file not found");
    rtems_rtl_unlock ();
    return false;
  }

  rtems_rtl_unlock ();

  return true;
}
Exemple #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;
}