Fix compilation with GCC

Hi, I have done some minor changes to fix compilation with GNU toolchain (gcc and ld). Please see commit messages for details.