The nasty secret is called "transfer pricing", which is permissible under OECD rules, which permits companies to claim their headquarters are whereever they want (so they choose a low tax jurisdiction), when everybody knows that their "real headquarter" is not there (including their own Website, which names an entirely different place as their HQ). One such loophole the "Double Dutch-Irish Sandwich" was closed two years ago, but plenty of other ways remain.
It is a bit unfair to "Big Pharma" (or Apple) to single them out, because lots of other corporations do the same. For example, just check the Canton Zug (CH)'s ratio between companies registered there (29k?) and people living there (25k?). I have not seen a single political party offering in their manifesto to fix this... meanwhile large corporates create shell companies owned by other shell companies licensing brands to third shell companies while receiving loans from fourth parties etc. etc. - typical money laundering patterns like organized crime, yet entirely legal at the moment.
In my opinion, everyone who is a Director of >50 companies should be investigated for fraud to begin with, and rules for determining companies' true headquarter should be changed so they cannot be freely chosen "only for tax purposes".