summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTom Kelly <ctk21@cl.cam.ac.uk>2021-03-04 14:24:49 +0000
committerTom Kelly <ctk21@cl.cam.ac.uk>2021-03-04 14:24:49 +0000
commit7011fd87c4576c86f6ba29f4c0b6f4e7d725e7a3 (patch)
tree27cb26e48243360e650fb3843f0deea47ebeba27 /tools
parentea29a366ebabe83220eee6192509430ce5391014 (diff)
parent01c6a5ebe38b680a0b104aa4075ff790f311ea01 (diff)
downloadocaml-7011fd87c4576c86f6ba29f4c0b6f4e7d725e7a3.tar.gz
Merge commit '01c6a5ebe38b680a0b104aa4075ff790f311ea01' into parallel_minor_gc_4_12
Diffstat (limited to 'tools')
-rw-r--r--tools/.depend8
-rw-r--r--tools/Makefile18
-rwxr-xr-xtools/ci/inria/main4
-rw-r--r--tools/objinfo.ml25
-rw-r--r--tools/objinfo_helper.c148
5 files changed, 11 insertions, 192 deletions
diff --git a/tools/.depend b/tools/.depend
index 2c96493b76..5aeba6d7c4 100644
--- a/tools/.depend
+++ b/tools/.depend
@@ -92,14 +92,14 @@ objinfo.cmo : \
../middle_end/linkage_name.cmi \
../typing/ident.cmi \
../middle_end/flambda/export_info.cmi \
- ../utils/config.cmi \
../middle_end/compilation_unit.cmi \
../file_formats/cmxs_format.cmi \
../file_formats/cmx_format.cmi \
../file_formats/cmt_format.cmi \
../file_formats/cmo_format.cmi \
../file_formats/cmi_format.cmi \
- ../bytecomp/bytesections.cmi
+ ../bytecomp/bytesections.cmi \
+ ../utils/binutils.cmi
objinfo.cmx : \
../bytecomp/symtable.cmx \
../middle_end/symbol.cmx \
@@ -108,14 +108,14 @@ objinfo.cmx : \
../middle_end/linkage_name.cmx \
../typing/ident.cmx \
../middle_end/flambda/export_info.cmx \
- ../utils/config.cmx \
../middle_end/compilation_unit.cmx \
../file_formats/cmxs_format.cmi \
../file_formats/cmx_format.cmi \
../file_formats/cmt_format.cmx \
../file_formats/cmo_format.cmi \
../file_formats/cmi_format.cmx \
- ../bytecomp/bytesections.cmx
+ ../bytecomp/bytesections.cmx \
+ ../utils/binutils.cmx
ocamlcmt.cmo : \
../typing/untypeast.cmi \
../typing/stypes.cmi \
diff --git a/tools/Makefile b/tools/Makefile
index 931ec3eeeb..aa54e5b275 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -267,23 +267,12 @@ ifeq "$(SYSTEM)" "cygwin"
DEF_SYMBOL_PREFIX = '-Dsymbol_prefix="_"'
endif
-objinfo_helper$(EXE): objinfo_helper.$(O)
- $(CC) $(BFD_LDFLAGS) $(OC_CFLAGS) $(OUTPUTEXE)$@ $< $(BFD_LDLIBS)
-
-objinfo_helper.$(O): $(ROOTDIR)/runtime/caml/s.h
-
-objinfo_helper.$(O): \
- OC_CPPFLAGS += -I$(ROOTDIR)/runtime $(DEF_SYMBOL_PREFIX) $(BFD_CPPFLAGS)
-
OBJINFO=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \
$(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \
$(ROOTDIR)/compilerlibs/ocamlmiddleend.cma \
objinfo.cmo
-$(call byte_and_opt,ocamlobjinfo,$(OBJINFO),objinfo_helper$(EXE))
-
-install::
- $(INSTALL_PROG) objinfo_helper$(EXE) "$(INSTALL_LIBDIR)"
+$(call byte_and_opt,ocamlobjinfo,$(OBJINFO),)
primreq=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \
$(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \
@@ -305,11 +294,6 @@ clean::
rm -f -- lintapidiff.opt lintapidiff.opt.exe
rm -f lintapidiff.cm? lintapidiff.o lintapidiff.obj
-
-clean::
- rm -f "objinfo_helper" "objinfo_helper.manifest"
- rm -f "objinfo_helper.exe" "objinfo_helper.exe.manifest"
-
# Eventlog metadata file
install::
diff --git a/tools/ci/inria/main b/tools/ci/inria/main
index 9d6c9182d5..ebed3e694b 100755
--- a/tools/ci/inria/main
+++ b/tools/ci/inria/main
@@ -112,8 +112,6 @@ case $NODE_NAME in
ocaml-ppc-64)
CCOMP="CC='gcc -m64'"
OCAML_CONFIGURE_OPTIONS=;;
- ocaml-freebsd-64|ocaml-openbsd-64)
- OCAML_CONFIGURE_OPTIONS='--with-bfd'
esac
#########################################################################
@@ -139,7 +137,7 @@ case "${OCAML_ARCH}" in
make=gmake
;;
macos)
- confoptions="$confoptions --with-bfd "
+ # Nothing special but we must not fall through the "arch_error" case
;;
linux)
check_make_alldepend=true
diff --git a/tools/objinfo.ml b/tools/objinfo.ml
index 4854ca1c74..63b1a77e90 100644
--- a/tools/objinfo.ml
+++ b/tools/objinfo.ml
@@ -244,26 +244,11 @@ let dump_byte ic =
toc
let find_dyn_offset filename =
- let helper_name = "objinfo_helper" ^ Config.ext_exe in
- let helper = Filename.concat Config.standard_library helper_name in
- let tempfile = Filename.temp_file "objinfo" ".out" in
- match
- Fun.protect
- ~finally:(fun () -> remove_file tempfile)
- (fun () ->
- let rc =
- Sys.command
- (Filename.quote_command helper ~stdout:tempfile [filename])
- in
- if rc <> 0 then failwith "cannot read";
- let tc = Scanf.Scanning.from_file tempfile in
- Fun.protect
- ~finally:(fun () -> Scanf.Scanning.close_in tc)
- (fun () ->
- Scanf.bscanf tc "%Ld" (fun x -> x)))
- with
- | offset -> Some offset
- | exception (Failure _ | Sys_error _) -> None
+ match Binutils.read filename with
+ | Ok t ->
+ Binutils.symbol_offset t "caml_plugin_header"
+ | Error _ ->
+ None
let exit_err msg = print_endline msg; exit 2
let exit_errf fmt = Printf.ksprintf exit_err fmt
diff --git a/tools/objinfo_helper.c b/tools/objinfo_helper.c
deleted file mode 100644
index 9eb8087beb..0000000000
--- a/tools/objinfo_helper.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/**************************************************************************/
-/* */
-/* OCaml */
-/* */
-/* Mehdi Dogguy, PPS laboratory, University Paris Diderot */
-/* */
-/* Copyright 2010 Mehdi Dogguy */
-/* */
-/* All rights reserved. This file is distributed under the terms of */
-/* the GNU Lesser General Public License version 2.1, with the */
-/* special exception on linking described in the file LICENSE. */
-/* */
-/**************************************************************************/
-
-#include "caml/s.h"
-#include <stdio.h>
-
-#ifdef HAS_LIBBFD
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-// PACKAGE: protect against binutils change
-// https://sourceware.org/bugzilla/show_bug.cgi?id=14243
-#define PACKAGE "ocamlobjinfo"
-#include <bfd.h>
-#undef PACKAGE
-
-#define plugin_header_sym (symbol_prefix "caml_plugin_header")
-
-/* We need to refer to a few functions of the BFD library that are */
-/* actually defined as macros. We thus define equivalent */
-/* functions below */
-
-long get_static_symtab_upper_bound(bfd *fd)
-{
- return bfd_get_symtab_upper_bound(fd);
-}
-
-long get_dynamic_symtab_upper_bound(bfd *fd)
-{
- return bfd_get_dynamic_symtab_upper_bound(fd);
-}
-
-long canonicalize_static_symtab(bfd * fd, asymbol **symbolTable)
-{
- return bfd_canonicalize_symtab(fd, symbolTable);
-}
-
-long canonicalize_dynamic_symtab(bfd * fd, asymbol **symbolTable)
-{
- return bfd_canonicalize_dynamic_symtab(fd, symbolTable);
-}
-
-typedef struct {
- long (*get_upper_bound)(bfd *);
- long (*canonicalize)(bfd *, asymbol **);
-} symTable_ops;
-
-symTable_ops staticSymTable_ops = {
- &get_static_symtab_upper_bound,
- &canonicalize_static_symtab
-};
-
-symTable_ops dynamicSymTable_ops = {
- &get_dynamic_symtab_upper_bound,
- &canonicalize_dynamic_symtab
-};
-
-/* Print an error message and exit */
-static void error(bfd *fd, char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
- vfprintf (stderr, msg, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- if (fd!=NULL) bfd_close(fd);
- exit(2);
-}
-
-/* Look for plugin_header_sym in the specified symbol table */
-/* Return its address, -1 if not found */
-long lookup(bfd* fd, symTable_ops *ops)
-{
- long st_size;
- asymbol ** symbol_table;
- long sym_count, i;
-
- st_size = ops->get_upper_bound (fd);
- if (st_size <= 0) return -1;
-
- symbol_table = malloc(st_size);
- if (! symbol_table)
- error(fd, "Error: out of memory");
-
- sym_count = ops->canonicalize (fd, symbol_table);
-
- for (i = 0; i < sym_count; i++) {
- if (strcmp(symbol_table[i]->name, plugin_header_sym) == 0)
- return symbol_table[i]->value;
- }
- return -1;
-}
-
-int main(int argc, char ** argv)
-{
- bfd *fd;
- asection *sec;
- file_ptr offset;
- long value;
-
- if (argc != 2)
- error(NULL, "Usage: %s <dynamic library>", argv[0]);
-
- fd = bfd_openr(argv[1], "default");
- if (!fd)
- error(NULL, "Error opening file %s", argv[1]);
- if (! bfd_check_format (fd, bfd_object))
- error(fd, "Error: wrong format");
-
- sec = bfd_get_section_by_name(fd, ".data");
- if (! sec)
- error(fd, "Error: section .data not found");
-
- offset = sec->filepos;
-
- value = lookup(fd, &dynamicSymTable_ops);
-
- if (value == -1)
- value = lookup(fd, &staticSymTable_ops);
- bfd_close(fd);
-
- if (value == -1)
- error(NULL, "Error: missing symbol %s", plugin_header_sym);
-
- printf("%ld\n", (long) offset + value);
-}
-
-#else
-
-int main(int argc, char ** argv)
-{
- fprintf(stderr,"BFD library unavailable, cannot print info on .cmxs files\n");
- return 2;
-}
-
-#endif