This is an outgrowth of my previous post 'SLIM vs SLINK'.
I was going through the MAP file for one of the executables and came across a LOT of symbols that should not have been included in the executable. I've been poking around for several days trying to find out why, if I am using a library, so much extra code was loaded when it was never called for. I now have a clue.
If I happen to declare a named COMMON block that is also called out in other objects in the library, then those objects also appear to get loaded, then objects that are called by these objects, etc., etc.
I verified that by looking at the MAP file for a smaller piece of code. Compiles without errors, links fine, creates a very tiny executable that consumes about 1.8 MB at run time. Link Map: https://drive.google.com/file/d/13AdQS-x5i0qaBGYgAAHPVzAaKsndCD3h/view?usp=sharing
I then added the name of a COMMON block (CLOGCM) used by other modules in my library, and included one data item of 8 bytes in this common block. Other than this, there was no change to the code, and I never referenced the data item in the code. I then compiled and linked (got one warning about differences in COMMON block sizes, which was expected) and, since I did not change the SLINK step, I got undefined symbols. I now have en executable that, when run, now consumes 509 MB. Link Map: https://drive.google.com/file/d/1QiojnSa8HOx3PENklb7Qyztn4Ng_to4j/view?usp=sharing
Stated another way, the final link processing not only includes the linked objects that one requires, but also every module that those modules have in COMMON with all other modules, and as these modules have other COMMON, then those other objects get loaded, etc.
I don't think this is the way it should work.
V8.20.0