It uninterns every package's internal symbols. (In the special case of the
KEYWORD package, it uninterns the external symbols.) A garbage collection is then carried out, after which any remaining symbols are reinterned in the package from which they came. A similar procedure for class definitions and methods discriminating on classes is also performed.
If you require that certain internal symbols be kept, and know they will not be kept because they are not referenced in the image, you can export them explicitly. See :exports. Doing so prevents them from being deleted.
External symbols are shaken by default.. See :shake-externals,.