Before setting `CONFIG_USERSPACE=y`, my image size is ~680KB. After setting it, it overflows my partition by ~60KB. The partition size is ~840KB, meaning userspace has added 220KB of code!
Both are compiled with debug=y and speed_optimization=y. If I enable size optimization it shrinks enough to fit into my partition, but there is still significant differences between the two
I took the zephyr_pre0.map before and after enabling userspace and compared it using the diff tool meld. From what I can tell, it seems to have added a small amount of code to many of the functions. However, I can't pinpoint any one section that accounts for a significant chunk of the 220KB (it's getting a bit late here, but I'll look at it in more detail tomorrow).
Here's a screenshot of what I mean.
The left is no userspace, and the right is userspace. Three functions in this image have a slight increase in code size, which is very common throughout the map files. I can see the addresses slowly diverge as I scroll through the file, but I can't find anywhere where it jumps significantly.
Is this to be expected? This seems like a significant overhead, especially given the fact that there are already heavy restrictions on app partitions (alignment and size must be power of two) that make it difficult to use many partitions without heavily inflating ram usage. I assume this is for performance reasons in the hardware, which is why I'm surprised that there seems to be such a massive overhead in code size. I'm hoping this is just a mistake on my end.