Aieee! Need help with gmodule!



My apologies in advance that this is not a general-purpose GNOME question.

I am trying to use gmodule in a project (www.dents.org for more info).
I am compiling some shared objects which I hope to link into my system.

When I run my test g_module program on one of my shared object files,
I get the following error:

% gmodule_test modules/constant_module.so
** ERROR **: modules/constant_module.so: ELF file's phentsize not the
	expected size
aborting...
%

Since I can find no docs on gmodule, I have no idea if I am doing anything
at all right.  Would whoever in this crowd is knowledgeable concerning
gmodule mind looking this over and offering me what advice they can?

I compile my objects this way:

	gcc -shared  -fpic -DPIC -c \
		`/opt/gnome/bin/glib-config --cflags` -I.. \
		$file -o ${file%.c}.so

Here is the output of nm on such an object:

         U _GLOBAL_OFFSET_TABLE_
         U _IO_stderr_
00000044 T dents_module_add_zone
0000014c T dents_module_answer
00000114 T dents_module_destroy
000000cc T dents_module_drop_zone
00000000 T dents_module_init
00000000 D dents_module_name
00000084 T dents_module_reload_zone
         U fprintf
00000000 t gcc2_compiled.

and here's my loader program:

START
#include <glib.h> /* gmodule */
#include <gmodule.h> /* gmodule */
#include <sys/stat.h> /* stat */
#include <unistd.h> /* stat */
#include <stdio.h> /* printf */
#include "dents_module.h" /* struct dents_resolver_module */

int main(int argc, char *argv[])
{
	/* We just want to load up a module and
	call its answer routine. */

	char *module_file_name;
	struct dents_resolver_module my_mod;
	GModule *module = NULL;
	int (*my_func)();
	unsigned int result;

	if(argc!=2){
		fprintf(stderr, "%u is not 2!  Need one argument.\n", argc);
		exit(-1);
	}

	module_file_name=argv[1];

	fprintf(stderr, "module file name is %s.\n", module_file_name);
	if(g_module_supported()){
		module = g_module_open (module_file_name, G_MODULE_BIND_LAZY);
		if(!module){
			fprintf(stderr, "Aiee, module == NULL!\n");
			g_error(g_module_error());
		}
	}

	if (module && g_module_symbol (module, "dents_module_init", my_func)) {
		result=my_func();
		fprintf(stderr, "module init returned %u.\n", result);
		g_module_make_resident (module);
	}

	if (!my_func){
		g_warning ("Failed to load module \"%s\": %s",
			module ? module_file_name : module_file_name,
			g_module_error ());
		if (module) {
			g_module_close (module);
		}
	}
}
END

-- 
Todd Graham Lewis       tlewis@mindspring.net      (800) 719-4664, x2804

"It's still ludicrous that nobody's ever made a run at us by making UNIX
 a popular platform on PCs.  It's almost too late now."  -- Steve Balmer
"It is too late."   -- Bill Gates             _Newsweek_, 6/23/97, p. 82



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]