15-Jul-2010

Universal symbol deletion

Quite some time ago, I assisted the company I now work for to do a port of their in-house ERP system from Alpha to Itanium. As expected, some of the source code was missing when I got around to attempting to compile the entire system. Unfortunately, one of the bits that was missing was the source code to the large screen handling library that the application used.

The reason that this source code was missing was that the application was originally developed by a third party software house, who then sold it to this company. The company never purchased a source license for the screens library, and hence only had a shareable image when the port came around.

Now, during the port, it became apparent that another missing bit of source was performance critical. This company contacted the directors of the (now defunct) third party software house, and we managed to get the source for the performance critical module. I recommended at the time that they get the source for the screens library, but the directors wanted money for that transaction, and as the screens library was not performance critical, it was decided not to purchase it. We binary translated it instead.

Fast forward to now.

While investigating a mysterious CPU loop in a detached process (that calls the screens library on error ;) I was mystified that a part of the source that I did possess would not display in the debugger. On digging in, I found to my consternation that a copy of the module that I had the source to was embedded in the screens library.

I can only assume that at some point in time it was decided that because every single program in the system used this module, then it would be a good idea to put it in a shareable image. I really needed to get the module out of the shareable, but how could I do this without the source code?

The situation prompted a call for help on c.o.v.

While I was waiting for an answer there, I was reminding myself of symbol resolution order in the linker, and thinking that I'd have to complicate the options files that the developers were using by including a bunch of CLUSTER and COLLECT statements.

Then Ken Randell emailed me the "slap the forehead" solution. Ken suggested that I just edit the offending shareable image with a text editor and replace the name of the universal symbol with something else of the same length, then convert the output of the editor back into a fixed length 512 byte record. It worked! Thanks Ken!

A few more details: You only have to use this hacked shareable image as the input for the linker. Obviously, if the linker includes the object from the object library, the executable will run that rather than invoke the shareable image. You can also point to the hacked shareable or a copy of the non-hacked one. As the image activator will never look in the shareable for the renamed symbol, that part of the shareable is effectively disabled (unless for some strange reason you linked to the shareable with a reference to the renamed symbol).

Posted at July 15, 2010 6:12 PM
Tag Set:

Comments are closed