mid-14c., gunne "an engine of war that throws rocks, arrows or other missiles," probably a shortening of woman's name Gunilda, found in Middle English gonnilde "cannon" and in an Anglo-Latin reference to a specific gun from a 1330 munitions inventory of Windsor Castle ("...una magna balista de cornu quae Domina Gunilda ..."), from Old Norse Gunnhildr, woman's name, from gunnr + hildr, both meaning "war, battle." First element from PIE *gwhen- "to strike, kill" (see bane); for second, cf. Hilda.
The identification of women with powerful weapons is common historically (cf. Big Bertha, Brown Bess, Mons Meg, etc.); meaning shifted with technology, from cannons to firearms as they developed 15c. Great guns (cannon, etc.) distinguished from small guns (such as muskets) from c.1400. Applied to pistols and revolvers after 1744. Meaning "thief, rascal" is from 1858. Son of a gun is originally nautical. To jump the gun (1912, American English) is from track and field. Guns "a woman's breasts" (especially if prominent) attested by 2006.