* [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list
@ 2015-03-11 17:10 Joseph Hindin
2015-03-11 19:59 ` Stefan Weil
0 siblings, 1 reply; 4+ messages in thread
From: Joseph Hindin @ 2015-03-11 17:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Joseph Hindin, mdroth
When building qga-bss.dll with 64-bit mingw toolchain v. 4.9.2, the
qga-vss.dll linking fails with unresolved symbols from libssp,
stack protection support, like the following message:
.../qga/vss-win32/install.cpp:52: undefined reference to `__stack_chk_fail'
The patch fixes the problem by adding libssp to the qga-vss.dll
libraries list.
Signed-off-by: Joseph Hindin <jhindin@daynix.com>
---
qga/vss-win32/Makefile.objs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qga/vss-win32/Makefile.objs b/qga/vss-win32/Makefile.objs
index 6a69d50..bd0840d 100644
--- a/qga/vss-win32/Makefile.objs
+++ b/qga/vss-win32/Makefile.objs
@@ -5,7 +5,7 @@ qga-vss-dll-obj-y += requester.o provider.o install.o
obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
$(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor
-$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static
+$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -lssp -static
$(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y) $(SRC_PATH)/$(obj)/qga-vss.def
$(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y) $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list
2015-03-11 17:10 [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list Joseph Hindin
@ 2015-03-11 19:59 ` Stefan Weil
2015-03-12 14:08 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2015-03-11 19:59 UTC (permalink / raw)
To: Joseph Hindin, qemu-devel; +Cc: Michael Roth, Tomoki Sekiyama
Am 11.03.2015 um 18:10 schrieb Joseph Hindin:
> When building qga-bss.dll with 64-bit mingw toolchain v. 4.9.2, the
Typo: qga-vss.dll
> qga-vss.dll linking fails with unresolved symbols from libssp,
> stack protection support, like the following message:
>
> .../qga/vss-win32/install.cpp:52: undefined reference to `__stack_chk_fail'
>
> The patch fixes the problem by adding libssp to the qga-vss.dll
> libraries list.
>
> Signed-off-by: Joseph Hindin <jhindin@daynix.com>
> ---
> qga/vss-win32/Makefile.objs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qga/vss-win32/Makefile.objs b/qga/vss-win32/Makefile.objs
> index 6a69d50..bd0840d 100644
> --- a/qga/vss-win32/Makefile.objs
> +++ b/qga/vss-win32/Makefile.objs
> @@ -5,7 +5,7 @@ qga-vss-dll-obj-y += requester.o provider.o install.o
> obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
> $(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor
>
> -$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static
> +$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -lssp -static
> $(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y) $(SRC_PATH)/$(obj)/qga-vss.def
> $(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y) $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
>
Adding -lssp works, but adding -fstack-protector-all to the linker flags
also works and might be the better solution.
-$(obj)/qga-vss.dll: LDFLAGS = -shared
-Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
-lshlwapi -luuid -static
+$(obj)/qga-vss.dll: LDFLAGS = -fstack-protector-all -shared
-Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
-lshlwapi -luuid -static
Could you please try that and send an updated patch? Please cc it also
to qemu-trivial.
Regards
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list
2015-03-11 19:59 ` Stefan Weil
@ 2015-03-12 14:08 ` Paolo Bonzini
2015-03-12 21:31 ` Stefan Weil
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-03-12 14:08 UTC (permalink / raw)
To: Stefan Weil, Joseph Hindin, qemu-devel; +Cc: Michael Roth, Tomoki Sekiyama
On 11/03/2015 20:59, Stefan Weil wrote:
> Am 11.03.2015 um 18:10 schrieb Joseph Hindin:
>> When building qga-bss.dll with 64-bit mingw toolchain v. 4.9.2, the
>
> Typo: qga-vss.dll
>
>> qga-vss.dll linking fails with unresolved symbols from libssp,
>> stack protection support, like the following message:
>>
>> .../qga/vss-win32/install.cpp:52: undefined reference to
>> `__stack_chk_fail'
>>
>> The patch fixes the problem by adding libssp to the qga-vss.dll
>> libraries list.
>>
>> Signed-off-by: Joseph Hindin <jhindin@daynix.com>
>> ---
>> qga/vss-win32/Makefile.objs | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/qga/vss-win32/Makefile.objs b/qga/vss-win32/Makefile.objs
>> index 6a69d50..bd0840d 100644
>> --- a/qga/vss-win32/Makefile.objs
>> +++ b/qga/vss-win32/Makefile.objs
>> @@ -5,7 +5,7 @@ qga-vss-dll-obj-y += requester.o provider.o install.o
>> obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
>> $(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out
>> -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
>> -Wold-style-declaration -Wold-style-definition -Wredundant-decls
>> -fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas
>> -Wno-delete-non-virtual-dtor
>> -$(obj)/qga-vss.dll: LDFLAGS = -shared
>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>> -lshlwapi -luuid -static
>> +$(obj)/qga-vss.dll: LDFLAGS = -shared
>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>> -lshlwapi -luuid -lssp -static
>> $(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y)
>> $(SRC_PATH)/$(obj)/qga-vss.def
>> $(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y)
>> $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS)," LINK
>> $(TARGET_DIR)$@")
>>
>
> Adding -lssp works, but adding -fstack-protector-all to the linker flags
> also works and might be the better solution.
>
> -$(obj)/qga-vss.dll: LDFLAGS = -shared
> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
> -lshlwapi -luuid -static
> +$(obj)/qga-vss.dll: LDFLAGS = -fstack-protector-all -shared
> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
> -lshlwapi -luuid -static
>
> Could you please try that and send an updated patch? Please cc it also
> to qemu-trivial.
Actually it's not trivial...
There is already an attempt to avoid the stack protector in
qga/vss-win32/Makefile.objs:
$(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out -Wstrict-prototypes \
-Wmissing-prototypes -Wnested-externs -Wold-style-declaration \
-Wold-style-definition -Wredundant-decls -fstack-protector-all, \
$(QEMU_CFLAGS)) -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor
Perhaps you're using -fstack-protector-strong, and so the above line
should use "-fstack-protector%"?
Instead, if using the stack protector is fine, -fstack-protector-all
should not be filtered out in the above line.
In that case, I agree with Stefan that using -f is cleaner than -lssp,
but it's even cleaner to make the flags match (i.e. it's unclean to
have -fstack-protector-strong in the CFLAGS and -fstack-protector-all
in the LDFLAGS). So I'd do something like this to get the right flag:
diff --git a/configure b/configure
index 7ba4bcb..0e84b22 100755
--- a/configure
+++ b/configure
@@ -1510,6 +1510,7 @@ if test "$stack_protector" != "no"; then
# setups fail only on a .c->.o compile and some only at link time
if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
compile_prog "-Werror $flag" ""; then
+ stack_protector=$flag
QEMU_CFLAGS="$QEMU_CFLAGS $flag"
LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
sp_on=1
@@ -5003,6 +5004,7 @@ echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
echo "LIBS+=$LIBS" >> $config_host_mak
echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
+echo "STACK_PROTECTOR_FLAG=$stack_protector" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $config_host_mak
echo "DSOSUF=$DSOSUF" >> $config_host_mak
echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
and then use it in qga/vss-win32/Makefile.objs.
Thanks,
Paolo
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list
2015-03-12 14:08 ` Paolo Bonzini
@ 2015-03-12 21:31 ` Stefan Weil
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Weil @ 2015-03-12 21:31 UTC (permalink / raw)
To: Paolo Bonzini, Joseph Hindin, qemu-devel; +Cc: Michael Roth, Tomoki Sekiyama
Am 12.03.2015 um 15:08 schrieb Paolo Bonzini:
>
> On 11/03/2015 20:59, Stefan Weil wrote:
>> Am 11.03.2015 um 18:10 schrieb Joseph Hindin:
>>> When building qga-bss.dll with 64-bit mingw toolchain v. 4.9.2, the
>> Typo: qga-vss.dll
>>
>>> qga-vss.dll linking fails with unresolved symbols from libssp,
>>> stack protection support, like the following message:
>>>
>>> .../qga/vss-win32/install.cpp:52: undefined reference to
>>> `__stack_chk_fail'
>>>
>>> The patch fixes the problem by adding libssp to the qga-vss.dll
>>> libraries list.
>>>
>>> Signed-off-by: Joseph Hindin <jhindin@daynix.com>
>>> ---
>>> qga/vss-win32/Makefile.objs | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/qga/vss-win32/Makefile.objs b/qga/vss-win32/Makefile.objs
>>> index 6a69d50..bd0840d 100644
>>> --- a/qga/vss-win32/Makefile.objs
>>> +++ b/qga/vss-win32/Makefile.objs
>>> @@ -5,7 +5,7 @@ qga-vss-dll-obj-y += requester.o provider.o install.o
>>> obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
>>> $(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out
>>> -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
>>> -Wold-style-declaration -Wold-style-definition -Wredundant-decls
>>> -fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas
>>> -Wno-delete-non-virtual-dtor
>>> -$(obj)/qga-vss.dll: LDFLAGS = -shared
>>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>>> -lshlwapi -luuid -static
>>> +$(obj)/qga-vss.dll: LDFLAGS = -shared
>>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>>> -lshlwapi -luuid -lssp -static
>>> $(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y)
>>> $(SRC_PATH)/$(obj)/qga-vss.def
>>> $(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y)
>>> $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS)," LINK
>>> $(TARGET_DIR)$@")
>>>
>> Adding -lssp works, but adding -fstack-protector-all to the linker flags
>> also works and might be the better solution.
>>
>> -$(obj)/qga-vss.dll: LDFLAGS = -shared
>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>> -lshlwapi -luuid -static
>> +$(obj)/qga-vss.dll: LDFLAGS = -fstack-protector-all -shared
>> -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
>> -lshlwapi -luuid -static
>>
>> Could you please try that and send an updated patch? Please cc it also
>> to qemu-trivial.
> Actually it's not trivial...
>
> There is already an attempt to avoid the stack protector in
> qga/vss-win32/Makefile.objs:
>
> $(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out -Wstrict-prototypes \
> -Wmissing-prototypes -Wnested-externs -Wold-style-declaration \
> -Wold-style-definition -Wredundant-decls -fstack-protector-all, \
> $(QEMU_CFLAGS)) -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor
>
> Perhaps you're using -fstack-protector-strong, and so the above line
> should use "-fstack-protector%"?
>
> Instead, if using the stack protector is fine, -fstack-protector-all
> should not be filtered out in the above line.
>
> In that case, I agree with Stefan that using -f is cleaner than -lssp,
> but it's even cleaner to make the flags match (i.e. it's unclean to
> have -fstack-protector-strong in the CFLAGS and -fstack-protector-all
> in the LDFLAGS). So I'd do something like this to get the right flag:
>
> diff --git a/configure b/configure
> index 7ba4bcb..0e84b22 100755
> --- a/configure
> +++ b/configure
> @@ -1510,6 +1510,7 @@ if test "$stack_protector" != "no"; then
> # setups fail only on a .c->.o compile and some only at link time
> if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
> compile_prog "-Werror $flag" ""; then
> + stack_protector=$flag
> QEMU_CFLAGS="$QEMU_CFLAGS $flag"
> LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
> sp_on=1
> @@ -5003,6 +5004,7 @@ echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
> echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak
> echo "LIBS+=$LIBS" >> $config_host_mak
> echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
> +echo "STACK_PROTECTOR_FLAG=$stack_protector" >> $config_host_mak
> echo "EXESUF=$EXESUF" >> $config_host_mak
> echo "DSOSUF=$DSOSUF" >> $config_host_mak
> echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
>
>
> and then use it in qga/vss-win32/Makefile.objs.
>
> Thanks,
>
> Paolo
Indeed, it's not trivial. Builds for Windows obviously are never
trivial. :-(
My previous experience was gained with a Debian Jessie hosted cross build.
Now I have cross built on my standard environment with Debian Wheezy,
and there these modifications were needed:
diff --git a/qga/vss-win32/Makefile.objs b/qga/vss-win32/Makefile.objs
index 6a69d50..c501738 100644
--- a/qga/vss-win32/Makefile.objs
+++ b/qga/vss-win32/Makefile.objs
@@ -3,7 +3,7 @@
qga-vss-dll-obj-y += requester.o provider.o install.o
obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
-$(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
-Wold-style-declaration -Wold-style-definition -Wredundant-decls
-fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas
-Wno-delete-non-virtual-dtor
+$(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out
-Wno-override-init -Wstrict-prototypes -Wmissing-prototypes
-Wnested-externs -Wold-style-declaration -Wold-style-definition
-Wredundant-decls -fstack-protector-all, $(QEMU_CFLAGS))
-Wno-unknown-pragmas
$(obj)/qga-vss.dll: LDFLAGS = -shared
-Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32
-lshlwapi -luuid -static
$(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y)
$(SRC_PATH)/$(obj)/qga-vss.def
diff --git a/rules.mak b/rules.mak
index 7738121..bad44ba 100644
--- a/rules.mak
+++ b/rules.mak
@@ -102,7 +102,11 @@ endif
%.o: %.dtrace
$(call quiet-command,dtrace -o $@ -G -s $<, " GEN $(TARGET_DIR)$@")
+ifdef CONFIG_WIN32
+%$(DSOSUF): CFLAGS += -DBUILD_DSO
+else
%$(DSOSUF): CFLAGS += -fPIC -DBUILD_DSO
+endif
%$(DSOSUF): LDFLAGS += $(LDFLAGS_SHARED)
%$(DSOSUF): %.mo
$(call LINK,$^)
Nothing with stack protection, but some compiler flags had to be removed...
Stefan
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-12 21:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-11 17:10 [Qemu-devel] [PATCH] windows build: -lssp added to qga-vss.dll libraries list Joseph Hindin
2015-03-11 19:59 ` Stefan Weil
2015-03-12 14:08 ` Paolo Bonzini
2015-03-12 21:31 ` Stefan Weil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.