Hi,

I am working on porting J (see jsoftware.com) to openbsd.

I have run into a problem with the interpreter's mechanism for calling
routines in dynamically linked shared libraries.

J uses a hack where doubles are passed as long. This works on other
OSes but not on openbsd.

The line of code in question looks like this, after macro expansion:
https://gist.github.com/rdm/52d851f5f1cf15641950

The problem is that when the underlying type is double the argument
values are mutilated between this line of code and the when the
foreign function begins execution.

I think the issue is that d[] in the above code sample is an array of
long, and the foreign function is looking for a double. So I am
presuming that something in gcc or openbsd is looking at this and is
changing things.

For example, the value 0x9999999a (floating point 2.7) when passed to
a function which accepts a single double argument shows up with the
value 0 when the function begins execution.

I was under the impression that gcc passes all values on the stack,
not in floating point registers or anything like that?

When I try single stepping through the call using gdb, I run into a
fair number of messages that say:

"No function contains program counter for selected frame."

I also wind up spending a fair amount of time in ld.so -- maybe I'll
be able to find my way through all the detail, but mostly I'm just as
lost using gdb as with any other approach.

Basically, though, I don't know what I am looking for, so I don't know
how to tell when I am getting close to it.

Does anyone know how I should approach this issue? (Is there anything
specific to OpenBSD which should be relevant here, or should I
strictly focus on gcc issues?)

Thanks,

-- 
Raul

Reply via email to