~ubuntu-branches/ubuntu/vivid/gcl/vivid

« back to all changes in this revision

Viewing changes to o/fasldlsym.c.link

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-03-04 14:29:59 UTC
  • Revision ID: james.westby@ubuntu.com-20020304142959-dey14w08kr7lldu3
Tags: upstream-2.5.0.cvs20020219
ImportĀ upstreamĀ versionĀ 2.5.0.cvs20020219

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 Copyright (C) 1994 M. Hagiya, W. Schelter, T. Yuasa
 
3
 
 
4
This file is part of GNU Common Lisp, herein referred to as GCL
 
5
 
 
6
GCL is free software; you can redistribute it and/or modify it under
 
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
 
8
the Free Software Foundation; either version 2, or (at your option)
 
9
any later version.
 
10
 
 
11
GCL is distributed in the hope that it will be useful, but WITHOUT
 
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public 
 
14
License for more details.
 
15
 
 
16
You should have received a copy of the GNU Library General Public License 
 
17
along with GCL; see the file COPYING.  If not, write to the Free Software
 
18
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 
 
20
*/
 
21
 
 
22
 
 
23
#include <dlfcn.h>
 
24
#ifdef HAVE_ELF
 
25
#include <elf.h>
 
26
#endif
 
27
 
 
28
/* cc -DVOL=volatile -G 0 -c foo.c ; ld  -shared foo.o -o jim.o ; cat foo.data >> jim.o */
 
29
int did_a_dynamic_load;
 
30
 
 
31
fasload(faslfile)
 
32
     object faslfile;
 
33
{ void *dlp ;
 
34
  int (*fptr)();
 
35
  char buf[200];
 
36
  static count=0;
 
37
  object memory;
 
38
  object data;
 
39
  char filename[MAXPATHLEN];
 
40
  coerce_to_filename(truename(faslfile), filename);
 
41
  sprintf(buf,"./ufas%dxXXXXXX",count++);
 
42
  /* this is just to allow reloading in the same file twice.
 
43
   */
 
44
  mktemp(buf);
 
45
  link(filename,buf);
 
46
  dlp = dlopen(buf,RTLD_NOW);
 
47
  if (dlp ==0)
 
48
    FEerror("Cant open for dynamic link ~a",1,faslfile);
 
49
  fptr = (int (*)())dlsym(dlp, "init_code");
 
50
  if (fptr == 0)
 
51
    { FEerror("Cant find init_code in ~a",1,make_simple_string(faslfile));}
 
52
  faslfile = open_stream(faslfile, smm_input, Cnil, sKerror);
 
53
  SEEK_TO_END_OFILE(faslfile->sm.sm_fp);
 
54
  data = read_fasl_vector(faslfile);
 
55
  memory = alloc_object(t_cfdata);
 
56
  memory->cfd.cfd_self = NULL;
 
57
  memory->cfd.cfd_start = NULL;
 
58
  memory->cfd.cfd_size = 0;
 
59
  if(symbol_value(sLAload_verboseA)!=Cnil)      
 
60
    printf(" start address (dynamic) 0x%x ",fptr);
 
61
  call_init(0,memory,data,fptr);
 
62
  /* unlink(buf); */
 
63
  did_a_dynamic_load = 1;
 
64
  return memory->cfd.cfd_size;
 
65
}
 
66
 
 
67
  
 
68
  
 
69
 
 
70
  
 
71
  
 
72
 
 
73