4 pointsby shikaan3 days ago1 comment
  • saidnooneever3 days ago
    there is a bit about 'global _start' which is confusing.

    using symbol _start isn't a rule of the assembler; it’s just a default convention used by the linker. you link your object file with LD which applied its default link script and that includes entry symbol being _start.

    You can actually use any name you want (e.g., global my_entry) as long as you point to it using a linker script or the -e flag. It’s important to distinguish between the Assembler (which just exports symbols) and the Linker (which defines the entry point in the ELF header).

    using symbol _start is done so that libc or crt0 _start can be called and then that calls main (for C code). This whole convention has nothing to do with programming languages or code. its just a result of some default choices. you can dump the default linker script from LD to see whats in there. its pretty interesting to learn especially if u write assembly as your code is more directly manipulated / treated as you define sections manually etc.