<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://webfault.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Michael VERGOZ - glibc</title>
  <link>http://webfault.org/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Wed, 25 Mar 2009 17:59:15 +0000</pubDate>
  <copyright>Copyright 2007 - Michael Vergoz</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>GCC et le SSP</title>
    <link>http://webfault.org/post/2007/09/14/Test</link>
    <guid isPermaLink="false">urn:md5:78d3cfc1b8c8d4dc043046f56f6056b6</guid>
    <pubDate>Fri, 14 Sep 2007 15:48:00 +0000</pubDate>
    <dc:creator>Michael Vergoz</dc:creator>
        <category>Portage / Cross dev</category>
        <category>GCC</category><category>glibc</category><category>SSP</category>    
    <description>    &lt;p&gt;Depuis la version 2.4 de la &lt;a href=&quot;http://webfault.org/index.php?tag/glibc&quot;&gt;glibc&lt;/a&gt; des symboles de controle ( comme __stack_chk_fail ) sont intégrés par defaut dans tous les binaires compilés.
C'est le &lt;a href=&quot;http://webfault.org/index.php?tag/SSP&quot;&gt;SSP&lt;/a&gt; dans &lt;a href=&quot;http://webfault.org/index.php?tag/GCC&quot;&gt;GCC&lt;/a&gt; qui est responsable de cette action et il est possible de désactiver ce &lt;a href=&quot;http://webfault.org/index.php?tag/SSP&quot;&gt;SSP&lt;/a&gt; avec l'option &lt;strong&gt;-fno-stack-protector&lt;/strong&gt;.&lt;/p&gt;


&lt;p&gt;Un petit code C comme exemple&amp;nbsp;:&lt;/p&gt;
&lt;code class=&quot;c&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #339933;&quot;&gt;#include &amp;lt;pthread.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pthread_mutex_t fastmutex = PTHREAD_MUTEX_INITIALIZER;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pthread_mutex_lock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;fastmutex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Tst&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pthread_mutex_unlock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;fastmutex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;


&lt;p&gt;Ensuite on teste&amp;nbsp;:&lt;/p&gt;
&lt;pre&gt;
none@zef:~# gcc -O2 -o test.bin test.c
none@zef:~# readelf -a test.bin | grep _stack_
080496c8  00000507 R_386_JUMP_SLOT   00000000   __stack_chk_fail
     5: 00000000    70 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@GLIBC_2.4 (3)
    75: 00000000    70 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@@GLIBC_2
none@zef:~# gcc -O2 -fno-stack-protector -o test.bin test.c
none@zef:~# readelf -a test.bin | grep _stack_
none@zef:~# 
&lt;/pre&gt;


&lt;p&gt;Ca rend de fait portable le binaire pour des glibc &amp;gt; 2.3 :)&lt;/p&gt;

&lt;pre&gt;
none@zef:~# file /lib/libc-2.5.so
/lib/libc-2.5.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, stripped
none@zef:~# gcc -O2 -o test.bin test.c
none@zef:~# readelf -a test.bin | grep -i GLIBC_2.4
     5: 00000000    70 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@GLIBC_2.4 (3)
  004:   2 (GLIBC_2.0)     3 (GLIBC_2.4)     2 (GLIBC_2.0)     1 (*global*)
  0x0010:   Name: GLIBC_2.4  Flags: none  Version: 3
none@zef:~# gcc -O2 -fno-stack-protector -o test.bin test.c
none@zef:~# readelf -a test.bin | grep -i GLIBC_2.4
none@zef:~#
&lt;/pre&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>