5 ms·
It's great, thanks! Thoughts for chapter 2: stuff that often confuses me: PLT, GOT, FDE/CIE.
by wyldfire 10y ago
It's great, thanks!
Thoughts for chapter 2: stuff that often confuses me: PLT, GOT, FDE/CIE.
- rocky1138 10y agoI 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.
- cirosantilli 10y agoWell, you can also fork and git clone it: https://github.com/cirosantilli/cirosantilli.github.io/blob/master/elf-hello-world.md https://github.com/cirosantilli/cirosantilli.github.io/blob/... :-)
- rocky1138 10y agoThanks 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).
- kdunwoody 10y agoDefinitely 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.
- rocky1138 10y agoI 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.
- Ded7xSEoPKYNsDd 10y agoIt'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.
- bogomipz 10y agoI know PLT and GOT but am unfamiliar with the acronyms FDE/CIE. Can you say what those are?
- wyldfire 10y agoFDE: 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.
- bogomipz 10y agoInteresting, 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 http://wiki.dwarfstd.org/index.php?title=Exception_Handling
- cstrahan 10y agoEli 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-of-shared-libraries/ http://eli.thegreenplace.net/2011/08/25/load-time-relocation... http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/ http://eli.thegreenplace.net/2011/11/03/position-independent...