Example #1
0
/* add the extra undefined symbols that will be contained in the generated spec file itself */
static void add_extra_undef_symbols(void)
{
    const char *extras[10];
    int i, count = 0;

#define ADD_SYM(name) \
    do { if (!find_symbol( extras[count] = (name), undef_symbols, \
                           nb_undef_symbols )) count++; } while(0)

    sort_symbols( undef_symbols, nb_undef_symbols );

    /* add symbols that will be contained in the spec file itself */
    switch (SpecMode)
    {
    case SPEC_MODE_DLL:
        break;
    case SPEC_MODE_GUIEXE:
        ADD_SYM( "GetCommandLineA" );
        ADD_SYM( "GetStartupInfoA" );
        ADD_SYM( "GetModuleHandleA" );
        /* fall through */
    case SPEC_MODE_CUIEXE:
        ADD_SYM( "__wine_get_main_args" );
        ADD_SYM( "ExitProcess" );
        break;
    case SPEC_MODE_GUIEXE_UNICODE:
        ADD_SYM( "GetCommandLineA" );
        ADD_SYM( "GetStartupInfoA" );
        ADD_SYM( "GetModuleHandleA" );
        /* fall through */
    case SPEC_MODE_CUIEXE_UNICODE:
        ADD_SYM( "__wine_get_wmain_args" );
        ADD_SYM( "ExitProcess" );
        break;
    }
    ADD_SYM( "RtlRaiseException" );
    if (nb_delayed)
    {
       ADD_SYM( "LoadLibraryA" );
       ADD_SYM( "GetProcAddress" );
    }

    for (i = 0; i < nb_entry_points; i++)
    {
        ORDDEF *odp = EntryPoints[i];
        if (odp->flags & FLAG_REGISTER)
        {
            ADD_SYM( "__wine_call_from_32_regs" );
            break;
        }
    }

    if (count)
    {
        for (i = 0; i < count; i++) add_undef_symbol( extras[i] );
        sort_symbols( undef_symbols, nb_undef_symbols );
    }
}
Example #2
0
static void remove_ignored_symbols(void)
{
    int i;

    sort_symbols( ignore_symbols, nb_ignore_symbols );
    for (i = 0; i < nb_undef_symbols; i++)
    {
        if (find_symbol( undef_symbols[i], ignore_symbols, nb_ignore_symbols ))
        {
            free( undef_symbols[i] );
            undef_symbols[i] = NULL;
        }
    }
    remove_symbol_holes();
}
Example #3
0
/* read in the list of exported symbols of a .so */
static void read_exported_symbols( const char *name, struct import *imp )
{
    FILE *f;
    char buffer[1024];
    char *fullname, *cmdline;
    const char *ext;
    int size, err;

    imp->exports    = NULL;
    imp->nb_exports = size = 0;

    if (!(ext = strrchr( name, '.' ))) ext = name + strlen(name);

    if (!(fullname = open_library( name ))) return;
    cmdline = xmalloc( strlen(fullname) + 7 );
#if !defined(__APPLE__)    
    sprintf( cmdline, "nm -D %s", fullname );
#else
    /* MacOS X does not support the -D commandline option */
    sprintf( cmdline, "nm %s", fullname);
#endif
    free( fullname );

    if (!(f = popen( cmdline, "r" )))
        fatal_error( "Cannot execute '%s'\n", cmdline );

    while (fgets( buffer, sizeof(buffer), f ))
    {
        char *p = buffer + strlen(buffer) - 1;
        if (p < buffer) continue;
        if (*p == '\n') *p-- = 0;
        if (!(p = strstr( buffer, "__wine_dllexport_" ))) continue;
        p += 17;
        if (strncmp( p, name, ext - name )) continue;
        p += ext - name;
        if (*p++ != '_') continue;

        if (imp->nb_exports == size)
        {
            size += 128;
            imp->exports = xrealloc( imp->exports, size * sizeof(*imp->exports) );
        }
        imp->exports[imp->nb_exports++] = xstrdup( p );
    }
    if ((err = pclose( f ))) fatal_error( "%s error %d\n", cmdline, err );
    free( cmdline );
    sort_symbols( imp->exports, imp->nb_exports );
}
Example #4
0
static void	my_nm(const char *file, int display_file)
{
  t_dumper	d;
  int		i;
  Elf64_Sym	*sym;

  if (load_dumper(&d, file) != RET_SUCCESS)
    return ;
  if (display_file)
    printf("%s:\n", file);
  sort_symbols(&d);
  i = 1;
  while ((sym = dumper_get_sym_by_index(&d, i)))
    {
      display_symbol(&d, sym);
      i++;
    }
  dumper_dtor(&d);
}
Example #5
0
symbol_table_t* load_symtable(Elf32_File* file)
{
	int i,j;
	int nb_func = 0;
	char* string;
	symbol_table_t* table;
	
	if(file == NULL || file->sym_table == NULL)
		return NULL;
	
	table = kmalloc(sizeof(symbol_table_t));
	
	/* Compte le nombre de symboles de fonctions, optimisé en espace précompilation*/
	for(i=0; i<file->nb_symbols; nb_func+=(ELF32_ST_TYPE(file->sym_table[i++].st_info) == STT_FUNC));
	
	table->count = nb_func;
	
	/* Allocation de la table des symboles dans le kernel */
	table->symbols = kmalloc(nb_func * sizeof(symbol_t));
	
	/* On ne récupère que les symboles de fonction, osef du reste pour le moment
	 * Sinon, on pourrait ajouter un champ à symbol_t pour identifier le type de symbol */
	for(i=0,j=0; i<file->nb_symbols; i++)
	{
		/* Si le symbole est une fonction... */
		if(ELF32_ST_TYPE(file->sym_table[i].st_info) == STT_FUNC)
		{
			string = file->symbol_string_table + file->sym_table[i].st_name;
			
			table->symbols[j].name = strdup(string);
			table->symbols[j].addr = file->sym_table[i].st_value;
			
			j++;
		}
	}
	//print_symbols(table);
	sort_symbols(table);
	return table;
}