I watched this movie in maybe 1992 but it's not the iron giant for sure. I just remember a young boy finding the old war robot and some bad guys trying to take it. I seem to remember the robot was an old war relic and a chase scene with a steam train springs to mind. Thanks in advance for anyone who helps solve this.
In Castle in the Sky (1986) there is an ancient, broken robot that is later reanimated and begins attacking people.
The young boy (Pazu) doesn't find the robot, but he and a young girl (Sheeta) are taken to a fortress where the robot is already being studied. The "bad guys" were attempting to repair it.
There is a scene later in the movie where Pazu and Sheeta find another robot that is deactivated and overgrown with grass and moss. This may be where you got the "buried in a cliff" memory.
The movie also includes a steam train chase between the young boy and girl, a band of pirates, and a group of government and military men.
Is it Yamato Takeru?
A boy found a robot buried underground. At the same time a group of villains with similar type of robot tried to acquire that robot.
A million years later, the Death Star Yomi is approaching the Onam System once again. Tsukuyomi, the master of Yomi, plans to take this opportunity to realize his dream of ruling the entire universe. He is desperate for the last stone containing Yamatano Orochi. If Tsukuyomi can get hold of this capsule, Yamata no Orochi will return to life and its power will become his. Tsukuyomi needs Sky Warrior Susanoo to abstract Orochi and dispatches Sky Soldiers to retrieve Susanoo. But it is too late. Susanoo no longer belongs to Tsukuyomi. It belongs to Takeru, a 12-year-old boy from Earth, who happened to discover the buried robot Susanoo and woke it from its million-year-long sleep. Takeru becomes involved in the battle against the Sky Soldiers and the fate of all in Ismo.