0

I have one elf 32 application and not stripped, I use gdb info functions and it list only the memory address and function name, but there is no function name with "main", so any way to find the main function of the program?

the other problem is when using info functions, it didn't list of the input parameter of each function, if i want to list all input parameter of each function, which command should be use?

1
  • Give, at least, the architecture you target. Saying '32-bit' is not enough!
    – perror
    Commented Dec 17, 2018 at 10:22

1 Answer 1

1

The memory address of main() is a parameter of __libc_start_main:

int __libc_start_main(int *(main) (int, char * *, char * *),    <-----pointer to main
                      int argc, 
                      char * * ubp_av, 
                      void (*init) (void), 
                      void (*fini) (void), 
                      void (*rtld_fini) (void), 
                      void (* stack_end));

This means we can find the address of main() when __libc_start_main() is called in the _start routine (from crt1.o).

In x86 environments, the memory address of main() will be pushed onto the stack prior to calling __libc_start_main(), but the way arguments are passed to functions depend on the calling convention implemented by the compiler, and this can vary across compiler toolchains and CPU architectures (arguments may be passed in registers instead, for example). You did not give any information regarding the CPU family the object code in your ELF binary targets (beyond the fact that the architecture is 32-bit) or the compiler used to generate the binary, or any sample disassembly, so I can't be more specific.

As far as I know, information about function parameters is not stored in the symbol table, so there is no command to list them.

At runtime, you may use info args and info locals to inspect the values of function arguments and local variables if your binary has been compiled with the -g flag.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.