From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Cc: xavier.leroy@inria.fr
Subject: Re: [Caml-list] Dynlink problems
Date: Thu, 31 Jul 2003 18:31:55 +0100 [thread overview]
Message-ID: <20030731173155.GA20099@redhat.com> (raw)
In-Reply-To: <20030729162843.GB32764@redhat.com>
The following patch to OCaml fixes this bug in Dynlink. It allows you
to specify an alternate executable name, and also improves debugging
by printing a useful message if the system tries to use
Sys.executable_name when it is empty.
Rich.
----------------------------------------------------------------------
diff -ur ocaml-3.06.orig/bytecomp/symtable.ml ocaml-3.06/bytecomp/symtable.ml
--- ocaml-3.06.orig/bytecomp/symtable.ml 2002-02-11 14:08:43.000000000 +0000
+++ ocaml-3.06/bytecomp/symtable.ml 2003-07-31 18:16:48.000000000 +0100
@@ -243,10 +243,10 @@
(* Initialize the linker for toplevel use *)
-let init_toplevel () =
+let init_toplevel_from_executable filename =
(* Read back the known global symbols and the known primitives
from the executable file *)
- let ic = open_in_bin Sys.executable_name in
+ let ic = open_in_bin filename in
begin try
Bytesections.read_toc ic;
ignore(Bytesections.seek_section ic "SYMB");
@@ -267,6 +267,11 @@
(* Initialize the Dll machinery for toplevel use *)
Dll.init_toplevel dllpath
+let init_toplevel () =
+ if Sys.executable_name = "" then
+ fatal_error "Sys.executable_name is \"\"";
+ init_toplevel_from_executable Sys.executable_name
+
(* Find the value of a global identifier *)
let get_global_position id = slot_for_getglobal id
diff -ur ocaml-3.06.orig/bytecomp/symtable.mli ocaml-3.06/bytecomp/symtable.mli
--- ocaml-3.06.orig/bytecomp/symtable.mli 2000-03-06 22:11:11.000000000 +0000
+++ ocaml-3.06/bytecomp/symtable.mli 2003-07-31 18:15:22.000000000 +0100
@@ -29,6 +29,7 @@
(* Functions for the toplevel *)
val init_toplevel: unit -> unit
+val init_toplevel_from_executable: string -> unit
val update_global_table: unit -> unit
val get_global_value: Ident.t -> Obj.t
val assign_global_value: Ident.t -> Obj.t -> unit
diff -ur ocaml-3.06.orig/otherlibs/dynlink/dynlink.ml ocaml-3.06/otherlibs/dynlink/dynlink.ml
--- ocaml-3.06.orig/otherlibs/dynlink/dynlink.ml 2002-04-24 08:57:17.000000000 +0100
+++ ocaml-3.06/otherlibs/dynlink/dynlink.ml 2003-07-31 18:17:18.000000000 +0100
@@ -39,6 +39,9 @@
let init () =
Symtable.init_toplevel()
+let init_from_executable =
+ Symtable.init_toplevel_from_executable
+
(* Check that the object file being loaded has been compiled against
the same interfaces as the program itself. In addition, check that
only authorized compilation units are referenced. *)
diff -ur ocaml-3.06.orig/otherlibs/dynlink/dynlink.mli ocaml-3.06/otherlibs/dynlink/dynlink.mli
--- ocaml-3.06.orig/otherlibs/dynlink/dynlink.mli 2001-12-28 23:21:49.000000000 +0000
+++ ocaml-3.06/otherlibs/dynlink/dynlink.mli 2003-07-31 18:18:59.000000000 +0100
@@ -18,6 +18,12 @@
val init : unit -> unit
(** Initialize the library. Must be called before [loadfile]. *)
+val init_from_executable : string -> unit
+(** Initialize the library. Must be called before [loadfile].
+ This version takes the bytecode executable filename as an argument,
+ rather than using Sys.executable_name which will not be defined in
+ all cases (eg. if the main program is a C program or shared library). *)
+
val loadfile : string -> unit
(** Load the given bytecode object file and link it.
All toplevel expressions in the loaded compilation unit
----------------------------------------------------------------------
--
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
NET::FTPSERVER is a full-featured, secure, configurable, database-backed
FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2003-07-31 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-28 9:49 Richard Jones
2003-07-28 10:07 ` Jacques Garrigue
2003-07-28 10:22 ` Nicolas Cannasse
2003-07-28 17:41 ` Richard Jones
2003-07-29 8:48 ` Jacques Garrigue
2003-07-29 15:43 ` Richard Jones
2003-07-29 16:28 ` Richard Jones
2003-07-31 17:31 ` Richard Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030731173155.GA20099@redhat.com \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
--cc=xavier.leroy@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox