News for hackers. Stuff that matters.
Re:Elf Hello World by wyldfire on Wednesday May 17, 2017 @11:44AM (#14359565)
It's great, thanks!

Thoughts for chapter 2: stuff that often confuses me: PLT, GOT, FDE/CIE.

Re:Elf Hello World by cstrahan on Wednesday May 17, 2017 @04:18PM (#14362408)
Eli Bandersky wrote an excellent series on load-time relocation and position independent code (PIC), including details regarding PLT/GOT:

http://eli.thegreenplace.net/2011/08/25/load-time-relocation...

http://eli.thegreenplace.net/2011/11/03/position-independent...

Re:Elf Hello World by rocky1138 on Wednesday May 17, 2017 @11:52AM (#14359651)
I love the fact that it's all on one page and uses HTML anchors to get around. It makes it super simple to archive and read up later if the site ever goes down.
Re:Elf Hello World by cirosantilli on Wednesday May 17, 2017 @01:39PM (#14360779)
Well, you can also fork and git clone it: https://github.com/cirosantilli/cirosantilli.github.io/blob/... :-)
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.

Re:Elf Hello World by bogomipz on Wednesday May 17, 2017 @11:59AM (#14359751)
I know PLT and GOT but am unfamiliar with the acronyms FDE/CIE. Can you say what those are?
Re:Elf Hello World by wyldfire on Wednesday May 17, 2017 @12:08PM (#14359837)
FDE: Frame Description Entry, CIE: Common Information Entry. AFAIR, they're used to unwind the stack in exceptions.

I think it's specified by itanium C++ ABI (which sounds archaic but actually many other processors use the same one).

I don't recall if these things are ELF features or if the ELF only knows about the "eh_frame" section. It's interesting and kinda sorta related low-level stuff IMO.

Re:Elf Hello World by bogomipz on Wednesday May 17, 2017 @12:16PM (#14359912)
Interesting, I wasn't familiar with this standard. It sounds like this has been adopted by some other architectures besides Itanium as well:

http://wiki.dwarfstd.org/index.php?title=Exception_Handling