I would point you to the Wikipedia page for this song which reads:
"Venom – Music from the Motion Picture", more commonly known as simply "Venom", is a song by American rapper Eminem, written for the soundtrack of the 2018 film of the same name and featured in his album Kamikaze.
(emphasis mine)
As far as which was released first, the same page has the following to say:
On August 30, 2018, Eminem posted a 15-seconds teaser showing Venom's title with the "E" turning to the "backwards E", used as Eminem's emblem. Seven hours later, on August 31, 2018, Eminem's previously unannounced album Kamikaze was released, and "Venom" appeared as its final track. On September 21, 2018, the track was released as a separate digital single on streaming services
So I would say, rather than the movie inspiring the song or vice-versa, the producers of the film commissioned work from the artist (he was likely well paid for this - speculation on my part).
Logically, the song would have to be finished first to be included in the end credits of the film