According to the Edda and the Völsunga saga, Hamdir and Sörli were the sons of Gjuki's daughter Gudrun and king Jonakr. Erp was the son of Jonakr from an earlier marriage. Svanhild, the daughter of Sigurd and Gudrun was also raised by Jonakr.
King Jörmunrek (Ermanaric) proposed to Svanhild through his son Randver, but the treacherous Bicke said that Randver tried to win Svanhild's love. Consequently, Jörmunrek sentenced Randver to death by hanging and had Svanhild trampled to death by horses. Gudrun then agitated her sons Hamdir and Sörli to avenge their half-sister. When Sörli and Hamdir met Erp en route, they didn't understand his riddles and, thinking him arrogant, killed him.
During the night, they arrived and they cut off Jörmunrek's hands and feet. This made Jörmunrek wake up and he cried for his housecarls. Hamdir said that if Erp had been alive he would have cut off the head. The housecarls could not kill the two brothers with sharp weapons, but an old one-eyed man (Odin) advised them to kill them with stones.
This is why scaldic poetry used the "sorrow of Jonakr's sons" as a kenning for stones.
Sources and historic basis
The legend of Jörmunrek appears in the Poetic Edda as Hamðismál and Guðrúnarhvöt. It also appears in Bragi Boddason's Ragnarsdrápa, in the Völsunga saga and in Gesta Danorum. Jordanes wrote in 551 that the Gothic king Ermanaric was upset with the attack of a subordinate king and had his wife Sunilda (i.e. Svanhild) torn to pieces by horses, and as revenge Ermanaric was pierced with spears by her brothers Ammius (Hamdir) and Sarus (Sörli) and died from the wounds. The Annals of Quedlinburg (end of the 10th century) relates that the brothers Hemidus (Hamdir), Serila (Sörli) and Adaccar (Erp/Odoacer) had cut off the hands of Ermanarik.