Submitted upstream at https://github.com/WebAssembly/wasi-libc/pull/509. Differential Revision: https://phabricator.services.mozilla.com/D214492