Search code examples
cmainframedebug-symbolszos

Remove symbolic information from C language executable on z/OS


Having built my application, initially using debug, I now move to make it production ready. I have changed my compile options from

-c -W"c,debug,LP64,sscomm,dll"

to

-c -s -W"c,LP64,sscomm,dll"

which reduces the size of the resultant executable to 60% of the debug version.

I changed my link options from

-W"l,LP64,DYNAM=DLL"

to

-s -W"l,LP64,DYNAM=DLL"

which further reduces the size of the resultant executable to 20% of the original debug version.

So it certainly seems to be doing something. But when I view the executable, I can still see all the function name eye-catchers in the executable, and when I force an abend, the CEEDUMP generated still shows all the function names in that file. I expected -s to remove all symbolic information.

So my question is "how do I remove all symbolic information?"

In addition, once linked with -s I can no longer copy the module to an MVS dataset, from the USS file where it is generated. I use the following command:-

cp -X prog "//'ME.USER.LOAD(PROG)'"

which fails with:-

 IEW2523E 3702 MEMBER *NULL* IDENTIFIED BY DDNAME /0000002 IS NOT AN EDITABLE
          MODULE AND CANNOT BE INCLUDED.
 IEW2510W 3704 ENTRY OFFSET  0 IN MODULE *NULL* IDENTIFIED BY DDNAME /0000002
          DOES NOT EXIST IN A VALID SECTION.
cp: FSUMF140 IEWBIND function "INCLUDE" failed with return code 8 and reason code 83000505

This error message seems to say that I need the EDIT linkage option, but if I add that in, it appears to negate the step of using -s on the link, as the size goes back up to 60% of the debug version size.

So my second question is, "how do I copy the file to an MVS dataset and also remove symbolic information?"

Maybe there is a subsequent step that I can take to drive the binder again to remove symbolic information from the USS file and from the MVS dataset after the copy?


Solution

  • You can use COMPRESS compiler option and to some extent COMPACT. The COMPRESS option will suppress emitting function names in control blocks, while the COMPACT option will influence the compiler optimization choices to favor smaller object size.

    Even though you are compiling and linking your executable in USS, you do not need to produce the executable in USS and then copy it to a data set. You can put your executable straight into the data set by using -o "//'ME.USER.LOAD(PROG)'" syntax. Just make sure your output data set is a PDSE.

    Since you are compiling and linking in USS, you should use the xlc utility with -q syntax for compiler options as this syntax avoids the use of parenthesis which have special meaning in shell.