I have a friend that has asked me for some aid in preventing their character from being made into an undead by a rather vindictive DM. I know that gentle repose can prevent a body from being raised as undead, and I believe another spell can do the same but cannot think of the name. I'm trying to find something that can be cast upon a living creature that will prevent the use of necromancy to turn them undead.
Ultimately, it seems that there's little that a creature can do to prevent its corpse from being the subject of a spell like animate dead. However, a creature can prevent itself from becoming an undead spawn upon its death at the hands or fangs of an undead creature like a shadow or vampire.
See the spell spawn ward…
In addition to other effects, the spell spawn ward makes it so the spell's subject "cannot be made into undead spawn if killed while the spell is in effect." It's a 5th-level cleric and inquisitor spell largely because of its other effects, the inability to be turned into a undead spawn if slain while the spell's duration continues appearing to be the spell's most minor boon. However, the spell spawn ward does not prevent a necromancer from using the protected creature's corpse to create an undead via a spell like animate dead.
The spell sanctify corpse can be cast on a corpse to, for 1 day, delay the corpse from rising as an undead and, for the same duration, prevent folks from using the corpse to create an undead creature from it like with the spell animate dead. The spell must be cast on the corpse each day for this delay and prevention to continue. The spell sanctify corpse is a 1st-level spell on many casters' spell lists.
(The spell gentle repose is actually of no help here, doing nothing to prevent the subject corpse from spawning as an undead or being transformed into an undead. The spell gentle repose just keeps a corpse from rotting. There also doesn't seem to be a lower-level spell that grants similar protection to spawn ward like the Dungeons and Dragons 3.5 2nd-level Sor/Wiz spell spawn screen [necro] (Spell Compendium 197), but I doubt a truly vindictive GM that's intent upon turning a PC into an undead creature will allow importing that spell from Pathfinder's antecedent!)
…But, instead, wear a ring of the faithful dead
If all that's sought is not to turn into an undead spawn, the ring says, in part, that if the wearer
is slain by a creature with the create spawn ability, the wearer does not rise as an undead creature, even if the ring is later removed. If a corpse is wearing a ring of the faithful dead, any attempts to create an undead creature from the corpse (such as via the spell animate dead) automatically fail, though simply removing the ring ends this protection.
The ring is a bargain at 500 gp. The elysian shield has a similar effect among its other effect, but at a much higher price at over 50,000 gp (and the necessity of bearing a tower shield).