Generate only pure libraries with no relocations.
With -ztext, if ld finds an incomplete relocation in the text segment, then it does not build the library. If it finds one in the data segment, then it generally builds the library anyway; the data segment is writable.
Without -ztext, ld builds the library, relocations or not.
A typical use is to make a library from both source files and object files, where you do not know if the object files were made with -pic.
Example: Make library from both source and object files:
demo% f95 -G -pic -ztext -o MyLib -hMyLib a.f b.f x.o y.o
An alternate use is to ask if the code is position–independent already: compile without -pic, but ask if it is pure text.
Example: Ask if it is pure text already—even without -pic:
demo% f95 -G -ztext -o MyLib -hMyLib a.f b.f x.o y.o
The options -ztext and -xprofile=collect should not be used together. While -ztext prohibits position-dependent symbol relocations in read-only storage, -xprofile=collect generates statically initialized, position-dependent symbol relocations in writable storage.
If you compile with -ztext and ld does not build the library, then you can recompile without -ztext, and ld will build the library. The failure to build with -ztext means that one or more components of the library cannot be shared; however, maybe some of the other components can be shared. This raises questions of performance that are best left to you, the programmer.