It says the HD is the number of d8s the animal has but I wasn't sure if we should be rolling a d8 or just adding up the HDs as 8s + Con modifier.
House-rules apart, normally just the very first hit dice of a creature or character is maxed out. The rest are rolled. In some tables that could be diffent: you could take the average, for example, depending on what your group use as rule.
However, taking into account what Tridius commented, it seens that for racial hit die that rule is a bit different, so all of the hit die of your companion should be rolled.
So, let´s say that your companion dog is lvl 5. It will have 5d8 HP, plus all relevant cons bonuses.
I changed the awnser a little bit to take Tridius comment into account.
Short answer: Roll for them as usual and add Con modifier.
As Tridus pointed out:
The SRD at the Animal Companions page have this text:
As you can see, it all comes down to your group preferences.
Do you think the poor animal deserves a better chance of survival? Give him full HD.
Do you think that the Druid have already enough good stuff? Give him average HD.
Do you like randomness? Roll the HD.
Hope this helps ^^