To clarify, it’s not that the square rigged sails themselves can be used to sail upwind. I was talking about how you could rotate the yard so that the sails could continue to catch a wind. But, for sailing upwind, the square rigged sails wouldn’t help much. It’s that square rigged sailing ships had staysails which would let them sail upwind slightly. Apparently a fore-and-aft rigged sailing ship can sail within 20 degrees to the wind, while a square rigged ship could only do about 60 degrees.
In a castaway situation, I wonder what the best idea would be. Try an experimental modification of an existing sail to give you better mobility? Or be thankful you have a working sail and accept limitations on how much you can steer? Ignoring the sails though, my guess is that in a shipwreck, one of the most likely to be damaged things will be the keel, and trying to sail without a good keel would suck.