From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6232881792 for ; Mon, 17 Jun 2013 14:34:06 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of philippe.wang.lists@gmail.com) identity=pra; client-ip=74.125.82.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="philippe.wang.lists@gmail.com"; x-sender="philippe.wang.lists@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of philippe.wang.lists@gmail.com designates 74.125.82.42 as permitted sender) identity=mailfrom; client-ip=74.125.82.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="philippe.wang.lists@gmail.com"; x-sender="philippe.wang.lists@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f42.google.com) identity=helo; client-ip=74.125.82.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="philippe.wang.lists@gmail.com"; x-sender="postmaster@mail-wg0-f42.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AloBAMkBv1FKfVIqjWdsb2JhbABagzpJgjgBRrtodAgWDgEBAQEHCwsJEgYkgiMBAQUjHQE4AQMMAQUFCw0CAiYCAiEBEgEFARwGE4d8Aw+bOot8g06EOScNiEwBBQyBGos+gTF/gwaBFAOOQ4cXgWeMH4M/FimBXYJZO4E1 X-IPAS-Result: AloBAMkBv1FKfVIqjWdsb2JhbABagzpJgjgBRrtodAgWDgEBAQEHCwsJEgYkgiMBAQUjHQE4AQMMAQUFCw0CAiYCAiEBEgEFARwGE4d8Aw+bOot8g06EOScNiEwBBQyBGos+gTF/gwaBFAOOQ4cXgWeMH4M/FimBXYJZO4E1 X-IronPort-AV: E=Sophos;i="4.87,880,1363129200"; d="scan'208";a="18037370" Received: from mail-wg0-f42.google.com ([74.125.82.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Jun 2013 14:34:05 +0200 Received: by mail-wg0-f42.google.com with SMTP id z11so178603wgg.3 for ; Mon, 17 Jun 2013 05:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=mUu70roTpnJ4wSv7gpuPxYDhrm1OU7ISNNuh4Zx7XS0=; b=s9ujgpx5rrel5EsdnBbbVmzqrLTNgvPMv+mFwT+nJi0KiH3E8xFhDjMqbOTz31v/i7 T68Bg58nJu4PeM1KUxliC+OKQ8ZEVdKZwH+uy8svMMFYKcEVZJE9FF3vuGcqPvlLlBQW /xG3iPAVd22WbzheD+Z4c9Ji53RpZejhQTezjWvFx/jWq1WBM5DOI6LuRjyheJruWAiz fS04L0h3plpdrdLMXdE9z7TMIGeV7PXCe8rnrRmOWvzS5cb/KhqMIF5gmUvTa3HA5qbx tszmb/bCdoFSb6gXdmVTcwGA50/tuMGxUoaCpxk2Ywo5bT+53nCtwwibZBiWKsl6P8+G GWUQ== MIME-Version: 1.0 X-Received: by 10.180.182.228 with SMTP id eh4mr4760221wic.42.1371472445339; Mon, 17 Jun 2013 05:34:05 -0700 (PDT) Sender: philippe.wang.lists@gmail.com Received: by 10.216.13.74 with HTTP; Mon, 17 Jun 2013 05:34:05 -0700 (PDT) In-Reply-To: References: Date: Mon, 17 Jun 2013 13:34:05 +0100 X-Google-Sender-Auth: 76kqhOfssb6L-8mOvisMsWFOXIA Message-ID: From: Philippe Wang To: =?ISO-8859-9?Q?=D6mer_Sinan_A=F0acan?= Cc: Dawid Toton , OCaml Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Re: OCaml binary formats -- how are they linked? On Mon, Jun 17, 2013 at 1:12 PM, =C3=96mer Sinan A=C4=9Facan wrote: >> $ echo 'print_endline "hello";;' > p.ml >> $ ocamlc p.ml -o p >> $ ( head -n 1 p ; cat p.ml p ) > q >> $ chmod a+x q >> $ ./q >> hello >> >> Oh, a binary that contains its source code! :-) > > Thanks, this is very interesting. As far as I understand, OCamlrun > looks for a magic number in source file to start interpreting, right? ocamlrun checks the magic number and a few other properties as well. For instance, if it can read the bytecode for some reason, it'll raise an error. If you're interested in how it's implemented, you might want to look into ocaml-4.00.1/byterun/fix_code.c. -- Philippe Wang mail@philippewang.info