home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / hp / 12730 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  2.9 KB

  1. From: cdb@hpcuhe.cup.hp.com (Carl Burch)
  2. Date: Tue, 10 Nov 1992 01:48:40 GMT
  3. Subject: Re: What's 'P-fixup again???
  4. Message-ID: <31480279@hpcuhe.cup.hp.com>
  5. Organization: Hewlett Packard, Cupertino
  6. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!scd.hp.com!hpscdm!hplextra!hpcss01!hpcuhe!cdb
  7. Newsgroups: comp.sys.hp
  8. References: <1992Nov5.143254.22984@cv.ruu.nl>
  9. Lines: 56
  10.  
  11.  
  12.    Several questions on comp.sys.hp lately have involved the Gnu C compiler
  13. and the linker message below :
  14.  
  15.         gcc  test_h.o -o test_h ../libg++.a -lm
  16. ld: R_DATA_ONE_SYMBOL fixup in file ../libg++.a(streambuf.o) for code unsat
  17. symbol "abort" - use P' fixup
  18. collect: /bin/ld returned 1 exit status
  19.  
  20.    This is caused by the code generator emitting assembly code in a data
  21. subspace to initialize a function pointer, equivalent to :
  22.  
  23.     .word    foo
  24.  
  25. where (in this case) foo() is an extern, and shared libraries are referenced
  26. by the executable being built (usually libc.sl).  
  27.  
  28.    The linker is being helpful by pointing out a fatal error waiting
  29. to happen, as function pointers are different in the presence of shared
  30. libraries.  A different fixup is needed to generate the kind of procedure
  31. label that can be called.  This is explained under "Procedure Labels" in
  32. Chapter 7 of "Programming on HP-UX" (Part # B2355-90026 E0892) and at the
  33. end of "Expressions" in Chapter 1 of the Assembly Language Reference Manual
  34. (Part # 92432-90001 E0191).
  35.  
  36.    There are two ways to fix this :
  37.     1) Change the code generation to the equivalent of :
  38.         .word P%foo
  39.     or
  40.     2) Link the program using the "-a archive" linker option.  The
  41.     easiest way to do this is via the LDOPTS environment variable :
  42.         setenv LDOPTS "-a archive"
  43.          - or -
  44.         LDOPTS="-a archive"; export LDOPTS
  45.  
  46.    The first fixes the problem directly, generating an R_DATA_PLABEL fixup
  47. which is unambiguous whether shared libraries are present or not.  The
  48. second puts you back in time to the situation before shared libraries were
  49. added to HP-UX.  Without shared libraries HP-UX drew no distinction between
  50. code addresses and procedure labels - an ambiguity that the P% fixup syntax
  51. resolves.
  52.  
  53.    The reason the linker can't just fix this situation is that there are
  54. cases where code addresses are implicitly or explicitly desired, cases that
  55. are part of the motivation for having an assembler to begin with.
  56. Unfortunately, in this case a message designed to be helpful to an errant
  57. assembly programmer is instead a symptom of an out-of-date code generator,
  58. and is too low-level to help the people seeing it.  The other alternative
  59. (letting the program segmentation violate at runtime with no warning) would
  60. be more likely to result in the user blaming the Gnu code generator instead
  61. of HP's linker, but otherwise very little more satisfying.
  62.  
  63.                         Carl Burch
  64.                         HP California Language Lab
  65. ------------------------------------------------------------------------
  66. I don't get paid to speak for myself, let alone HP.
  67.