From alf@hpbidrd.bbn.hp.com  Fri Apr  4 13:30:35 1997
Return-Path: alf@hpbidrd.bbn.hp.com
Received: from spider.hro.nl (spider.hro.nl [145.24.9.9]) by ronix.ptf.hro.nl (8.8.5/8.6.7) with ESMTP id NAA17412 for <staveren@ronix.ptf.hro.nl>; Fri, 4 Apr 1997 13:29:50 GMT
Received: from hplb.hpl.hp.com (hplb.hpl.hp.com)
 by SPIDER.HRO.NL (PMDF V5.0-3 #6017) id <01IHB5586IKG008U6Z@SPIDER.HRO.NL> for
 staveren@ronix.ptf.hro.nl; Fri, 04 Apr 1997 13:29:50 +0100 (MET)
Received: from bidro64.bbn.hp.com by hplb.hpl.hp.com; Fri,
 04 Apr 1997 12:29:42 +0100
Received: by bidro64.bbn.hp.com (1.37.109.16/15.5+ECS 3.3) id AA262083433; Fri,
 04 Apr 1997 13:30:33 +0200
Date: Fri, 04 Apr 1997 13:30:32 +0000
From: Alf Clement <alf@hpbidrd.bbn.hp.com>
Subject: Re: shl_load()
In-reply-to: Ruben van Staveren <staveren@ronix.ptf.hro.nl>
 <"Re: explorer 0.65 release"@SPIDER.hro.nl> (Apr 3, 9:50pm)
To: Ruben van Staveren <staveren>
Message-id: <9704041330.ZM26206@bidro64.bbn.hp.com>
MIME-version: 1.0
X-Mailer: Z-Mail (3.2.1 10oct95)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
X-Recyclenotice: This message was prepared using 100% recycled electrons
References: <199704032250.WAA04370@ronix.ptf.hro.nl>
Status: RO

Hello Ruben,

here is a simple program, which load the shared lib...

#include <dl.h>

main()
{
 shl_t handle;
 int i,k;
 void (*addr)();
 int *pi;

 handle = shl_load("tsh.sl", BIND_IMMEDIATE|BIND_VERBOSE, 0);
 if(!handle)
 {
    puts("handle is zero"); exit(1);
 }

 /* find tsh_int */
  k = shl_findsym(&handle, "tsh_int", TYPE_DATA,  &addr);
  if(!k)
  {
     pi = (int *)addr;
     *pi = 4;
  }
  else
    printf("tsh_int not found\n");

 /* find main entry */
 k = shl_findsym(&handle, "tsh_main", TYPE_UNDEFINED,  &addr);

 printf("\ngot %d %x\n",k,addr);
 if(addr)
   addr();

}


and tsh.c::
int tsh_int=2;

tsh_main()
{
  tsh_int = 1;

  printf("this is tsh_main(%d)\n",tsh_int);
}


So I don't see any problems here, except for the different calls.

Alf

-- 
Alf Clement
Hewlett Packard GmbH                  eMail : alf@bbn.hp.com
Boeblingen Instruments Division       
Herrenberger Str. 130 - Werk 2        Phone : +49 (7031) 14-2302
71043 Boeblingen - Germany	      Fax   : +49 (7031) 14-7023

