Gilmour said he spoke to Khlyvnyuk, who was recovering in a hospital from a mortar shrapnel injury, while he was writing the song. He said: "I played him a little bit of the song down the phone line and he gave me his blessing. We both hope to do something together in person in the future."
The song is being released on Friday (Saturday NZ time) and the band says proceeds will go to the Ukraine Humanitarian Relief Fund.
"We want to express our support for Ukraine, and in that way show that most of the world thinks that it is totally wrong for a superpower to invade the independent democratic country that Ukraine has become," Gilmour said.
Pink Floyd was founded in London in the mid-1960s and helped forge the UK psychedelic scene before releasing influential 1970s albums including "The Dark Side of the Moon", "Wish You Were Here" and "The Wall".
Original member Waters quit in 1985, and the remaining members of Pink Floyd last recorded together for the 1994 album "The Division Bell". After keyboard player Richard Wright died in 2008, Gilmour said he doubted Pink Floyd would perform together again.
"Hey Hey Rise Up" also features Guy Pratt on bass and Nitin Sawhney on keyboards.