How to find out the location of a function compiled by a compiler

I am trying to change glibc for use with my program. I wanted to add code to the mmap function (not the mmap system call, but the function in glibc that makes the mmap system call). However, I see several mmap or mmap64.c files inside the source code directory.

My architecture is x86-64, so I ignored the files in another architecture directory. However, I do not know mmap from which the compiler uses the file. I intentionally inserted some garbage code (so that the compiler gives an error) in different files containing the mmap function, but the compiler compiles glibc in order without giving any errors. I even see .o files. I have no idea what to do. Any easy way to determine which mmap compiler compiler is compiling?

+3
source share
2 answers

Any easy way to determine which mmap compiler is compiling?

gdb -q libc.so.6

Reading symbols from /tmp/build/libc.so.6...done.
(gdb) list mmap
76  #else
77  
78  /* This is a "normal" system call stub: if there is an error,
79     it returns -1 and sets errno.  */
80  
81  T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
82      ret
83  T_PSEUDO_END (SYSCALL_SYMBOL)
84  
85  #endif
(gdb) info source
Current source file is ../sysdeps/unix/syscall-template.S
Compilation directory is /glibc-git-rw/glibc/misc
Located in /glibc-git-rw/glibc/sysdeps/unix/syscall-template.S <<< You want this
Contains 87 lines.
Source language is asm.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
+2
source

There may be some linker (ld) options that may help you. Look at the manual page ld, --print-map, or --trace, or --trace-character should help you. After you receive the object file, you can find the corresponding header file.

0
source

All Articles