1.Linuxä¸ç交åç¼è¯ç¯å¢è®¾ç½®
2.如何用lde
3.å¦ä½ä¸ºåµå
¥å¼å¼å建ç«äº¤åç¼è¯ç¯å¢
Linuxä¸ç交åç¼è¯ç¯å¢è®¾ç½®
éç¨äº¤åç¼è¯ç主è¦åå å¨äºï¼å¤æ°åµå ¥å¼ç®æ ç³»ç»ä¸è½æä¾è¶³å¤çèµæºä¾ç¼è¯è¿ç¨ä½¿ç¨ï¼å èåªå¥½å°ç¼è¯å·¥ç¨è½¬ç§»å°é«æ§è½ç主æºä¸è¿è¡ã
linuxä¸ç交åç¼è¯ç¯å¢éè¦å æ¬ä»¥ä¸å 个é¨åï¼
1.对ç®æ ç³»ç»çç¼è¯å¨gcc
2.对ç®æ ç³»ç»çäºè¿å¶å·¥å ·binutils
3.ç®æ ç³»ç»çæ åcåºglibc
4.ç®æ ç³»ç»çlinuxå æ ¸å¤´æ件
交åç¼è¯ç¯å¢ç建ç«æ¥éª¤
ä¸ãä¸è½½æºä»£ç ä¸è½½å æ¬binutilsãgccãglibcålinuxå æ ¸çæºä»£ç ï¼éè¦æ³¨æçæ¯ï¼glibcåå æ ¸æºä»£ç ççæ¬å¿ é¡»ä¸ç®æ æºä¸å®é 使ç¨ççæ¬ä¿æä¸è´ï¼ï¼å¹¶è®¾å®shellåéPREFIXæå®å¯æ§è¡ç¨åºçå®è£ è·¯å¾ã
äºãç¼è¯binutils é¦å è¿è¡configureæ件ï¼å¹¶ä½¿ç¨--prefix=$PREFIXåæ°æå®å®è£ è·¯å¾ï¼ä½¿ç¨--target=arm-linuxåæ°æå®ç®æ æºç±»åï¼ç¶åæ§è¡make installã
ä¸ãé ç½®linuxå æ ¸å¤´æ件
é¦å æ§è¡make mrproperè¿è¡æ¸ çå·¥ä½ï¼ç¶åæ§è¡make config ARCH=armï¼æmake menuconfig/xconfig ARCH=armï¼è¿è¡é ç½®ï¼æ³¨æï¼ä¸å®è¦å¨å½ä»¤è¡ä¸ä½¿ç¨ARCH=armæå®cpuæ¶æï¼å 为缺çæ¶æ为主æºçcpuæ¶æï¼ï¼è¿ä¸æ¥éè¦æ ¹æ®ç®æ æºçå®é æ åµè¿è¡è¯¦ç»çé ç½®ï¼ç¬è è¿è¡çå®éªä¸ç®æ æºä¸ºHPçipaq-hp PDAï¼å è设置system type为SAX0ï¼SAX0 Implementationsä¸éæ©Compaq iPAQ H/Hã
é ç½®å®æä¹åï¼éè¦å°å æ ¸å¤´æ件æ·è´å°å®è£ ç®å½ï¼ cp -dR include/asm-arm $PREFIX/arm-linux/include/asm cp -dR include/linux $PREFIX/arm-linux/include/linux
åã第ä¸æ¬¡ç¼è¯gcc
é¦å è¿è¡configureæ件ï¼ä½¿ç¨--prefix=$PREFIXåæ°æå®å®è£ è·¯å¾ï¼ä½¿ç¨--target=arm-linuxåæ°æå®ç®æ æºç±»åï¼å¹¶ä½¿ç¨--disable-threadsã--disable-sharedã--enable-languages=cåæ°ï¼ç¶åæ§è¡make installãè¿ä¸æ¥å°çæä¸ä¸ªæç®çgccãç±äºç¼è¯æ´ä¸ªgccæ¯éè¦ç®æ æºçglibcåºçï¼å®ç°å¨è¿ä¸åå¨ï¼å æ¤éè¦é¦å çæä¸ä¸ªæç®çgccï¼å®åªéè¦å ·å¤ç¼è¯ç®æ æºglibcåºçè½åå³å¯ã
äºã交åç¼è¯glibc
è¿ä¸æ¥éª¤çæç代ç æ¯é对ç®æ æºcpuçï¼å æ¤å®å±äºä¸ä¸ªäº¤åç¼è¯è¿ç¨ã该è¿ç¨è¦ç¨å°linuxå æ ¸å¤´æ件ï¼é»è®¤è·¯å¾ä¸º$PREFIX/arm-linux/sys-linuxï¼å èéè¦å¨$PREFIX/arm-linuxä¸å»ºç«ä¸ä¸ªå为sys-linuxç软è¿æ¥ï¼ä½¿å ¶å æ ¸å¤´æ件æå¨çincludeç®å½ï¼æè ï¼ä¹å¯ä»¥å¨æ¥ä¸æ¥è¦æ§è¡çconfigureå½ä»¤ä¸ä½¿ç¨--with-headersåæ°æå®linuxå æ ¸å¤´æ件çå®é è·¯å¾ã
configureçè¿è¡åæ°è®¾ç½®å¦ä¸ï¼å 为æ¯äº¤åç¼è¯ï¼æ以è¦å°ç¼è¯å¨åéCC设为arm-linux-gccï¼ï¼ CC=arm-linux-gcc ./configure --prefix=$PREFIX/arm-linux --host=arm-linux --enable-add-ons æåï¼æ以ä¸é ç½®æ§è¡configureåmake installï¼glibcç交åç¼è¯è¿ç¨å°±ç®å®æäºï¼è¿ééè¦æåºçæ¯ï¼glibcçå®è£ è·¯å¾è®¾ç½®ä¸º$PREFIXARCH=arm/arm-linuxï¼å¦ææ¤å¤è®¾ç½®ä¸å½ï¼ç¬¬äºæ¬¡ç¼è¯gccæ¶å¯è½æ¾ä¸å°glibcç头æ件ååºã
å ã第äºæ¬¡ç¼è¯gcc
è¿è¡configureï¼åæ°è®¾ç½®ä¸º--prefix=$PREFIX --target=arm-linux --enable-languages=c,源码c++ã
è¿è¡make installã
å°æ¤ä¸ºæ¢æ´ä¸ªäº¤åç¼è¯ç¯å¢å°±å®å ¨çæäºã
å ç¹æ³¨æäºé¡¹
第ä¸ç¹ãå¨ç¬¬ä¸æ¬¡ç¼è¯gccçæ¶åå¯è½ä¼åºç°æ¾ä¸å°stdio.hçé误ï¼è§£å³åæ³æ¯ä¿®æ¹gcc/config/arm/t-linuxæ件ï¼å¨TARGET_LIBGCC2_CFLAGSåéç设å®ä¸å¢å -Dinhibit_libcå-D__gthr_posix_hã
如何用lde
在编程和软件开发中,`lde`并不是解读一个通用的术语或命令。可能你是源码指`ld`,它是解读手机行业网站源码GNU Binutils中的一个程序,用于链接程序。源码详细解释如下:
`ld`是解读有趣源码GNU链接器的缩写,它是源码GNU Binutils软件包的一部分。链接器的解读主要作用是将多个对象文件和一些必要的库文件链接成一个可执行文件。在这个过程中,源码链接器会处理对象文件中的解读符号引用,确保所有的源码函数调用、变量访问等都正确地指向它们在可执行文件中的解读位置。
在编译和链接一个程序时,源码iapp的源码通常首先使用编译器将源代码文件编译成对象文件,解读然后使用`ld`将这些对象文件链接成一个可执行文件。源码链接器还可以用来创建共享库,asp 网站 源码这是多个程序可以共享的代码和数据的集合。
`ld`链接器具有许多选项和参数,可以用来控制链接过程的asp源码的网站各种方面。例如,可以使用选项来指定要链接的对象文件和库文件,控制符号解析的方式,以及指定生成的可执行文件或共享库的各种属性。
总的来说,`ld`是GNU Binutils中的一个重要程序,用于将对象文件和库文件链接成可执行文件或共享库。在软件开发过程中,了解和使用`ld`链接器的功能和选项是非常重要的。
å¦ä½ä¸ºåµå ¥å¼å¼å建ç«äº¤åç¼è¯ç¯å¢
ããä¸é¢æ们å°ä»¥å»ºç«é对armç交åç¼è¯å¼åç¯å¢ä¸ºä¾æ¥è§£è¯´æ´ä¸ªè¿ç¨ï¼å ¶ä»çä½ç³»ç»æä¸è¿ä¸ªç¸ç±»ä¼¼ï¼åªè¦ä½ä¸äºå¯¹åºçæ¹å¨ãæçå¼åç¯å¢æ¯ï¼å®¿ä¸»æº i-redhat-7.2ï¼ç®æ æº armã
ããè¿ä¸ªè¿ç¨å¦ä¸
ãã1. ä¸è½½æºæ件ãè¡¥ä¸å建ç«ç¼è¯çç®å½
ãã2. 建ç«å æ ¸å¤´æ件
ãã3. 建ç«äºè¿å¶å·¥å ·ï¼binutilsï¼
ãã4. 建ç«åå§ç¼è¯å¨ï¼bootstrap gccï¼
ãã5. 建ç«cåº(glibc)
ãã6. 建ç«å ¨å¥ç¼è¯å¨ï¼full gccï¼
ããä¸è½½æºæ件ãè¡¥ä¸å建ç«ç¼è¯çç®å½
ãã1. éå®è½¯ä»¶çæ¬å·
ããéæ©è½¯ä»¶çæ¬å·æ¶ï¼å ççglibcæºä»£ç ä¸çINSTALLæ件ãé£éå举äºè¯¥çæ¬çglibcç¼è¯æ¶æéçbinutils ågccççæ¬å·ãä¾å¦å¨ glibc-2.2.3/INSTALL æ件ä¸æ¨è gcc ç¨ 2.以ä¸ï¼binutils ç¨ 2..1 以ä¸çæ¬ã
ããæéçå个软件ççæ¬æ¯ï¼
ããlinux-2.4.+rmk2
ããbinutils-2..1
ããgcc-2..3
ããglibc-2.2.3
ããglibc-linuxthreads-2.2.3
ããå¦æä½ éçglibcççæ¬å·ä½äº2.2ï¼ä½ è¿è¦ä¸è½½ä¸ä¸ªå«glibc-cryptçæ件ï¼ä¾å¦glibc-crypt-2.1.tar.gzã Linux å æ ¸ä½ å¯ä»¥ä»www.kernel.org æå®çéåä¸è½½ã
ããBinutilsãgccåglibcä½ å¯ä»¥ä»FSFçFTPç«ç¹ftp://ftp.gun.org/gnu/ æå®çéåå»ä¸è½½ã å¨ç¼è¯glibcæ¶ï¼è¦ç¨å° Linux å æ ¸ä¸ç include ç®å½çå æ ¸å¤´æ件ãå¦æä½ åç°æåé没æå®ä¹è导è´ç¼è¯å¤±è´¥ï¼ä½ å°±æ¹åä½ çå æ ¸çæ¬å·ãä¾å¦æå¼å§ç¨linux-2.4.+vrs2ï¼ç¼è¯glibc-2.2.3 æ¶æ¥ BUS_ISA 没å®ä¹ï¼åæ¥åç°å¨ 2.4. å¼å§å®çåå被æ¹ä¸º CTL_BUS_ISAãå¦æä½ æ²¡æå®å ¨çææ¡ä¿è¯ä½ æ¹çå æ ¸æ¹å®å ¨äºï¼å°±ä¸è¦å¨å æ ¸ï¼èæ¯æä½ ç Linux å æ ¸ççæ¬å·éä½æåé«ï¼æ¥éåº glibcã
ããGcc ççæ¬å·ï¼æ¨èç¨ gcc-2. 以ä¸çã太èççæ¬ç¼è¯å¯è½ä¼åºé®é¢ãGcc-2..3 æ¯ä¸ä¸ªæ¯è¾ç¨³å®ççæ¬ï¼ä¹æ¯å æ ¸å¼å人åæ¨èç¨çä¸ä¸ª gcc çæ¬ã
ããå¦æä½ åç°æ æ³ç¼è¯è¿å»ï¼æå¯è½æ¯ä½ éç¨ç软件ä¸æçå å ¥äºä¸äºæ°çç¹æ§èå ¶ä»æé软件ä¸æ¯æçåå ï¼å°±ç¸åºéä½è¯¥è½¯ä»¶ççæ¬å·ãä¾å¦æå¼å§ç¨ gcc-3.3.2ï¼åç°ç¼è¯ä¸è¿ï¼æ¥ asãld ççæ¬å¤ªèï¼æå°±æ gcc é为 2..3ã 太æ°ççæ¬å¤§å¤æ²¡ç»è¿å¤§éçæµè¯ï¼å»ºè®®ä¸è¦éç¨ã
ããå页é¦
ãã2. 建ç«å·¥ä½ç®å½
ããé¦å ï¼æ们建ç«å 个ç¨æ¥å·¥ä½çç®å½ï¼
ããå¨ä½ çç¨æ·ç®å½ï¼æç¨çæ¯ç¨æ·liangï¼å æ¤ç¨æ·ç®å½ä¸º /home/liangï¼å 建ç«ä¸ä¸ªé¡¹ç®ç®å½embeddedã
ãã$pwd
ãã/home/liang
ãã$mkdir embedded
ããåå¨è¿ä¸ªé¡¹ç®ç®å½ embedded ä¸å»ºç«ä¸ä¸ªç®å½ build-toolsãkernel å toolsã
ããbuild-tools-ç¨æ¥åæ¾ä½ ä¸è½½ç binutilsãgcc å glibc çæºä»£ç åç¨æ¥ç¼è¯è¿äºæºä»£ç çç®å½ã
ããkernel-ç¨æ¥åæ¾ä½ çå æ ¸æºä»£ç åå æ ¸è¡¥ä¸ã
ããtools-ç¨æ¥åæ¾ç¼è¯å¥½ç交åç¼è¯å·¥å ·ååºæ件ã
ãã$cd embedded
ãã$mkdir build-tools kernel tools
ããæ§è¡å®åç®å½ç»æå¦ä¸ï¼
ãã$ls embedded
ããbuild-tools kernel tools
ãã3. è¾åºåç¯å¢åé
ããæ们è¾åºå¦ä¸çç¯å¢åéæ¹ä¾¿æ们ç¼è¯ã
ãã$export PRJROOT=/home/liang/embedded
ãã$export TARGET=arm-linux
ãã$export PREFIX=$PRJROOT/tools
ãã$export TARGET_PREFIX=$PREFIX/$TARGET
ãã$export PATH=$PREFIX/bin:$PATH
ããå¦æä½ ä¸æ¯ç¨ç¯å¢åéçï¼ä½ å¯ä»¥ç´æ¥ç¨ç»å¯¹æç¸å¯¹è·¯å¾ãæå¦æä¸ç¨ç¯å¢åéï¼ä¸è¬é½ç¨ç»å¯¹è·¯å¾ï¼ç¸å¯¹è·¯å¾ææ¶ä¼å¤±è´¥ãç¯å¢åéä¹å¯ä»¥å®ä¹å¨.bashrcæ件ä¸ï¼è¿æ ·å½ä½ logoutææ¢äºæ§å¶å°æ¶ï¼å°±ä¸ç¨èæ¯exportè¿äºåéäºã
ããä½ç³»ç»æåä½ çTAEGETåéç对åºå¦ä¸è¡¨
ããä½ å¯ä»¥å¨éè¿glibcä¸çconfig.subèæ¬æ¥ç¥éï¼ä½ çTARGETåéæ¯å¦è¢«æ¯æï¼ä¾å¦ï¼
ãã$./config.sub arm-linux
ããarm-unknown-linux-gnu
ããå¨æçç¯å¢ä¸ï¼config.sub å¨ glibc-2.2.3/scripts ç®å½ä¸ã
ããç½ä¸è¿æä¸äº HOWTO å¯ä»¥åèï¼ARM ä½ç³»ç»æçãThe GNU Toolchain for ARM Target HOWTOãï¼PowerPC ä½ç³»ç»æçãLinux for PowerPC Embedded Systems HOWTOãçã对TARGETçéåå¯è½æ帮å©ã
ãã4. 建ç«ç¼è¯ç®å½
ãã为äºææºç åç¼è¯æ¶çæçæ件åå¼ï¼ä¸è¬çç¼è¯å·¥ä½ä¸å¨çæºç ç®å½ä¸ï¼è¦å¦å»ºä¸ä¸ªç®å½æ¥ä¸é¨ç¨äºç¼è¯ãç¨ä»¥ä¸çå½ä»¤æ¥å»ºç«ç¼è¯ä½ ä¸è½½çbinutilsãgccåglibcçæºä»£ç çç®å½ã
ãã$cd $PRJROOT/build-tools
ãã$mkdir build-binutils build-boot-gcc build-gcc build-glibc gcc-patch
ããbuild-binutils-ç¼è¯binutilsçç®å½
ããbuild-boot-gcc-ç¼è¯gcc å¯å¨é¨åçç®å½
ããbuild-glibc-ç¼è¯glibcçç®å½
ããbuild-gcc-ç¼è¯gcc å ¨é¨çç®å½
ããgcc-patch-æ¾gccçè¡¥ä¸çç®å½
ããgcc-2..3 çè¡¥ä¸æ gcc-2..3-2.patchãgcc-2..3-no-fixinc.patch ågcc-2..3-returntype-fix.patchï¼å¯ä»¥ä» http://www.linuxfromscratch.org/ ä¸è½½å°è¿äºè¡¥ä¸ã
ããåå°ä½ ä¸è½½ç binutils-2..1ãgcc-2..3ãglibc-2.2.3 å glibc-linuxthreads-2.2.3 çæºä»£ç æ¾å ¥ build-tools ç®å½ä¸
ããçä¸ä¸ä½ ç build-tools ç®å½ï¼æ以ä¸å 容ï¼
ãã$ls
ããbinutils-2..1.tar.bz2 build-gcc gcc-patch
ããbuild-binutls build-glibc glibc-2.2.3.tar.gz
ããbuild-boot-gcc gcc-2..3.tar.gz glibc-linuxthreads-2.2.3.tar.gz
ããå页é¦
ãã建ç«å æ ¸å¤´æ件
ããæä½ ä» www.kernel.org ä¸è½½çå æ ¸æºä»£ç æ¾å ¥ $PRJROOT /kernel ç®å½
ããè¿å ¥ä½ ç kernel ç®å½ï¼
ãã$cd $PRJROOT /kernel
ãã解å¼å æ ¸æºä»£ç
ãã$tar -xzvf linux-2.4..tar.gz
ããæ
ãã$tar -xjvf linux-2.4..tar.bz2
ããå°äº 2.4. çå æ ¸çæ¬è§£å¼ä¼çæä¸ä¸ª linux ç®å½ï¼æ²¡å¸¦çæ¬å·ï¼å°±å°å ¶æ¹åã
ãã$mv linux linux-2.4.x
ããç» Linux å æ ¸æä¸ä½ çè¡¥ä¸
ãã$cd linux-2.4.
ãã$patch -p1 < ../patch-2.4.-rmk2
ããç¼è¯å æ ¸çæ头æ件
ãã$make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
ããä½ ä¹å¯ä»¥ç¨ config å xconfig æ¥ä»£æ¿ menuconfigï¼ä½è¿æ ·ç¨å¯è½ä¼æ²¡æ设置æäºé ç½®æ件é项å没æçæä¸é¢ç¼è¯æéç头æ件ãæ¨èå¤§å®¶ç¨ make menuconfigï¼è¿ä¹æ¯å æ ¸å¼å人åç¨çæå¤çé ç½®æ¹æ³ãé ç½®å®éåºå¹¶ä¿åï¼æ£æ¥ä¸ä¸çå æ ¸ç®å½ä¸ç include/linux/version.h å include/linux/autoconf.h æ件æ¯ä¸æ¯çæäºï¼è¿æ¯ç¼è¯ glibc æ¯è¦ç¨å°çï¼version.h å autoconf.h æ件çåå¨ï¼ä¹è¯´æäºä½ çæäºæ£ç¡®ç头æ件ã
ããè¿è¦å»ºç«å 个æ£ç¡®çé¾æ¥
ãã$cd include
ãã$ln -s asm-arm asm
ãã$cd asm
ãã$ln -s arch-epxa arch
ãã$ln -s proc-armv proc
ããæ¥ä¸æ¥ä¸ºä½ ç交åç¼è¯ç¯å¢å»ºç«ä½ çå æ ¸å¤´æ件çé¾æ¥
ãã$mkdir -p $TARGET_PREFIX/include
ãã$ln -s $PRJROOT/kernel/linux-2.4./include/linux $TARGET_PREFIX/include/linux
ãã$in -s $PRJROOT/kernel/linux-2.4./include/asm-arm $TARGET_PREFIX/include/asm
ããä¹å¯ä»¥æ Linux å æ ¸å¤´æ件æ·è´è¿æ¥ç¨
ãã$mkdir -p $TARGET_PREFIX/include
ãã$cp -r $PRJROOT/kernel/linux-2.4./include/linux $TARGET_PREFIX/include
ãã$cp -r $PRJROOT/kernel/linux-2.4./include/asm-arm $TARGET_PREFIX/include
ããå页é¦
ãã建ç«äºè¿å¶å·¥å ·ï¼binutilsï¼
ããbinutilsæ¯ä¸äºäºè¿å¶å·¥å ·çéåï¼å ¶ä¸å å«äºæ们常ç¨å°çasåldã
ããé¦å ï¼æ们解åæ们ä¸è½½çbinutilsæºæ件ã
ãã$cd $PRJROOT/build-tools
ãã$tar -xvjf binutils-2..1.tar.bz2
ããç¶åè¿å ¥build-binutilsç®å½é ç½®åç¼è¯binutilsã
ãã$cd build-binutils
ãã$../binutils-2..1/configure --target=$TARGET --prefix=$PREFIX
ãã--target é项æ¯æåºæ们çæçæ¯ arm-linux çå·¥å ·ï¼--prefix æ¯æåºæ们å¯æ§è¡æ件å®è£ çä½ç½®ã
ããä¼åºç°å¾å¤ checkï¼æå产ç Makefile æ件ã
ããæäº Makefile åï¼æ们æ¥ç¼è¯å¹¶å®è£ binutilsï¼å½ä»¤å¾ç®åã
ãã$make
ãã$make install
ããçä¸ä¸æ们 $PREFIX/bin ä¸ççæçæ件
ãã$ls $PREFIX/bin
ããarm-linux-addr2line arm-linux-gasp arm-linux-objdump arm-linux-strings
ããarm-linux-ar arm-linux-ld arm-linux-ranlib arm-linux-strip
ããarm-linux-as arm-linux-nm arm-linux-readelf
ããarm-linux-c++filt arm-linux-objcopy arm-linux-size
ããæ们æ¥è§£éä¸ä¸ä¸é¢çæçå¯æ§è¡æ件é½æ¯ç¨æ¥å¹²ä»ä¹ç
ããadd2line - å°ä½ è¦æ¾çå°å转ææ件åè¡å·ï¼å®è¦ä½¿ç¨ debug ä¿¡æ¯ã
ããAr-产çãä¿®æ¹å解å¼ä¸ä¸ªåæ¡£æ件
ããAs-gnu çæ±ç¼å¨
ããC++filt-C++ å java ä¸æä¸ç§éè½½å½æ°ï¼æç¨çéè½½å½æ°æåä¼è¢«ç¼è¯è½¬åææ±ç¼çæ å·ï¼c++filt å°±æ¯å®ç°è¿ç§ååç转åï¼æ ¹æ®æ å·å¾å°å½æ°åã
ããGasp-gnu æ±ç¼å¨é¢ç¼è¯å¨ã
ããLd-gnu çè¿æ¥å¨
ããNm-ååºç®æ æ件ç符å·å对åºçå°å
ããObjcopy-å°æç§æ ¼å¼çç®æ æ件转åæå¦å¤æ ¼å¼çç®æ æ件
ããObjdump-æ¾ç¤ºç®æ æ件çä¿¡æ¯
ããRanlib-为ä¸ä¸ªåæ¡£æ件产çä¸ä¸ªç´¢å¼ï¼å¹¶å°è¿ä¸ªç´¢å¼åå ¥åæ¡£æ件ä¸
ããReadelf-æ¾ç¤º elf æ ¼å¼çç®æ æ件çä¿¡æ¯
ããSize-æ¾ç¤ºç®æ æ件å个èç大å°åç®æ æ件ç大å°
ããStrings-æå°åºç®æ æ件ä¸å¯ä»¥æå°çå符串ï¼æ个é»è®¤çé¿åº¦ï¼ä¸º4
ããStrip-å¥æç®æ æ件çææç符å·ä¿¡æ¯
ããå页é¦
ãã建ç«åå§ç¼è¯å¨ï¼bootstrap gccï¼
ããé¦å è¿å ¥ build-tools ç®å½ï¼å°ä¸è½½ gcc æºä»£ç 解å
ãã$cd $PRJROOT/build-tools
ãã$tar -xvzf gcc-2..3.tar.gz
ããç¶åè¿å ¥ gcc-2..3 ç®å½ç» gcc æä¸è¡¥ä¸
ãã$cd gcc-2..3
ãã$patch -p1< ../gcc-patch/gcc-2..3.-2.patch
ãã$patch -p1< ../gcc-patch/gcc-2..3.-no-fixinc.patch
ãã$patch -p1< ../gcc-patch/gcc-2..3-returntype-fix.patch
ããecho timestamp > gcc/cstamp-h.in
ããå¨æ们ç¼è¯å¹¶å®è£ gcc åï¼æ们å è¦æ¹ä¸ä¸ªæ件 $PRJROOT/gcc/config/arm/t-linuxï¼æ
ããTARGET_LIBGCC2-CFLAGS = -fomit-frame-pointer -fPIC
ããè¿ä¸è¡æ¹ä¸º
ããTARGET_LIBGCC2-CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h
ããä½ å¦æ没å®ä¹ -Dinhibitï¼ç¼è¯æ¶å°ä¼æ¥å¦ä¸çé误
ãã../../gcc-2..3/gcc/libgcc2.c:: stdlib.h: No such file or directory
ãã../../gcc-2..3/gcc/libgcc2.c:: unistd.h: No such file or directory
ããmake[3]: *** [libgcc2.a] Error 1
ããmake[2]: *** [stmp-multilib-sub] Error 2
ããmake[1]: *** [stmp-multilib] Error 1
ããmake: *** [all-gcc] Error 2
ããå¦æ没æå®ä¹ -D__gthr_posix_hï¼ç¼è¯æ¶ä¼æ¥å¦ä¸çé误
ããIn file included from gthr-default.h:1,
ããfrom ../../gcc-2..3/gcc/gthr.h:,
ããfrom ../../gcc-2..3/gcc/libgcc2.c::
ãã../../gcc-2..3/gcc/gthr-posix.h:: pthread.h: No such file or directory
ããmake[3]: *** [libgcc2.a] Error 1
ããmake[2]: *** [stmp-multilib-sub] Error 2
ããmake[1]: *** [stmp-multilib] Error 1
ããmake: *** [all-gcc] Error 2
ããè¿æä¸ç§ä¸-Dinhibitåçææçæ¹æ³ï¼é£å°±æ¯å¨ä½ é ç½®configureæ¶å¤å ä¸ä¸ªåæ°-with-newlibï¼è¿ä¸ªé项ä¸ä¼è¿«ä½¿æä»¬å¿ é¡»ä½¿ç¨newlibãæ们ç¼è¯äºbootstrap-gccåï¼ä»ç¶å¯ä»¥éæ©ä»»ä½cåºã
ããæ¥çå°±æ¯é ç½®boostrap gccï¼ åé¢è¦ç¨bootstrap gcc æ¥ç¼è¯ glibc åºã
ãã$cd ..; cd build-boot-gcc
ãã$../gcc-2..3/configure --target=$TARGET --prefix=$PREFIX \
ãã>--without-headers --enable-languages=c --disable-threads
ããè¿æ¡å½ä»¤ä¸ç -targetã--prefix åé ç½® binutils çå«ä¹æ¯ç¸åçï¼--without-headers å°±æ¯æä¸éè¦å¤´æ件ï¼å 为æ¯äº¤åç¼è¯å·¥å ·ï¼ä¸éè¦æ¬æºä¸ç头æ件ã-enable-languages=cæ¯ææ们ç boot-gcc åªæ¯æ c è¯è¨ã--disable-threads æ¯å»æ thread åè½ï¼è¿ä¸ªåè½éè¦ glibc çæ¯æã
ããæ¥çæ们ç¼è¯å¹¶å®è£ boot-gcc
ãã$make all-gcc
ãã$make install-gcc
ããæ们æ¥çç $PREFIX/bin éé¢å¤äºåªäºä¸è¥¿
ãã$ls $PREFIX/bin
ããä½ ä¼åç°å¤äº arm-linux-gcc ãarm-linux-unprotoizeãcpp å gcov å 个æ件ã
ããGcc-gnu ç C è¯è¨ç¼è¯å¨
ããUnprotoize-å° ANSI C çæºç 转å为 K&R C çå½¢å¼ï¼å»æå½æ°ååä¸çåæ°ç±»åã
ããCpp-gnuç C çé¢ç¼è¯å¨
ããGcov-gcc çè¾ å©æµè¯å·¥å ·ï¼å¯ä»¥ç¨å®æ¥åæåä¼ç¨åºã
ããä½¿ç¨ gcc3.2 以å gcc3.2 以ä¸çæ¬æ¶ï¼é ç½® boot-gcc ä¸è½ä½¿ç¨ --without-headers é项ï¼èéè¦ä½¿ç¨ glibc ç头æ件ã
ããå页é¦
ããå»ºç« c åº(glibc)
ããé¦å 解å glibc-2.2.3.tar.gz å glibc-linuxthreads-2.2.3.tar.gz æºä»£ç
ãã$cd $PRJROOT/build-tools
ãã$tar -xvzf glibc-2.2.3.tar.gz
ãã$tar -xzvf glibc-linuxthreads-2.2.3.tar.gz --directory=glibc-2.2.3
ããç¶åè¿å ¥ build-glibc ç®å½é ç½® glibc
ãã$cd build-glibc
ãã$CC=arm-linux-gcc ../glibc-2.2.3/configure --host=$TARGET --prefix="/usr"
ãã--enable-add-ons --with-headers=$TARGET_PREFIX/include
ããCC=arm-linux-gcc æ¯æ CC åé设æä½ åç¼è¯å®çboostrap gccï¼ç¨å®æ¥ç¼è¯ä½ çglibcã--enable-add-onsæ¯åè¯glibcç¨ linuxthreads å ï¼å¨ä¸é¢æ们已ç»å°å®æ¾å ¥äº glibc æºç ç®å½ä¸ï¼è¿ä¸ªé项çä»·äº -enable-add-ons=linuxthreadsã--with-headers åè¯ glibc æ们çlinux å æ ¸å¤´æ件çç®å½ä½ç½®ã
ããé ç½®å®åå°±å¯ä»¥ç¼è¯åå®è£ glibc
ãã$make
ãã$make install_root=$TARGET_PREFIX prefix="" install
ããç¶åä½ è¿è¦ä¿®æ¹ libc.so æ件
ããå°
ããGROUP ( /lib/libc.so.6 /lib/libc_nonshared.a)
ããæ¹ä¸º
ããGROUP ( libc.so.6 libc_nonshared.a)
ããè¿æ ·è¿æ¥ç¨åº ld å°±ä¼å¨ libc.so æå¨çç®å½æ¥æ¾å®éè¦çåºï¼å ä¸ºä½ çæºåç/libç®å½å¯è½å·²ç»è£ äºä¸ä¸ªç¸åååçåºï¼ä¸ä¸ªä¸ºç¼è¯å¯ä»¥å¨ä½ ç宿主æºä¸è¿è¡çç¨åºçåºï¼èä¸æ¯ç¨äºäº¤åç¼è¯çã
ããå页é¦
ãã建ç«å ¨å¥ç¼è¯å¨ï¼full gccï¼
ããå¨å»ºç«boot-gcc çæ¶åï¼æ们åªæ¯æäºCãå°è¿éï¼æ们就è¦å»ºç«å ¨å¥ç¼è¯å¨ï¼æ¥æ¯æCåC++ã
ãã$cd $PRJROOT/build-tools/build-gcc
ãã$../gcc-2..3/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++
ãã--enable-languages=c,c++ åè¯ full gcc æ¯æ c å c++ è¯è¨ã
ããç¶åç¼è¯åå®è£ ä½ ç full gcc
ãã$make all
ãã$make install
ããæ们åæ¥çç $PREFIX/bin éé¢å¤äºåªäºä¸è¥¿
ãã$ls $PREFIX/bin
ããä½ ä¼åç°å¤äº arm-linux-g++ ãarm-linux-protoize å arm-linux-c++ å 个æ件ã
ããG++-gnuç c++ ç¼è¯å¨ã
ããProtoize-ä¸Unprotoizeç¸åï¼å°K&R Cçæºç 转å为ANSI Cçå½¢å¼ï¼å½æ°ååä¸å å ¥åæ°ç±»åã
ããC++-gnu ç c++ ç¼è¯å¨ã
ããå°è¿éä½ ç交åç¼è¯å·¥å ·å°±ç®åå®äºï¼ç®åéªè¯ä¸ä¸ä½ ç交åç¼è¯å·¥å ·ã
ããç¨å®æ¥ç¼è¯ä¸ä¸ªå¾ç®åçç¨åº helloworld.c
ãã#include <stdio.h>
ããint main(void)
ãã{
ããprintf("hello world\n");
ããreturn 0;
ãã}
ãã$arm-linux-gcc helloworld.c -o helloworld
ãã$file helloworld
ããhelloworld: ELF -bit LSB executable, ARM, version 1,
ããdynamically linked (uses shared libs), not stripped
ããä¸é¢çè¾åºè¯´æä½ ç¼è¯äºä¸ä¸ªè½å¨ arm ä½ç³»ç»æä¸è¿è¡ç helloworldï¼è¯æä½ çç¼è¯å·¥å ·åæåäºã
è½¬è½½ä» ä¾åèï¼çæå±äºåä½è