The presence of light elements such as S, Si, C, O, P, etc., can significantly modify the density, compressibility, and phase relations of the molten metallic cores in the terrestrial planets and some differentiated icy/rocky satellites. Thus, knowledge on the high-pressure properties of Fe-alloying liquids is critical to the understanding of the composition, structure, and evolution of planetary cores. In this study, we determined the sound velocity of Fe-X (X = S, Si, C, or P) liquids up to 7 GPa and 2073 K by combining the ultrasonic measurements in a multianvil device with synchrotron X-ray imaging and diffraction techniques. Combined with our density data and data in the literature, our velocity data provide tight constraints on the equations of state for Fe-rich liquids. The temperature dependence of sound velocities also provides constraints on the Anderson-Grüneisen parameter, from which the adiabatic temperature gradient in molten planetary cores can be calculated. We also developed a new technique to determine the high-pressure melting phase diagram of Fe-light element alloys utilizing the ultrasonic sound wave propagation through the sample. With this technique, we have determined the phase diagram of the Fe-P system up to 7 GPa. Comparing adiabatic temperature gradients derived from our velocity data with the pressure dependences of liquidi for metallic cores, our results point to complex solidification histories of metallic cores, depending on the pressure and the type and abundance of light elements present in planetary cores.