HPUX PIC and Oracle division broke?

From: Ken Busby <ken_at_isscorp.com>
Date: 10 Dec 1993 15:38:05 -0500
Message-ID: <2eamnd$k6p_at_isss10.isscorp.com>

I have recently converted to using shared libraries where possible. Under HP-UX 9.0, I recompiled all my code PIC (+Z/+z) and everything appears to work, except the following section of code. I have isolated this problem from a large system. The problem is in the division. Watching xdb in disassembly mode, when $divI is called, the stack appears corrupt (if I ask for a procedure trace, it shows $divI for hundreds of levels) and I never get back. The process is taking all the CPU it can get.

int main(int argc, char *argv[])

{	int i, j, k;
	i = 72;
	printf("Dividing: %u / %u...\n", 1, i);
	j = 1 / i;           /** THIS STATEMENT NEVER RETURNS.  **/


There are 3 scenarios:
1. Compiled normally without +Z/+z, there is no error.

2. Compiled PIC, linked with this ld command, there is no error.

	ld  /lib/crt0.o -o kbtest kbtest.o \
		-ldld /lib/libm.a /lib/libc.a /usr/lib/end.o 

3. Compiled PIC, linked with this ld command, it never returns from $divI.
	ld /lib/crt0.o -o oracle/kbtest kbtest.o     \
    		/ora7/product/7.0.12/lib/libocic.a   \

/ora7/product/7.0.12/lib/libsql.a \
/ora7/product/7.0.12/lib/osntab.o \
/ora7/product/7.0.12/lib/libora.a \
/ora7/product/7.0.12/lib/libtcp.a \
/ora7/product/7.0.12/lib/libsqlnet.a \
/ora7/product/7.0.12/lib/libora.a \
/ora7/product/7.0.12/lib/libcore.a \
-ldld /lib/libm.a /lib/libc.a /usr/lib/end.o

The only difference is the Oracle 7 libraries that are included. Although not needed here, in the real system they are. I used ld -v to see what was being included when and it appears the $divI comes from the normal /lib/milli.a.

I guess the questions are:

  1. Is it really this deadly to compile non-shared library modules PIC and what is it about including the Oracle libs that uncovers the problem? I do not want to have to distinquish while compiling between shared lib and non-shared lib modules.
  2. Is this a compiler/ld bug, a problem with combining non-PIC & PIC code, or something else?
  3. Why does scenario 2 not give problems?
  4. Is there something about the Oracle libs that is confusing ld and causing it to screw up code?

Thanks for any insights.

ken_at_isscorp.com Received on Fri Dec 10 1993 - 21:38:05 CET

Original text of this message