How to rig and move two objects in sync?
What you are looking for is a Child of Constraint.

Both the gun and the magazine need to be rigged separately with at least one bone each. 

This file comes with a likely scenario: a hand with a gun holster (the character) which has 1 rig, the gun (separate rig), and magazine (separate rig).



The hand has a special bone called "Grabber" where the gun and the magazine will be parented to with the constraint.
The gun has 2 "Child of" constraints, one for the hand, one
for the holster
The magazine has 3 "Child of" constraints - hand, gun
and holster.


In an animation, you keyframe the influence to the bone you want it parented to. If the mag is in the gun, put the gun influence at 1 (and move the mag rig to the gun). Now if the gun moves, the mag moves. Same thing with the other elements.

Only one influence must be active.

If you are building this yourself from scratch, you must press the "set inverse" button each time you add a new Child of constraint.