embeddedartistry / libc

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
MIT License
524 stars 67 forks source link

Address pointer math bug in crt.c #152

Closed phillipjohnston closed 4 years ago

phillipjohnston commented 4 years ago

Originally we used void* for calculations, but this is a GCC extension. I switched to uintptr_t, but then I was doing actual math. This meant that the startup code was calculating values incorrectly, and running 4x the actual functions that were supposed to be run.

For portability reasons, we keep the uintptr math, and then we convert back to the actual count of functions using shift operations.