diff options
Diffstat (limited to 'tools/ocaml-objcopy-macosx')
-rwxr-xr-x | tools/ocaml-objcopy-macosx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/ocaml-objcopy-macosx b/tools/ocaml-objcopy-macosx new file mode 100755 index 000000000..31070f54b --- /dev/null +++ b/tools/ocaml-objcopy-macosx @@ -0,0 +1,53 @@ +#!/bin/bash + +######################################################################### +# # +# Objective Caml # +# # +# Damien Doligez, projet Cristal, INRIA Rocquencourt # +# # +# Copyright 2005 Institut National de Recherche en Informatique et # +# en Automatique. All rights reserved. This file is distributed # +# under the terms of the Q Public License version 1.0. # +# # +######################################################################### + +# $Id$ + + +TEMP=/tmp/ocaml-objcopy-$$.o +UNDEF=/tmp/ocaml-objcopy-$$.sym + +usage () { + echo "usage: objcopy {--redefine-sym <old>=<new>} file.o" >&2 + exit 2 +} + +: > "$UNDEF" + +while : ; do + case $# in + 0) break;; + *) case $1 in + --redefine-sym) + case $2 in + *=*) ALIAS="$ALIAS -i${2#*=}:${2%%=*}" + echo ${2%%=*} >>"$UNDEF" + ;; + *) usage;; + esac + shift 2 + ;; + -*) usage;; + *) case $FILE in + "") FILE=$1; shift;; + *) usage;; + esac;; + esac;; + esac +done + +ld -o "$TEMP" -r $ALIAS "$FILE" +ld -o "$FILE" -r -unexported_symbols_list "$UNDEF" "$TEMP" + +rm -f "$TEMP" "$UNDEF" |