they have a plan for this: reformulating old drugs for new indications. if drug X was originally made for condition Y but there is some inkling which suggests it could work for condition Z, they can commission a new round of trials and eventually remarket X for Z. thus the crusty and middlingly profitable X gets a new lease on life, treating Z with modest efficacy. they do this at a very high rate at present.
they can also rehabilitate their older drugs by making facile new combinations in which drugs A and B which treat condition Z are combined into the same pill which is now rebranded as drug C. this technique is beneficial because if A and B were first-line treatments before, C is guaranteed to be a first-line treatment with a minimal amount of time in the wild.
then there's the old side effect shuffle in which older drugs with acceptable but unpleasant side effects are reformulated or otherwise tweaked to offer marginally better patient experiences, most frequently in a single small patient demographic. marginal improvements win the market if the drug's target demographic is already suffering a lot from their condition or their treatments.
in conclusion, the pharmas can create the appearance of innovation and modest new revenues nearly indefinitely even when their pipelines are in actuality quite sparse and breakthrough innovation is absent. this ability to churn old stuff buys them time to create new stuff to put into the pipeline using more complex therapeutics like immunotherapies, etc.