The gem golems have some pretty sick damage reduction that a measly little iron weapon isn't going to do poop against. You are literally banging your sword on a rock. However, the elemental damage on you swords should actually hurt them, depending on the type of golem it is. Now, this information comes from beating on the critters myself, not from some intimate DM knowledge of the creature, so I might be wrong, but I doubt it.
I'm not as sure about the earth elementals, but the same should go for them, since they are rocks with nice DR too.