About ChocoOS Forums System Development User Space Userspace programs – ELF

This topic contains 8 replies, has 1 voice, and was last updated by Patryk Patryk 1 month, 2 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #897
    Patryk
    Patryk
    Keymaster
    #900
    Patryk
    Patryk
    Keymaster

    how system should load elfs:

    http://www.lurklurk.org/linkers/linkers.html

    #901
    Patryk
    Patryk
    Keymaster
    #902
    Patryk
    Patryk
    Keymaster
    #903
    Patryk
    Patryk
    Keymaster
    #904
    Patryk
    Patryk
    Keymaster

    using GOT: http://bottomupcs.sourceforge.net/csbu/x3824.htm

    #905
    Patryk
    Patryk
    Keymaster

    source code of preparing ELF to run in linux: http://elixir.free-electrons.com/linux/latest/source/fs/binfmt_elf.c

    #906
    Patryk
    Patryk
    Keymaster
    #907
    Patryk
    Patryk
    Keymaster

    It is very interesting, for now I am not sure, how it should works. Lets take a look:

    As we can see at the begin it loads into the r4 register, the value from the offset 843c, and then it adds the PC to it. It is because of the -fPIC flag. It looks, that the register ‘r4’ stores the base address of the external symbol table, or something like that. After that, when the program want to call the function from the external symbol table, it loads the offset to the function from the 8440 and adds the r4 register to it.

    But how can we know, where the base address is?

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.