19

I am compiling the simple code below, and run it in gdb. I set a break point at the strcpy line, as soon as I run it for the input for instance abc, and then press s, I get the following error:

Breakpoint 1, main (argc=2, argv=0x7fffffffdd98) at ExploitMe.c:9
9           strcpy(buffer, argv[1]);
(gdb) s
__strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:48
48  ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.

I am using ubuntu 12.04 AMD64 and gcc 2.15. Any idea?


main(int argc, char *argv[]) {

    char buffer[80];

    strcpy(buffer, argv[1]);

    return 0;
}
6
  • 3
    That's not an error - gdb can't find the source file for the strcpy implementation but it will still display the disassembled code.
    – Paul R
    Dec 20, 2012 at 18:59
  • yes, I noticed that, but why? and any idea how to solve it?
    – Afshin
    Dec 20, 2012 at 19:03
  • 1
    Not sure why this was downvoted...
    – user541686
    Dec 20, 2012 at 19:04
  • 2
    The debugger doesn't have the source. That's all. Dec 20, 2012 at 19:20
  • 1
    Install the glibc source code, and tell gdb where it's installed (ofb.net/gnu/gdb/gdb_49.html) Interesting filename on the source file... ;) Dec 20, 2012 at 19:24

1 Answer 1

21

It is completely harmless to ignore these "errors" when debugging.

The error is simply because GDB is looking for the source of the strcpy function. Any function in libc that you don't have the source for will you give a similar error, e.g.:

int *p = malloc(sizeof *p);

Then...

(gdb) s
5       int *p = malloc(sizeof *p);
(gdb) s
__GI___libc_malloc (bytes=4) at malloc.c:2910
2910    malloc.c: No such file or directory.

You can always download GNU libc's source and link it with GDB:

git clone https://github.com/jeremie-koenig/glibc /opt/src/glibc

Then...

(gdb) dir /opt/src/glibc/malloc
(gdb) s
5       int *p = malloc(sizeof *p);
(gdb) s
__GI___libc_malloc (bytes=4) at malloc.c:2910
2910              }
(gdb) s
2915          } else if (!in_smallbin_range(size))

... which will let you step through malloc's source code. It's not particularly useful, but it can come in handy sometimes.

2
  • 1
    Just make sure that you copy the SAME VERSION as you are using on the system. The latest, which is what you get from git clone, is perhaps not what is installed on your system (and may not be the best idea either!) Dec 20, 2012 at 21:05
  • 1
    Just as a quick reminder, if you are using gdb you can use n (for next) to skip over lines with those function calls.
    – Sum
    Feb 10, 2014 at 20:10

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.