[comp.sources.d] libc.a error when linking perl3.0 on HP-UX 3.10

swh@hpcupt1.HP.COM (Steve Harrold) (11/10/89)

Re: perl 3.0 linking problem on HP-UX

>>> Whe I try to make perl version 3.0, patch level 1, I get the following
>>> output. I tried this also telling perl to use its onw malloc, it made no
>>> difference. This looks like an error in the hp-ux library.
>>> The system is hp-ux 3.10 running on a HP 9000/825.
>>> 
>>> 	cc   array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o 
>>> eval.o form.o hash.o malloc.o perly.o regcomp.o regexec.o stab.o str.o 
>>> toke.o util.o perl.o -lm -ldbm    -o perl
>>> /bin/ld: Target of conditional branch is out of range
>>>    Reference from:  /lib/libc.a(syscall.o)(0x3c)
>>> /bin/ld: Invalid fixups exist
>>> *** Error code 1

There appears to be a bug in the UX libc.a file (which I'm told is corrected
in the 7.0 release).

The problem revolves around the syscall.o module.  To workaraound the bug,
do the following:

	ar -x /lib/libc.a syscall.o cerror.o

Then redo the link steps of perl by ADDING these two .o files to the command
line.  In this way, the bug in syscall.o will not manifest itself since
the procedurte it wants will be close enough in the resultant address space.

I don't work for the compiler group, I just know someone there who helped
out when I encountered the problem independently.

contrib@iso.estec.nl (contrib (AM Davidson)) (11/10/89)

In article <127@geysir.os.is> eik@os.is (Einar Kjartansson) writes:
>Whe I try to make perl version 3.0, patch level 1, I get the following
>output. I tried this also telling perl to use its onw malloc, it made no
>difference. This looks like an error in the hp-ux library.
>The system is hp-ux 3.10 running on a HP 9000/825.
>
>	cc   array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o 
>eval.o form.o hash.o malloc.o perly.o regcomp.o regexec.o stab.o str.o 
>toke.o util.o perl.o -lm -ldbm    -o perl
>/bin/ld: Target of conditional branch is out of range
>   Reference from:  /lib/libc.a(syscall.o)(0x3c)
>/bin/ld: Invalid fixups exist
>*** Error code 1
>
>Stop.
>-- 
>  Einar Kjartansson                           | eik@os.is

I had the same problem (on an 840) and called the local support centre - they
were very helpful and acknowledged that it is a bug (fixed in HPUX 7.0).
The good news is that there is a work around.

Do the following:

	ar xv /lib/libc.a cerror.o syscall.o

to extract the offending routines. Now patch them in with the rest of the
.o files and link directly, viz:

	ld /lib/crt0.o   array.o cmd.o cons.o consarg.o doarg.o doio.o \
		dolist.o dump.o eval.o form.o hash.o perly.o regcomp.o \
		regexec.o stab.o str.o toke.o util.o perl.o \
		cerror.o syscall.o \
		-lm -ldbm   \
		-lc \
		-o perl

You'll have to do the same trick with the link of taintperl.

Oh BTW, don't use Perl's own malloc - it'll go crazy.

Murray.

--
===============================================================================
| A.M. Davidson   Tel (0)1719-84025    Fax (0)1719-17401    Telex 39098ESTC NL |
| mail  :  ISO Project, ESTEC, PO Box 227, 2200 AG Noordwijk, The Netherlands. |
| e-mail:  ..mcvax!hp4nl!estec!iso!contrib   or contrib@iso.estec.nl           |
===============================================================================

ggordon@agsm.ucla.edu (Glen Gordon) (11/11/89)

