Take Boots for example, it traded perfectly well for 160 years paying UK corporation tax until being bought out by private equity who transferred the HQ, and used tax laws for start up business to offset debt interest against tax, and now pays the UK 90% less corp tax. Perfectly legal, but not actually within the spirit of what the law was intended for. Other countries, like Australia as one example, have simple other caveats to stop things like this happening, something we could simply do here.
The debt interest that the off-shore company charges (basically an extraction of profits) has to be classified as arm's length (i.e. a bank would charge that amount of interest, for that loan, on those terms). They can't get away with charging 15% interest if it's senior debt secured to assets. There also has to be commercial reasoning behind the loan (i.e. would an independent party go to a bank for a £100m loan it doesn't need?).