Not just stock: companies are constantly comparing alternative sources of capital. Any increase in demand from investors for any particular source of capital (bonds, stocks, loans, etc...) will tend to make that capital available at a lower cost to the company.
I have not thought about whether aggregate increases in the demand for housing have the same positive effect on firms, though you could argue that increasing housing values creates home equity and the mortgage interest deduction encourages homeowners to borrow against that new equity and invest the proceeds in ways that will generate a higher return than the interest rate - marginal tax rate, such as stocks. But that happens a lot in economics, many seemingly conflicting forces can lead to the same effect.