For Gestalt characters, as far as I know there isnt a hard and fast rule other than the "take the best of a class and use that". That said these options might be amenable to your DM.
1) If there only a few Gestalt Characters then you might consider maxing out rolls and giving an automatic appropriate template of choice with DM approval if the player has 2 animal companion classes. In addition allow the levels to stack to a max of actual character level (6ranger/6druid is still level 6, so use the higher of the 2 for determining animal) per normal rules for Gestalt. A template plus maxed stat rolls should be more than enough to give a companion a fighting edge albeit weaker than an actual additional party member in most cases. This case makes the player with such a split feel like they are "viable" and attended to for their focus on the animal companion given the other options that may offer better synergy.
2) If there is an average amount of gestalt characters allow a template OR maxed out stat rolls. The key here is that the players should be the focus a lot more of the focus than one players character boon. It should be fine combat wise without overshadowing the main focus which should always be the players themselves. Per usual, the higher of the class benefits should dictate the level/CR of the animal companion.
3) Bump up size category (stat and rule wise, not logistics wise IE the large ape doesnt actually become huge but hits and defends as if he were) of the animal in addition to normal gestalt rules.
One of these three should be palatable enough for a DM to agree with. Dont assume that its a given, work with the DM.
Ultimately, this is an issue you have to plead your case with the DM about. Let them know what the character's design is suppose to be and try to work together to come to a conclusion that doesn't feel munkin-y. Everyone wants their time to shine at the table.