Depends on how "hard" you want your fiction. Right now the top answer suggests having your creatures eat rock, which is a cool idea but doesn't male a whole lot of sense from a biological point of view, not if we assume your creatures are carbon based like life on Earth is. So I'm just going to throw a few more options of varying degrees of "hardness" and plausibility, but first, a premise. I'm assuming that your world will be Earth-like, with comparable atmosphere and temperature, I'm also going to assume that you wish to handwave the other classical problems one runs into when designing giant creatures, like how do they breathe or how do they avoid collapsing under their own weight. With that said: 1- Have them rely on symbiotic organisms that can metabolize stuff that a normal animal wouldn't be able to draw sustenance from. Photosynthetic organisms living in or on their skin could provide a lot of energy, as would a variety of specialized bacteria living inside them and able to process dangerous chemical substances that normally need to be disposed of, like the colonies of bacteria living in abyssal tube worms. This would even make the lithovore suggestion more plausible. 2- Have them live in the water and rely on filter feeding or similar behaviour. Just like blue wales, the largest animals that ever lived. If you want them to be terrestrial, have them have access to similarly abundant sources of food in the form of small, gregarious and numerous animals. Just keep in mind that this will necessitate a very different environment from Earth in order to work, probably a hypercharged biosphere, with access to a lot more energy than what is found on Earth. Some kind of super-earth planet might do the trick. 3- Have them be plant eaters. Boring but practical, as the biggest land animals that ever lived, sauropods, show that some truly impressive sizes are possible for a sufficiently specialized plant eater. And of course where there are large preys there are large predators, though to have them in any large number or to make them reach as impressive sizes as their preys you need again a hypercharged biosphere.