diff: Runtime support for stack_layouts
Fergus Henderson
fjh at mundook.cs.mu.OZ.AU
Wed Oct 29 02:20:32 AEDT 1997
Zoltan Somogyi <zs at cs.mu.oz.au> writes:
> [Tyson writes:]
> > +#ifdef MR_USE_STACK_LAYOUTS
> > + /*
> > + ** The succip will be set to the address stored in the
> > + ** layout info. For some reason, this is different to
> > + ** the address passed to insert_entry
> > + */
> > + addr = entry_layout_info[0];
> > +#endif /* MR_USE_STACK_LAYOUTS */
>
>The comment is weird. I don't see any setting of succip, and I don't
>see why the two definitions of addr should be different. This latter
>matter must be resolved before we rely on layout tables.
This is (I'll bet) due to the following problem with the DEC Alpha
implementation of shared libraries. This is the same problem that
sometimes breaks Mercury's profiling if you use shared libraries on
a DEC Alpha system.
The problem is that (a) the dynamic linker seems to resolve addresses lazily
and (b) taking the address of a label in a shared library does not
cause the dynamic linker to resolve the address -- at least not if
the program is compiled with gcc. It seems to work OK if the program
is compiled with cc.
The script below demonstrates the bug.
It ought to print out "ok" twice. Instead it prints out "ok"
and then "failed".
#-----------------------------------------------------------------------------#
#!/bin/sh
cat > main.c <<EOF
#include <stdio.h>
extern void foo (void);
void (*f) (void);
int main(void) {
f = foo;
foo();
if (f == foo) {
printf("ok\n");
} else {
printf("failed\n");
exit(1);
}
return 0;
}
EOF
cat > foo.c <<EOF
void foo(void) {}
EOF
LD_LIBRARY_PATH="."
export LD_LIBRARY_PATH
#cc -c main.c foo.c
#ld -shared -o libfoo.so foo.o -lc
#cc main.o -L. -lfoo
#./a.out
#ld -shared -o libfoo.so foo.o -lc
#sleep 1
#./a.out
gcc -c main.c
cc -c foo.c
ld -shared -o libfoo.so foo.o -lc
cc main.o -L. -lfoo
./a.out
sleep 1
ld -shared -o libfoo.so foo.o -lc
./a.out
#-----------------------------------------------------------------------------#
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list