From article <127@geysir.os.is>, by eik@os.is (Einar Kjartansson):
> Whe I try to make perl version 3.0, patch level 1, I get the following
> output. I tried this also telling perl to use its onw malloc, it made no
> difference. This looks like an error in the hp-ux library.
> The system is hp-ux 3.10 running on a HP 9000/825.
> 
> 	cc   array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o 
> eval.o form.o hash.o malloc.o perly.o regcomp.o regexec.o stab.o str.o 
> toke.o util.o perl.o -lm -ldbm    -o perl
> /bin/ld: Target of conditional branch is out of range
>    Reference from:  /lib/libc.a(syscall.o)(0x3c)
> /bin/ld: Invalid fixups exist
> *** Error code 1
> 
> Stop.
> -- 
>   Einar Kjartansson                           | eik@os.is
>   Orkustofnun (National Energy Authority)     | eik@geysir.uucp
>   Grensasvegi 9, IS-108 Reykjavik, Iceland    | mcvax!hafro!geysir!eik
>   Phone: 354-1-83600    Fax: 354-1-688896    Home: 354-1-16407
I too had this problem on HP-UX 3.11 until I undef'd SYSCALL in
config.sh and reran the .SH scripts.  After that all went well and all the tests ran perfectly.
I assume that HP's syscall, which is not documented anywhere I know about
is not intended for public consumption.  
-- 
Glen Gordon
UCLA, Anderson Graduate School Of Management

kamat@uceng.UC.EDU (Govind N. Kamat) (11/13/89)

In article <1322@iso.estec.nl> contrib@iso.estec.nl (contrib (AM
Davidson)) writes:

   In article <127@geysir.os.is> eik@os.is (Einar Kjartansson) writes:
   >Whe I try to make perl version 3.0, patch level 1, I get the following
   >output. I tried this also telling perl to use its onw malloc, it made no
   >difference. This looks like an error in the hp-ux library.

   I had the same problem (on an 840) and called the local support
   centre - they were very helpful and acknowledged that it is a bug
   (fixed in HPUX 7.0).  The good news is that there is a work around.

Umm.  The bad news is that syscall on HP-UX seems to be buggy, just
like many other things on it.

     #include <sys/types.h>
     #include <sys/stat.h>
     #include <syscall.h>
     main()
     {
       syscall(SYS_mkdir, "/usr/tmp/tst", 0755);
     }

====> Core Dump on Series 800s.

You may wish to wait until all these problems are fixed.  I just
undef'ed SYSCALL in Perl's config.h.

--
Govind N. Kamat 			College of Engineering
kamat@uceng.UC.EDU			University of Cincinnati
					Cincinnati, OH 45221, USA

tml@hemuli.atk.vtt.fi (Tor Lillqvist) (11/14/89)

In article <1322@iso.estec.nl> contrib@iso.estec.nl (contrib (AM Davidson)) writes:
>Oh BTW, don't use Perl's own malloc - it'll go crazy.

It is possible to use perl's malloc if you patch it.  I don't have
diffs handy, but I remember two changes were necessary on the
hp9000s800: Use the strut field in the overhead union:

#if defined(mips) || defined(sparc) || defined(hp9000s800)
	double  strut;			/* alignment problems */
#endif

and change the test for corrupt pointers to

#ifdef hp9000s800
	if (*((unsigned int*)p) != 0 &&
	    (*((unsigned int*)p) > 0x80000000 ||
	     *((unsigned int*)p) < 0x40000000))
#else

-- 
Tor Lillqvist, VTT/ATK

