We derive a thermodynamic identity that allows one to infer the change in the number of screening ions that are associated with a charged macromolecule as the macromolecule is continuously stretched. Applying this identity to force-extension data on both single-stranded and double-stranded DNA, we find that the number of polymer-associated ions depends nontrivially on both the bulk salt concentration and the bare rigidity of the polymer, with single-stranded DNA exhibiting a relatively large decrease in ion excess upon stretching. We rationalize these observations using simple models for polyelectrolyte extension.