<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/1.5.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Linkers part 6</title>
	<link>http://www.airs.com/blog/archives/43</link>
	<description>Ian Lance Taylor</description>
	<pubDate>Wed,  8 Oct 2008 06:05:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.2</generator>

	<item>
 		<title>Comment on Linkers part 6 by: ncm</title>
		<link>http://www.airs.com/blog/archives/43#comment-4095</link>
		<pubDate>Tue, 04 Sep 2007 21:51:58 +0000</pubDate>
		<guid>http://www.airs.com/blog/archives/43#comment-4095</guid>
					<description>The optimization would have to be the default, because nobody would know about it; or, if they did, they'd need apparatus in configure to tell whether it was there and turn it on. 

Is there something unsafe about the optimization?  I suppose a program could dlopen a library that doesn't construct a type T, but uses a virtual member of T not referenced in the main program.  You'd like to get an unresolved-symbol error at dlopen time, then, just as when the library references a regular symbol that's not present.  But, you 'd also like to have a way to tell the program linker to retain unused virtuals meant to be available for use by dlopened libraries.</description>
		<content:encoded><![CDATA[	<p>The optimization would have to be the default, because nobody would know about it; or, if they did, they&#8217;d need apparatus in configure to tell whether it was there and turn it on. </p>
	<p>Is there something unsafe about the optimization?  I suppose a program could dlopen a library that doesn&#8217;t construct a type T, but uses a virtual member of T not referenced in the main program.  You&#8217;d like to get an unresolved-symbol error at dlopen time, then, just as when the library references a regular symbol that&#8217;s not present.  But, you &#8216;d also like to have a way to tell the program linker to retain unused virtuals meant to be available for use by dlopened libraries.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Linkers part 6 by: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/43#comment-4075</link>
		<pubDate>Tue, 04 Sep 2007 01:36:59 +0000</pubDate>
		<guid>http://www.airs.com/blog/archives/43#comment-4075</guid>
					<description>The current GNU linker implemented that optimization for a while, using special relocation types to indicate virtual function calls and the class heirarchy.  This information was fed into the garbage collector.  This was implemented for eCos.  I don't think anybody really uses it, though, and I don't know whether it still works correctly.

Using relocation types was the wrong approach.  It should be done using a separate side table in an unloaded section.  In any case, this optimization requires cooperation with the compiler.  It's not particularly hard to implement in the linker as part of a garbage collector to discard unreferenced sections.</description>
		<content:encoded><![CDATA[	<p>The current GNU linker implemented that optimization for a while, using special relocation types to indicate virtual function calls and the class heirarchy.  This information was fed into the garbage collector.  This was implemented for eCos.  I don&#8217;t think anybody really uses it, though, and I don&#8217;t know whether it still works correctly.</p>
	<p>Using relocation types was the wrong approach.  It should be done using a separate side table in an unloaded section.  In any case, this optimization requires cooperation with the compiler.  It&#8217;s not particularly hard to implement in the linker as part of a garbage collector to discard unreferenced sections.
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Linkers part 6 by: Mark J. Wielaard &#187; Ian Lance Taylor&#8217;s Linker Notes</title>
		<link>http://www.airs.com/blog/archives/43#comment-4028</link>
		<pubDate>Fri, 31 Aug 2007 16:22:15 +0000</pubDate>
		<guid>http://www.airs.com/blog/archives/43#comment-4028</guid>
					<description>[...] Linkers part 6 - Relocations, Position Dependent Shared Libraries. [...]</description>
		<content:encoded><![CDATA[	<p>[&#8230;] Linkers part 6 - Relocations, Position Dependent Shared Libraries. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
 		<title>Comment on Linkers part 6 by: ncm</title>
		<link>http://www.airs.com/blog/archives/43#comment-4018</link>
		<pubDate>Fri, 31 Aug 2007 08:01:51 +0000</pubDate>
		<guid>http://www.airs.com/blog/archives/43#comment-4018</guid>
					<description>I'm hoping your linker will implement the omit-uncalled-virtuals optimization, as implemented in Symantecs's linker years back.   Naive linkers see the reference to a virtual function implementation in a virtual function table, itself referenced in a constructor, and link the function even though that function cannot be called by the program.  You can tell because that offset into the vtable is never used.  You can be smarter: that offset is never used with a static &quot;this&quot; type at or below it in the derivation hierarchy.  You can be smarter yet: if the &quot;this&quot; type is below it, and that type or one on the way there provides its own implementation, that can't call yours.

It's tempting to argue that virtual functions are all in shared libraries, these days, or that program size doesn't matter any more, or that virtual functions aren't so important any more.  However, big programs and embedded programs are often linked statically, and cache/VM footprint still matters, and people still insist on making derivation hierarchies.</description>
		<content:encoded><![CDATA[	<p>I&#8217;m hoping your linker will implement the omit-uncalled-virtuals optimization, as implemented in Symantecs&#8217;s linker years back.   Naive linkers see the reference to a virtual function implementation in a virtual function table, itself referenced in a constructor, and link the function even though that function cannot be called by the program.  You can tell because that offset into the vtable is never used.  You can be smarter: that offset is never used with a static &#8220;this&#8221; type at or below it in the derivation hierarchy.  You can be smarter yet: if the &#8220;this&#8221; type is below it, and that type or one on the way there provides its own implementation, that can&#8217;t call yours.</p>
	<p>It&#8217;s tempting to argue that virtual functions are all in shared libraries, these days, or that program size doesn&#8217;t matter any more, or that virtual functions aren&#8217;t so important any more.  However, big programs and embedded programs are often linked statically, and cache/VM footprint still matters, and people still insist on making derivation hierarchies.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
