Composition of super-Earths, super-Mercuries, and their host stars