Using a sharp knife held parallel to the bone, score the fat from one side to the other. Continue scoring at 1-inch intervals from bottom to top of the fat layer. Sprinkle the ham on all sides with salt and pepper.
Chop the rosemary as fine as possible and blend with the garlic. If you have a spice mill, grind the two together. In any event, rub the ham all over with the mixture.
Brush the ham on all sides with oil. Arrange the ham, fat side up, in a large roasting pan. Place in the oven and bake1 hour, or 45 minutes for a boneless ham. Reduce the oven heat to 350 degrees and place the onions in the pan. Bake 1½ hours longer, basting often with the pan drippings. As the ham bakes, rotate the pan in the oven so that it bakes evenly.
After 2½ hours total baking time (2¼ hours for boneless ham), pour off the fat from the pan and return the ham to the oven. Continue baking, basting and rotating the pan occasionally, about 30 minutes.
Pour off all the fat from the pan. If the ham has a bone in, you will facilitate carving if you pull out the very thin bone from the short end of the ham. If the ham is done, it should come out easily. Add the chicken stock to the pan and return the ham to the oven. Continue baking about 15 minutes. If you use a meat thermometer, the temperature at the thickest part of the ham should register 165 degrees. Transfer the ham to a warm platter.
Line a saucepan with a sieve and pour the pan juices into it. Skim off the fat. Bring the pan juices to the boil and serve with the ham.