<?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 - GCC</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>Compiler depuis un x86 vers un x86_64 avec GCC</title>
    <link>http://webfault.org/post/2007/09/14/Compiler-depuis-un-x86-vers-un-x86_64-avec-GCC</link>
    <guid isPermaLink="false">urn:md5:6c72938397aec219e076d5e6a6fcd1da</guid>
    <pubDate>Fri, 14 Sep 2007 16:19:00 +0000</pubDate>
    <dc:creator>Michael Vergoz</dc:creator>
        <category>Portage / Cross dev</category>
        <category>ARM</category><category>ELF</category><category>GCC</category><category>x86</category><category>x86_64</category>    
    <description>    &lt;p&gt;Au départ je pensais que la compilation d'un fichier &lt;a href=&quot;http://webfault.org/index.php?tag/ELF&quot;&gt;ELF&lt;/a&gt; &lt;a href=&quot;http://webfault.org/index.php?tag/x86_64&quot;&gt;x86_64&lt;/a&gt; puis un &lt;a href=&quot;http://webfault.org/index.php?tag/x86&quot;&gt;x86&lt;/a&gt; demandait forcément une cross compilation (CBUILD) d'un toolchain x86_64. Et en fait pas du tout, visiblement &lt;a href=&quot;http://webfault.org/index.php?tag/GCC&quot;&gt;GCC&lt;/a&gt; intégre par défaut la possibilité de compiler vers un x86_64 depuis un x86 (et inversement) par contre pour changer totalement de processeur, typiquement de l'&lt;a href=&quot;http://webfault.org/index.php?tag/ARM&quot;&gt;ARM&lt;/a&gt;, il est nécessaire de cross compiler des toolchain et là c'est pas la même histoire...&lt;/p&gt;


&lt;p&gt;Un petit test :&lt;/p&gt;
&lt;pre&gt;root@zef:~# gcc -o test.bin test.c -m64
root@zef:~# file test.bin
test.bin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), not stripped
root@zef:~# gcc -o test.bin test.c -m32
root@zef:~# file test.bin
test.bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), not stripped&lt;/pre&gt;


&lt;p&gt;Il faut savoir un truc c'est que ça ne fonctionne pas toujours. Par exemple si vous voulez compiler Apache 1.3 depuis un x86 vers du x86_64 eh bien cela ne sera pas possible car le Makefile d'Apache peut compiler des fichiers puis les executer pendant la compilation.
La solution c'est d'avoir un CHOST x86_64 + support lib32 qui compile pour du x86_64 et x86.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <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>