Constraining the origin of giant exoplanets via elemental abundance measurements