Use `getElementAsAPInt(`) to read array elements and emit via
`addIntAsBlock()` which handles target endianness correctly, instead of
`getRawDataValues()` which exposes host endianness. This fixes test
failures on big-endian hosts cross-compiling for little-endian targets.
Reland of #182442 with endianness fix.