tricks from TS's makefile and linker script ported over