public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Dynamic loader and object loader
@ 2007-06-25 14:06 David Miras
  0 siblings, 0 replies; only message in thread
From: David Miras @ 2007-06-25 14:06 UTC (permalink / raw)
  To: ecos-discuss

Hi,

I'm working, on ecos, for web service test (DPWS).

I'd like to use dynamic loader on i386 PC target and ARM target, the readme
says that should be not working (services\loader) on this target.
Is it possible to use objloader for dynamic loader (on i386 PC target and
ARM target) ?

A simple program on linux OS:

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int i;
int exeCall(char c)
{
    i = -1;
    printf("EXE >> Setting  i = -1, stopping the loop\n");    
    return 42;
}
int main(int argc, char **argv)
{
       void (*init)(void *fptr);
       int j = 0;      
       void *hndl = dlopen("./libdyn.so", RTLD_NOW);
       if(hndl == NULL)
       {
             printf("erreur dlopen : %s\n", dlerror());
             exit(-1);
       } 
       init = (void(*)()) dlsym(hndl, "init");
       if (init == NULL)
       {
             printf("erreur dlsym : %s\n", dlerror());
             exit(-1);
       }
       init(exeCall);
       printf("EXE >> Start counting !\n");
    while ( i != -1)
    {
        printf("EXE >> Counting J => %d !\n",j);
        j++;
        sleep(1);
    }   
       dlclose(hndl);
       return EXIT_SUCCESS;
}

With a dynamic library:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int (* switchProc)(char) = NULL;
void *my_thread_process (void * arg)
{
  int i;
  for (i = 0 ; i < 5 ; i++) {
    printf ("DLL >> Thread %s: %d\n", (char*)arg, i);
    sleep(1);
  }
  printf("DLL >> MyThread is Awekening, calling EXE\n");
  switchProc('P'); 
  pthread_exit (0);
}
void init(void * fptr)
{
   pthread_t th1;
   void *ret;
   if (pthread_create (&th1, NULL, my_thread_process, "1") < 0) {
     fprintf (stderr, "pthread_create error for thread 1\n");
     exit (1);
   }
   printf("DLL >> dll init \n");
   switchProc = fptr;    
}

How do I run that test on eCos OS? Is it possible ?
Does anyone have documentation on the dynamic loader or the object loader?

Regards.
------------------------------
David MIRAS 
Sogeti High Tech
email: david.miras@sogeti.com


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-25  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-25 14:06 [ECOS] Dynamic loader and object loader David Miras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).