Handle long library search paths

Before launching the arch-specific emulator, the emulator wrapper adds
a directory to the library search path (LD_LIBRARY_PATH or PATH).
There were two problems that this change fixes:

- The new path was assembled in a 2048 byte buffer. If the assembled
  path was longer than that, it would be truncated, in effect removing
  some directories. This change dynamically allocates the buffer so
  truncation doesn't happen.

- On Windows, the new directories were appended instead of prepended
  to the existing search path. If the path was truncated due to the
  previous problem, the new directory wouldn't be added to the path,
  and the arch-specific emulator would fail to load. This isn't a real
  problem now that truncation doesn't occur, but this change makes
  the Windows version prepend the directory for consistency's sake.