I am replacing the toilet in my house, and after removing the old toilet, I can see that the flange is not bolted to the floor. Also, it sits up off the finished floor about a quarter inch. Do I need to add any supports underneath to fill the gap, and do I need to drill holes and bolt it down to the subfloor before installing the new toilet?
The bottom of the flange needs to be sitting flush with (or not more than 1/8" above) the finished floor or else the toilet will rock. The flange should be fastened to the floor. Dry fit the toilet to make sure it doesn't rock. If it does rock, use shims to prevent rocking - just tightening the bolts probably will not stop the rocking but will risk cracking the toilet or breaking the flange.
We would usually screw it down during the rough in. Having said that I personally see nothing wrong with cementing it to the exit pipe below. Although not my first choice I have seen installs last many many years without screwing in the flange. For example for basement bathrooms I would just attach the flange via cement. Also if you have the PVC cemented together the screws are really doing nothing, other than backing up the cement in case of failure.
Closet (toilet) flanges must be 1/4" above a finished floor. This is so the wax ring seals properly to the flange and the hub on the toilet. If a proper seal is not achieved it will result in leaking. If the flange is lower than or flush with the floor they make foam rings that cover the distance for a proper seal. The foam seal will also seal in the case of your rocking toilet issue, and although it is not recommended and usually against code for wax rings, you can stack the foam seals.
Should be flush to the finished floor and bolted down. That's what all the holes are for in the flange. Screws are fine. If it's floating shim it with something suitable for damp locations, not because of leaks, but because it's a bathroom and bathrooms get wet. Use a new wax ring attached to the bottom of the bowl and carefully lower it on center.
If your pipe is already installed with a flange and studs, it's probably attached correctly. A sub floor was probably installed during the last remodeling. You just need to check for rot around the pipe flange.