severity 338148 important
tags 338437 patch
thanks
On Wed, Dec 07, 2005 at 10:51:48PM -0500, Mike Furr wrote:
> Steve Langasek wrote:
> > Rather, the segfault happens in camlPrintf__entry, which is called
> > from caml_startup__code_begin. I can't find a definition for
> > camlPrintf__entry anywhere, and I do in fact see some
> > suspicious-looking differences when disassembling this code. Can you
> > tell me where in the ocaml source I can find this definition, and/or
> > how I can get ocaml to spit out for me the corresponding asm?
> ocamlopt has a -S option, similar to gcc. To generate the assembly file
> for printf do,
> ocaml-3.09.0$ cd stdlib
> stdlib$ ocamlopt -c -S printf.ml
> stdlib$ $EDITOR printf.s
> The __entry symbols are the static initializers for OCaml modules, they
> are executed very early and only once. Also, note that not all
> invocations of camlPrintf__entry cause the segfault. The tiny program:
> let _ = Printf.printf "hello\n"
> does not segfault, even though gdb steps through the same line in
> camlPrintf__entry (with different data obviously). However my utter
> lack of knowledge for alpha assembly and linking internals is
> restricting any further investigation. If you need another binary which
> does segfault, you can grab the program: escher:~mfurr/felix-1.1.1/bin/flxg
Ok, here's a bit more information. Sorry for not posting to the bug
earlier.
The change in binutils that breaks ocaml on alpha is the addition of new plt
relaxation code, added on 20050529 to the binutils CVS trunk. This code
causes ld to elide certain instructions used to set up the gp before calling
functions that it believes don't use the gp. AFAICT (which isn't very far),
the assumption made by binutils here is valid, and it falls down because
ocaml itself is emitting invalid ".prologue 0" commands for certain
functions such as caml_apply2 which do touch $gp, where ".prologue 0"
apparently means that the function doesn't touch $gp at all.
There is also a new option added to ld in this patch, --no-relax, which
tells ld not to take this shortcut with gp handling. If I rebuild felix
with ocamlopt.opt -cclib -Wl,--no-relax, it runs successfully on alpha.
This suggests that adding -Wl,--no-relax to bytecclinkopts and
nativecclinkopts on alpha is a viable workaround. It also lends support, I
think, to the idea that this is an ocaml bug rather than a binutils bug.
A full fix so that ocaml emits .prologue 2 instead of .prologue 0 when
needed is beyond me since I don't speak ocaml, but attached is a patch which
adds --no-relax to the arguments passed to ld, which gets things going -- at
the very least, felix passes its build-time tests when built with this
option.
Since the problem has to do with startup code linked into all ocaml binaries
at build time, we'll probably need a list of ocaml application packages
built against this version of binutils for binNMUing on alpha.
Leaving the bug against binutils open for the moment, so the maintainer can
make a final decision on whether there's a bug here; but downgrading so it
no longer holds up testing.
Thanks,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
[EMAIL PROTECTED] http://www.debian.org/
--- ocaml-3.09.0.orig/configure 2005-09-24 02:19:09.0 -0700
+++ ocaml-3.09.0/configure 2005-12-07 22:03:36.019001353 -0800
@@ -268,7 +268,8 @@
gcc,alpha*-*-linux*)
if cc="$bytecc" sh ./hasgot -mieee; then
bytecccompopts="-mieee $bytecccompopts";
-fi;;
+fi
+bytecclinkopts="-Wl,--no-relax";;
cc,mips-*-irix6*)
# Add -n32 flag to ensure compatibility with native-code compiler
bytecccompopts="-n32"
@@ -612,6 +613,7 @@
nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
*,*,rhapsody,*)
nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs";;
+ alpha,gcc*,linux*,*) nativecclinkopts="-Wl,--no-relax";;
*,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
*,gcc*,*,*) nativecccompopts="$gcc_warnings";;
esac
signature.asc
Description: Digital signature