7 ms·
Using LibC in x86 Assembly Programs
- georgecmu 15y agoUsing main and not _start is required by the gcc linker, any other symbol name will not work!. Not really; while main is default, -e flag allows you to specify an arbitrary symbol as entry point.
- KonradKlause 15y agoAFAIK it's -e, not -E.
- deleted 15y ago[deleted]
- jdefr89 15y agoI should mention that. Thank you.
- ypcx 15y agoYou can find more info on Linux (and System V) calling conventions, stack layout, etc. in this document: http://www.x86-64.org/documentation/abi.pdf http://www.x86-64.org/documentation/abi.pdf
- KonradKlause 15y agoThis covers only x8_64
- ypcx 15y agoTrue. This doc covers more targets: http://agner.org./optimize/calling_conventions.pdf http://agner.org./optimize/calling_conventions.pdf However, if I'm going to do low-level server work, I will not be doing it for 32-bit anymore. (There goes the 32-bit EC2 "small" machine, but so be it.)
- OwlHuntr 15y agoAs well intentioned as I imagine the author to be, there's really nothing here that you couldn't learn from older documentation, as several commentors have pointed out. A more interesting example would have been to calculate running time of some function vs. it's recursive version. Essentially, something besides an extended 'hello world'.
- jdefr89 15y agoA lot of the stuff you read on here can be found in documentation.. Who the hell wants to go back and read all that nonsense?
- drblast 15y agoWhy would anyone do this? If you've accepted that you're going to pay the cost to link against libc, use C. If you need to do something that specifically requires assembly, write that function (and that function only) in assembly. GCC will handle all of this very cleanly for you. You don't have to write main() in assembly.