[comp.sys.hp] WANTED: patch/zap program for HP9000

tope@enea.se (Tommy Petersson) (04/30/91)

I have a problem with an application on a HP9000. Two different
libraries must be linked to the application, and both have the same
symbol defined. No linking.

The symbol in at least one of the libraries is not used externally,
so it seems possible to solve the problem by changing all occurences
with a patch program.

Is one included somewhere on a HP9000? (I'm new to this machine, and
HP/Sweden isn't of much help). If not, where can I find a program that
let me change the symbol?

email answers to: tope@enea.se
Tommy Petersson

tml@tik.vtt.fi (Tor Lillqvist) (05/01/91)

In article <3276@enea.se> tope@enea.se (Tommy Petersson) writes:
   I have a problem with an application on a HP9000. Two different
   libraries must be linked to the application, and both have the same
   symbol defined. No linking.

   The symbol in at least one of the libraries is not used externally,
   so it seems possible to solve the problem by changing all occurences
   with a patch program.

Use the -r and -h options to ld(1).
--
Tor Lillqvist,
working, but not speaking, for the Technical Research Centre of Finland

mjs@hpfcso.FC.HP.COM (Marc Sabatella) (05/06/91)

>   The symbol in at least one of the libraries is not used externally,
>   so it seems possible to solve the problem by changing all occurences
>   with a patch program.
>
>Use the -r and -h options to ld(1).

More particularly, if by "not used externally" you mean it isn't used outside
of the particular object file within the library, then you can extract that
module, run it through "ld -r -h symbolname", and then replace the module in
the library:

	ar x library.a module.o
	ld -r -h symbol module.o
	mv a.out module.o
	ar r library.a module.o

This will hide the symbol from other modules, ensuring that it does not
conflict with the other symbol of the same name.

However, if by "not used externally" you mean that it isn't used outside the
library, but is used within the library, this won't work - the other modules
within the library won't be able to access the symbol.  If there are only a few
modules involved, you might consider extracting them, linking them all together
with "ld -r -h", putting the new combined file back into the archive, and then
deleting the original versions from the library.

If that isn't feasible, then you will indeed need some sort of byte editor.
You should extract each affected module, patch them, and replace them in the
library.  You can use "nm" to find which modules within the library define and
use the symbol.  There is no binrary editor supplied with HP-UX that I am aware
of, but Emacs has a binary mode.  Also, there is generally only one occurence
of the symbol name in the file, at least on the Series 300 and 400; it
shouldn't be terribly difficult to write a program to find it, hack it, and
write it back out.

--------------
Marc Sabatella (marc@hpmonk.fc.hp.com)
Disclaimers:
	2 + 2 = 3, for suitably small values of 2
	Bill and Dave may not always agree with me

franks@hpuamsa.neth.hp.com (Frank Slootweg CRC) (05/10/91)

Marc Sabatella writes :

> There is no binrary editor supplied with HP-UX that I am aware of, ...

  There is sure no binrary editor in HP-UX and not even a binary editor,
but often "vis" and "inv" can be used for simple binary edit operations.
See VIS(1) for details. If needed I can probably dig up some examples
(but give me some time because I am not smart enough to event my own
ones).

  Hope this helps.

Frank "Eye neffer cpel ennythink vronk" Slootweg, Dutch CRC.