News for hackers. Stuff that matters.
Re:Elf Hello World by rocky1138 on Wednesday May 17, 2017 @02:30PM (#14361351)
Thanks for the article! I'm really enjoying learning this stuff. One thing that came up which doesn't appear very clear is why `ld` continues to set the entrypoint for executables at 0x08048000 when that seems like such an arbitrary number held over from a version of Unix made decades ago. Wouldn't it be better to just get rid of that and start programs at 0x00000001? (leaving 0x0 open for NUL).
Re:Elf Hello World by kdunwoody on Wednesday May 17, 2017 @03:46PM (#14362162)
Definitely not. In rough order of importance:

1. Space for NULL should be big enough for at least a medium-sized structure, otherwise (*NULL)->field = blah will overwrite your code. 2. Because of (1), Linux (for example) doesn't even allow processes to map the first page or so of memory. 3. On many platforms the PC needs to be aligned to a word boundary.

Re:Elf Hello World by rocky1138 on Wednesday May 17, 2017 @04:42PM (#14362609)
I see. I've obviously got a lot more to learn. Thanks :)

One more question, though: how much space should be safe to leave for NULL? Is 128MB enough? Why not only as much as required?

I suppose it doesn't really matter anyway since the entry point location is virtual at this point anyway.

Re:Elf Hello World by Ded7xSEoPKYNsDd on Thursday May 18, 2017 @06:03AM (#14366004)
It's impossible to know how much exactly is required. (While structures are fixed size, arrays indices are not.)

Linux allows you to configure the limit at /proc/sys/vm/mmap_min_addr.