If a company's main business is halal and its transactions also avoid interest-bearing borrowing, interest-bearing deposits and other prohibited dealings, its shares can be purchased and traded without this particular concern.
The practical difficulty is that such completely clean companies are rare in modern stock markets.