factoring out some common code generated in ld28