X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=generator%2Fgenerator.ml;h=e1e957a01f6c2727897ec60b0785f07df3055442;hb=refs%2Ftags%2F1.2.2;hp=d7b98752aee3db98143c330e940799617f033d80;hpb=0b960523cfccd4614dd644fa3c67d59bc02dc9bb;p=hivex.git diff --git a/generator/generator.ml b/generator/generator.ml index d7b9875..e1e957a 100755 --- a/generator/generator.ml +++ b/generator/generator.ml @@ -1321,6 +1321,32 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. " +(* Generate the linker script which controls the visibility of + * symbols in the public ABI and ensures no other symbols get + * exported accidentally. + *) +and generate_linker_script () = + generate_header HashStyle GPLv2plus; + + let globals = [ + "hivex_visit"; + "hivex_visit_node" + ] in + + let functions = + List.map (fun (name, _, _, _) -> "hivex_" ^ name) + functions in + let globals = List.sort compare (globals @ functions) in + + pr "{\n"; + pr " global:\n"; + List.iter (pr " %s;\n") globals; + pr "\n"; + + pr " local:\n"; + pr " *;\n"; + pr "};\n" + and generate_ocaml_interface () = generate_header OCamlStyle LGPLv2plus; @@ -2415,7 +2441,7 @@ DESTROY (h) pr " size_t len;\n"; pr " hive_type type;\n"; pr " PPCODE:\n"; - pr " r = hivex_%s (%s, &len, &type);\n" + pr " r = hivex_%s (%s, &type, &len);\n" name (String.concat ", " c_params); free_args (); pr " if (r == -1)\n"; @@ -2431,7 +2457,7 @@ DESTROY (h) pr " size_t len;\n"; pr " hive_type type;\n"; pr " PPCODE:\n"; - pr " r = hivex_%s (%s, &len, &type);\n" + pr " r = hivex_%s (%s, &type, &len);\n" name (String.concat ", " c_params); free_args (); pr " if (r == NULL)\n"; @@ -2439,7 +2465,7 @@ DESTROY (h) name; pr " EXTEND (SP, 2);\n"; pr " PUSHs (sv_2mortal (newSViv (type)));\n"; - pr " PUSHs (sv_2mortal (newSVpv (r, len)));\n"; + pr " PUSHs (sv_2mortal (newSVpvn (r, len)));\n"; pr " free (r);\n"; | RInt64 -> @@ -2522,6 +2548,8 @@ Run it from the top source directory using the command output_to "lib/hivex.h" generate_c_header; output_to "lib/hivex.pod" generate_c_pod; + output_to "lib/hivex.syms" generate_linker_script; + output_to "ocaml/hivex.mli" generate_ocaml_interface; output_to "ocaml/hivex.ml" generate_ocaml_implementation; output_to "ocaml/hivex_c.c" generate_ocaml_c;