问题
I was debugging my program, then the last line happened, how can I fix it? I used the -fno-builtin
to have a look at the strcpy()
but it shows that the __strcpy_sse2_unaligned
is getting called.
root@19:~/booksrc# gcc -fno-builtin -g char_array2.c
root@19:~/booksrc# gdb -q ./a.out
Reading symbols from ./a.out...done.
(gdb) list
1 #include <stdio.h>
2 #include <string.h>
3
4 int main() {
5 char str_a[20];
6
7 strcpy(str_a, "Hello World!\n");
8 printf(str_a);
9 }
(gdb) break 6
Breakpoint 1 at 0x708: file char_array2.c, line 6.
(gdb) break strcpy
Breakpoint 2 at 0x5a0
(gdb) break 8
Breakpoint 3 at 0x71b: file char_array2.c, line 8.
(gdb) run
Starting program: /root/booksrc/a.out
Breakpoint 1, main () at char_array2.c:7
7 strcpy(str_a, "Hello World!\n");
(gdb) cont
Continuing.
Breakpoint 2, __strcpy_sse2_unaligned ()
at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:47
47 ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.
回答1:
__strcpy_sse2_unaligned
is the implementation of strcpy
which is used on your machine. glibc automatically chooses an optimized implementation based on CPU characteristics, using an IFUNC resolver.
This does not have to do anything with GCC and GCC built-ins. GCC emits a call to strcpy
. It is just that glibc happens to call the function which it __strcpy_sse2_unaligned
.
来源:https://stackoverflow.com/questions/47119328/strcpy-sse2-unaligned-with-fno-builtin