From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 5/5 V2] kvm tools: Initialize and use VESA and VNC Date: Wed, 25 May 2011 12:44:20 +0200 Message-ID: <4DDCDD84.8010800@redhat.com> References: <20110523113824.GE4042@elte.hu> <4DDB6E55.8080408@redhat.com> <20110524085024.GA31453@elte.hu> <4DDB77E5.4080306@redhat.com> <20110524194019.GA27634@elte.hu> <4DDCBC08.3030507@redhat.com> <20110525083200.GF21552@elte.hu> <4DDCC8A0.8050708@redhat.com> <20110525093611.GD28500@elte.hu> <4DDCD364.9090903@redhat.com> <20110525101744.GA30983@elte.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Sasha Levin , penberg@kernel.org, john@jfloren.net, kvm@vger.kernel.org, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com To: Ingo Molnar Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1027 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab1EYKoh (ORCPT ); Wed, 25 May 2011 06:44:37 -0400 In-Reply-To: <20110525101744.GA30983@elte.hu> Sender: kvm-owner@vger.kernel.org List-ID: On 05/25/2011 12:17 PM, Ingo Molnar wrote: > Also it's not clear why ((constructor)) was written in the way it > was: why apparently no access is given to the array of init functions It is accessible---glibc uses it. > and why it's not possible to turn the auto-execution off but still > have the array generated, for legitimate cases that want to use data > driven constructor execution. The compiler doesn't care about what is done with the data. It simply provides the table for the runtime library to use it. ((constructor)) is a veneer over the same infrastructure used for C++ global constructors; that explains its design pretty well. > the ((section)) approach we could create a clear runtime > BUG_ON() assert for a zero-sized array of init function pointers, Not really. The problem is that f1.o is not pulled from the static library _because the linker thinks it is not necessary_. If f1.o defines another symbol, and f.o uses it, then the constructor is pulled in together with the rest of f.o. As soon as _one_ constructor is pulled in (even from outside the static library), your BUG() would not detect silently missing imports anymore. It turns out a way to get the semantics you want for ((section)) is to use --whole-archive (and possibly --no-whole-archive) on the "ld -r" command line. You can do the same on the link line for ((constructor)) or C++ constructors too. However, since you're effectively using a C++ feature, static libraries are probably a bad idea just like C++ static libraries are. Paolo