diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2010-05-24 14:27:50 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2010-05-24 14:27:50 +0000 |
commit | cd648ee2dd620d950376112033d8113e7a227e3a (patch) | |
tree | 81b9e118eb69da212edd2912642fb548b9726955 /tools/objinfo_stubs.c | |
parent | bcb5a6b669ace6386dd32eee478291a4033206e6 (diff) |
PR#5059: split objinfo into a pure Caml part and a pure C part.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10459 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools/objinfo_stubs.c')
-rw-r--r-- | tools/objinfo_stubs.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/tools/objinfo_stubs.c b/tools/objinfo_stubs.c deleted file mode 100644 index e96466e2e..000000000 --- a/tools/objinfo_stubs.c +++ /dev/null @@ -1,70 +0,0 @@ -/***********************************************************************/ -/* */ -/* Objective Caml */ -/* */ -/* Mehdi Dogguy, PPS laboratory, University Paris Diderot */ -/* */ -/* Copyright 2010 Mehdi Dogguy. Used and distributed as part of */ -/* Objective Caml by permission from the author. This file is */ -/* distributed under the terms of the Q Public License version 1.0. */ -/***********************************************************************/ - -#include "../config/s.h" -#include "../byterun/mlvalues.h" -#include "../byterun/alloc.h" - -#ifdef HAS_LIBBFD -#include <stdlib.h> -#include <string.h> -#include <bfd.h> - -static file_ptr get_cmxs_offset (char *file) -{ - file_ptr result = -1; - bfd *fd; - asection *sec; - file_ptr offset; - long st_size; - asymbol ** symbol_table; - long sym_count, i; - - fd = bfd_openr(file, "default"); - if (!fd) return -1; - - do { - if (! bfd_check_format (fd, bfd_object)) break; - - sec = bfd_get_section_by_name(fd, ".data"); - if (! sec) break; - - offset = sec->filepos; - st_size = bfd_get_dynamic_symtab_upper_bound (fd); - if (st_size <= 0) break; - - symbol_table = malloc(st_size); - if (! symbol_table) break; - - sym_count = bfd_canonicalize_dynamic_symtab (fd, symbol_table); - for (i = 0; i < sym_count; i++) { - if (strcmp(symbol_table[i]->name, "caml_plugin_header") == 0) { - result = offset + symbol_table[i]->value; - break; - } - } - free(symbol_table); - } - while (0); - bfd_close(fd); - return result; -} - -#endif - -CAMLprim value caml_get_cmxs_offset(value file) -{ -#ifdef HAS_LIBBFD - return caml_copy_int64(get_cmxs_offset(String_val(file))); -#else - return caml_copy_int64(-2); -#endif -} |