jand@kuling.UUCP (Jan Dj{rv) (11/14/89)

In article <1989Nov10.174805.24464@agsm.ucla.edu> ggordon@agsm.ucla.edu (Glen Gordon) writes:
:From article <127@geysir.os.is>, by eik@os.is (Einar Kjartansson):
:> Whe I try to make perl version 3.0, patch level 1, I get the following
:> output. I tried this also telling perl to use its onw malloc, it made no
:> difference. This looks like an error in the hp-ux library.
:> The system is hp-ux 3.10 running on a HP 9000/825.
:> 
:> 	cc   array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o 
:> eval.o form.o hash.o malloc.o perly.o regcomp.o regexec.o stab.o str.o 
:> toke.o util.o perl.o -lm -ldbm    -o perl
:> /bin/ld: Target of conditional branch is out of range
:>    Reference from:  /lib/libc.a(syscall.o)(0x3c)
:> /bin/ld: Invalid fixups exist
:> *** Error code 1
:> 
:> Stop.
:> -- 
:>   Einar Kjartansson                           | eik@os.is
:>   Orkustofnun (National Energy Authority)     | eik@geysir.uucp
:>   Grensasvegi 9, IS-108 Reykjavik, Iceland    | mcvax!hafro!geysir!eik
:>   Phone: 354-1-83600    Fax: 354-1-688896    Home: 354-1-16407
:I too had this problem on HP-UX 3.11 until I undef'd SYSCALL in
:config.sh and reran the .SH scripts.  After that all went well and all the tests ran perfectly.
:I assume that HP's syscall, which is not documented anywhere I know about
:is not intended for public consumption.  
:-- 
:Glen Gordon
:UCLA, Anderson Graduate School Of Management

I had exactly the same problem. The reason for this error is that syscall
has a branch to $cerror at the specified location (0x3c) and I guess that
the branch is too long (bytewise) for the assembler. (NOTE I'm only guessing
since I don't understand HPPA).

The fix we made was to extract syscall.o and cerror.o from /lib/libc.a
(ar x /lib/libc.a syscall.o cerror.o)
and put these in front of the other objectfiles when linking, thus
bringing syscall and cerror "closer together".
That is:
 	cc   syscall.o cerror.o [ rest of .o ] -lm -ldbm -o perl

Everything worked nicely.

I really don't know if my "explanation" makes any sense to you but the point
is that it works (or at least seems to work).

Further info from somebody that understands HPPA would be greatly
appriceated.
	Jan D.

brian@hpausla.aso.hp.com (Brian Coogan) (11/15/89)

Glen Gordon <ggordon@agsm.ucla.edu> writes in comp.sys.hp:
> I too had this problem on HP-UX 3.11 until I undef'd SYSCALL in
> config.sh and reran the .SH scripts.  After that all went well and all
> the tests ran perfectly.  I assume that HP's syscall, which is not
> documented anywhere I know about is not intended for public consumption.

The problem is that the linkage between syscall and cerror uses a short
branch instruction rather than a long one.  If you refer to syscall explicitly
in a large binary this can results in cerror being out of range.  Loading
them explicitly together works around this problem. In 7.0 the branch
instruction has been fixed.  The problem is more likely to be that public
consumption was not foreseen & tested, not so much that it was forbidden.
Note that I'm not speaking for HP in this case, this is just my own
understanding.

Tor Lillqvist <tml@hemuli.atk.vtt.fi> writes in comp.sys.hp:
> In article <1322@iso.estec.nl> contrib@iso.estec.nl (AM Davidson) writes:
> >Oh BTW, don't use Perl's own malloc - it'll go crazy.

> It is possible to use perl's malloc if you patch it.  I don't have
> diffs handy, but I remember two changes were necessary on the
> hp9000s800: Use the strut field in the overhead union:

> #if defined(mips) || defined(sparc) || defined(hp9000s800)
> 	double  strut;			/* alignment problems */
> #endif

To use perl's malloc, you will have to add a conditional as above, though you
could also use defined(hppa) which is a little more general.

> and change the test for corrupt pointers to

> #ifdef hp9000s800
> 	if (*((unsigned int*)p) != 0 &&
> 	    (*((unsigned int*)p) > 0x80000000 ||
> 	     *((unsigned int*)p) < 0x40000000))
> #else

The corrupt pointer test is fixed at patchlevel 4, so you won't have to
change that if you can update to patchlevel 4.

---
Brian Coogan,	Hewlett-Packard Australian Software Operation.
ACSnet:		brian@hpausla.oz		UUCP: hplabs!hpausla!brian
Internet:	brian%hpausla@hplabs.hp.com	Tel: +61 3 871 1648 (TZ=EST-10)