1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<think>
Okay, so I have this problem where after a git bisect, the first bad commit was identified as 37746c5eacf309fa019ea0fa45f776c36c561457. The commit message mentions adding -fstack-protector to the linker using libtool's -Wc argument because libtool was swallowing it otherwise. But now, when I run QEMU, I'm getting an undefined reference error: `qemu-1.4.0/stubs/arch-query-cpu-def.c:6: undefined reference to '__stack_chk_guard'`.
Hmm, the commit says that adding -fstack-protector was necessary, but perhaps it's not enough or there's another issue. Maybe __stack_chk_guard is part of a library I'm missing? Let me think about where this symbol comes from.
I know that __stack_chk_guard is typically provided by the compiler when using stack protection (-fstack-protector). If adding -fstack-protector didn't fix it, maybe the linker isn't getting the flag properly. Alternatively, perhaps some object files or libraries are being built without this flag, causing the missing symbol.
Wait, looking back at the commit, Marc-André Lureau added -Wc,-fstack-protector to libtool's arguments. So when libtool is compiling and linking, it should pass that flag. But in the build-sys change, maybe not all parts of QEMU are being passed this flag.
I should check if every relevant part of QEMU is built with this flag. Perhaps some Makefiles or rules aren't including it, leading to certain files like arch-query-cpu-def.c not getting the necessary stack protection.
Also, I recall that if you're using a C library like glibc, __stack_chk_guard might be in libc. But maybe the build environment is different, or perhaps static builds are causing issues where dynamic libraries aren't loaded properly, hence missing symbols.
Another thought: after bisecting to this commit, any changes after it could have fixed the issue, but since this is the first bad commit, I'm likely on a system that's now missing something because of how stack protection was applied. Maybe there's an error in how the flag is passed or where it's being applied.
I should verify if all binaries and shared libraries are built with -fstack-protector. Perhaps certain parts were overlooked, leading to some components not including __stack_chk_guard.
Additionally, I could try rebuilding after this commit but explicitly ensuring that every target (like qemu-system-x86) is built with the necessary flags. Maybe adding export CFLAGS and LDFLAGS in the environment variables might help pass along the flags correctly.
Alternatively, perhaps the way libtool handles -Wc isn't propagating the flag to all invocations, so a more direct approach to set the linker's stack protection would be needed, like adding it to LDFLAGS in the Makefile.
Wait, maybe the commit didn't cover all build configurations. For example, if some parts of QEMU use their own Makefiles not handled by libtool, they might not receive the -fstack-protector flag. That could explain why __stack_chk_guard is undefined in certain files.
I think I should check the configure script and make sure it's passing the necessary flags everywhere. Also, perhaps running a make clean and then rebuilding with verbose options would help identify if all components are getting the correct compiler and linker flags.
Another angle: the error points to arch-query-cpu-def.c. Maybe that specific file isn't being compiled with -fstack-protector. I should check which Makefile builds this file and ensure it's including the stack protection flag.
Alternatively, maybe there's a missing dependency or an older version of a library that doesn't include __stack_chk_guard when built without proper flags. But since the commit was about adding those flags, perhaps it's a build configuration issue rather than a missing package.
I could also try compiling QEMU with more debug output to see exactly which files are being compiled with which flags and ensure that all relevant parts have -fstack-protector.
In summary, the problem arises because after applying the commit that adds -fstack-protector via libtool's -Wc argument, some components aren't receiving the flag correctly, leading to a missing symbol. To fix this, I need to verify that every part of QEMU is built with the necessary stack protection flags and that __stack_chk_guard is properly provided by all compiled objects and libraries.
</think>
The issue arises because the commit adds `-fstack-protector` via libtool's `-Wc`, but not all parts of QEMU receive this flag, causing `__stack_chk_guard` to be undefined. To fix this:
1. **Check Build Flags**: Ensure every target (e.g., qemu-system-x86) is built with `-fstack-protector`. Verify Makefiles and configure scripts pass these flags.
2. **Rebuild**: Perform a clean build with verbose options to confirm all components use the correct flags.
3. **Modify Configuration if Needed**: If some parts aren't covered by libtool, update their Makefiles or environment variables to include `-fstack-protector`.
**Answer:** Ensure all QEMU components are built with `-fstack-protector` by verifying build configurations and rebuilding to fix the undefined symbol error.
|