¡¡¡¡ÒÔÏÂÊÇÕâÁ½ÖÖ½»²æ±àÒë»·¾³µÄÇø±ð
¡¡¡¡ÕâÁ½ÖÖ½»²æ»·¾³¶¼Ê¹Óùý
¡¡¡¡ÔÚ»ùÓÚARMµÄǶÈëʽϵͳ¿ª·¢ÖУ¬³£³£Óõ½½»²æ±àÒëµÄGCC¹¤¾ßÁ´ÓÐÁ½ÖÖ£ºarm-linux-*ºÍ arm-elf-*£¬Á½ÕßÇø±ðÖ÷ÒªÔÚÓÚʹÓò»Í¬µÄC¿âÎļþ¡£arm-linux-*ʹÓÃGNUµÄGlibc£¬¶øarm-elf-*Ò»°ãʹÓà uClibc/uC-libc»òÕßʹÓÃREDHATרÃÅΪǶÈëʽϵͳµÄ¿ª·¢µÄC¿ânewlib.Glibc¡£uClibc/uC-libcÒÔ¼° newlib¶¼ÊÇCÓïÑÔ¿âÎļþ£¬Ö»ÊÇËùÓ¦ÓõÄÁìÓò²»Í¬¶øÒÑ£¬GlibcÊÇÕë¶ÔPC¿ª·¢µÄ£¬uClibc/uC-libcÊÇÓëGlibc API¼æÈݵÄСÐÍ»¯CÓïÑԿ⣬ʵÏÖÁËGlibc²¿·Ö¹¦ÄÜ¡£
¡¡¡¡¹ØÓÚuClibc/uC-libcµÄ˵Ã÷£¬Ïê¼ûÈçÏ£º
¡¡¡¡There are two libc libraries commonly used with uClinux. uC-libc and uClibc. They are quite different despite their similar names. Here is a quick overview of how they are different.
¡¡¡¡uC-libc is the original library for uClinux. It was based on sources from the Linux-8086 C library which was part of the ELKs project with m68000 support added by Jeff Dionne and Kenneth Albanowski. It is a fairly complete libc implementation, however, some of the API's are a little non-standard and quite a few common libc routines are not present. Currently it has stable support for m68000, ColdFire and ARM (Non-MMU) architectures. It was primary design goal is to be small and light weight. It does try to conform to any standards, although its API tries to be compatible with most libcs, it is not always exactly the same.
¡¡¡¡The uClinux distribution provides an environment that can compile using either uC-libc or uClibc depending on your needs. For m68000 and Coldfire platforms it is generally better to chose uC-libc as it supports shared libraries and is the most commonly used libc for these CPUs. uClibc also works quite well with almost all platforms supported by the distribution. Which libc you choose to use will be decided by your requirements
¡¡¡¡uClinuxÓÐÁ½¸ö¾³£Ê¹ÓõÄlibc¿â£ºuC-libcºÍuClibc¡£ËäÈ»Á½ÕßÃû×ÖºÜÏàËÆ£¬ÆäʵÓвî±ð£¬ÏÂÃæ¾Í¼òµ¥µÄ½éÉÜһ϶þÕߵIJ»Í¬Ö®´¦¡£uC -libcÊÇ×îÔçΪuClinux¿ª·¢µÄ¿â£¬ÊÇJeff DionneºÍKenneth AlbanowskiΪÔÚEKLsÏîÄ¿ÖÐÖ§³Öm68000ÔÚLinux-8086 C¿âÔ´ÂëÉÏÒÆÖ²µÄ¡£uC-libcÊÇÒ»¸öÍêÈ«µÄlibcʵÏÖ£¬µ«ÆäÖÐÓÐһЩapiÊǷDZê×¼µÄ£¬ÓÐЩlibcµÄ±ê׼ҲûÓÐʵÏÖ¡£uC-libcÎȶ¨µØÖ§³Ö m68000£¬ColdFireºÍûÓÐMMUµÄARM¡£ÆäÖ÷ÒªÉè¼ÆÄ¿±êÊÇ¡°Ð¡¡±¡¢"Çá"£¬²¢¾¡Á¿Óë±ê×¼Ò»Ö£¬ËäÈ»ËüµÄAPIºÍºÜ¶àlibc¼æÈÝ£¬µ«ÊÇËƺõ²¢²»ÏñËüÆÚÍûµÄÄÇÑùºÍËùÓбê×¼Ò»Ö¡£
¡¡¡¡uClibc¾ÍÊÇΪÁ˽â¾öÕâ¸öÎÊÌâ´ÓuC-libcÖз¢Õ¹³öÀ´µÄ¡£ËüµÄËùÓÐAPI¶¼ÊDZê×¼µÄ(ÕýÈ·µÄ·µ»ØÀàÐÍ£¬²ÎÊýµÈµÈ)£¬ËüÃÖ²¹ÁËuC-libcÖÐûÓÐʵÏÖµÄlibc±ê×¼£¬ÏÖÔÚÒѾ±»ÒÆÖ²µ½¶àÖּܹ¹ÖС£Ò»°ãÀ´½²£¬Ëü¾¡Á¿¼æÈÝglibcÒÔ±ãʹӦÓóÌÐòÓÃuClibc¸Äд±äµÄÈÝÒס£uClibcÄܹ»ÔÚ±ê×¼µÄ VM linuxºÍuClinuxÉÏÃæʹÓá£ÎªÁËÓ¦ÓóÌÐòµÄ¼ò½à£¬ËüÉõÖÁ¿ÉÒÔÔÚÐí¶àÖ§³ÖMMUµÄƽ̨Éϱ»±àÒë³É¹²Ïí¿â¡£Erik AndersonÔÚuClibc±³ºó×öÁ˺ܶàµÄ¹¤×÷¡£uClibcÖ§³ÖÐí¶àϵÁеĴ¦ÀíÆ÷£ºm68000£¬Coldfire£¬ARM£¬MIPS£¬v850£¬ x86£¬i960£¬Sparc£¬SuperH£¬Alpha£¬PowerPCºÍHitachi 8¡£²»¶ÏÔö¼ÓµÄƽ̨֧³ÖÏÔʾuClibcÄܹ»ºÜÈÝÒ×µÄÊÊӦеļܹ¹¡£uClinux·¢ÐаæÌṩÁË»·¾³Äܹ»ÈÃÄãÑ¡ÔñʹÓÃuC-libc»òÊÇuClibc±àÒë¡£¶ÔÓÚm68000ºÍColdfireƽ̨À´Ëµ£¬Ñ¡ÔñuC-libc»¹ÊÇÉÔ΢ºÃÒ»µã£¬ÒòΪËüÖ§³Ö¹²Ïí¿â£¬¶ø¹²Ïí¿âÊÇÕâЩcpu¾³£Ê¹ÓÃµÄ libc.uClibcÒ²¼¸ºõºÍËùÓеÄƽ̨¶¼ÄܺܺõŤ×÷¡£Ñ¡ÔñÄÄÖÖlibcÈ¡¾öÓÚÄãµÄÐèÇó¡£
¡¡¡¡newlib ÊÇÒ»¸öÓÃÓÚǶÈëʽϵͳµÄ¿ª·ÅÔ´´úÂëµÄCÓïÑÔ³ÌÐò¿â£¬ÓÉlibcºÍlibmÁ½¸ö¿â×é³É£¬ÌصãÊÇÇáÁ¿¼¶£¬Ëٶȿ죬¿ÉÒÆÖ²µ½ºÜ¶àCPU½á¹¹ÉÏ¡£newlibʵÏÖÁËÐí¶à¸´ÔӵŦÄÜ£¬°üÀ¨×Ö·û´®Ö§³Ö£¬¸¡µãÔËË㣬ÄÚ´æ·ÖÅä(Èçmalloc)ºÍI/OÁ÷º¯Êý(printf£¬fprinf()µÈµÈ)¡£ÆäÖÐlibcÌṩÁËc ÓïÑÔ¿âµÄʵÏÖ£¬¶ølibmÌṩÁ˸¡µãÔËËãÖ§³Ö¡£
¡¡¡¡ÔÚΪARM½»²æ±àÒëgcc±àÒëÆ÷ʱ£¬¶ÔgccÖ¸¶¨²»Í¬µÄÅäÖÃÑ¡Ïîʱ£¬Ê¹ÓõÄCÓïÑÔ¿â¾Í²»Í¬£¬gcc±àÒëÆ÷ĬÈÏʹÓÃGlibc£¬Ò²¿ÉÒÔʹÓà uClibc/uC-libc(»ù±¾¼æÈÝGlibc API)£¬µ±Ê¹ÓÃ--with-newlibʱ£¬gcc±àÒëÆ÷²»Ê¹ÓÃGlibc¡£µ±Ã»Óн»²æ±àÒëGlibcʱ£¬¿ÉÒÔʹÓÃ--with-newlib½ûÖ¹Á¬½ÓGlibc¶ø±àÒëbootstrap gcc±àÒëÆ÷¡£´ÓgccԴĿ¼ÏµÄconfig/armÖеÄt-linuxºÍt-arm-elfÖпÉÒÔ¿´³ö£¬²»Í¬µÄ--targetÒ²Ó°ÏìgccÁ¬½ÓCÓïÑԿ⣬t-linux(--target=arm-linux)ĬÈÏʹÓÃGlibc£¬-arm-elf(--target=arm-elf)ʹÓÃ- Dinhibit_libc½ûÖ¹Á¬½ÓGlibc£¬ÕâʱÎÒÃǾͿÉÒÔʹÓÃnewlibµÈÆäËûCÓïÑÔ¿â±àÒëGCC¹¤¾ßÁ´¡£
¡¡¡¡ËäÈ»GCC¹¤¾ßÁ´ÅäÖÃÁ˲»Í¬µÄµÄCÓïÑԿ⣬µ«ÓÉÓÚÕâЩCÓïÑԿⶼ¿ÉÒÔÓÃÀ´Ö§³ÖGCC£¬ËüÃǶԺËÐÄÊý¾ÝµÄ´¦ÀíÉϲ»´æÔڽϴó³öÈë¡£Òò¶øarm-linux-* ºÍ arm-elf-*Çø±ðÖ÷Òª±íÏÖÔÚCÓïÑÔ¿âµÄʵÏÖÉÏ£¬ÀýÈ粻ͬϵͳµ÷Ó㬲»Í¬µÄº¯Êý¼¯ÊµÏÖ£¬²»Í¬µÄABI\Æô¶¯´úÂëÒÔ¼°²»Í¬ÏµÍ³ÌØÐÔµÈ΢СµÄ²î±ð¡£
¡¡¡¡arm-linux-*ºÍ arm-elf-*µÄʹÓÃûÓÐÒ»¸ö¾ø¶ÔµÄ±ê×¼£¬Åųý²»Í¬¿âʵÏֵIJîÒ죬gcc¿ÉÒÔ±àÒëÈκÎϵͳ¡£arm-linux-*ºÍ arm-elf-*¶¼¿ÉÒÔÓÃÀ´±àÒëÂã»ú³ÌÐòºÍ²Ù×÷ϵͳ£¬Ö»ÊÇÔÚ×ñÑÏÂÃæµÄÃèÊöʱϵͳ³ÌÐòÏԵøü¼Óе÷£º
¡¡¡¡arm-linux-*Õë¶ÔÔËÐÐlinuxµÄARM»úÆ÷£¬ÆäÒÀÀµÓÚÖ¸¶¨µÄCÓïÑÔ¿âGlibc£¬ÒòΪͬÑùʹÓÃGlibcµÄlinux¶øʹµÃarm-linux-*ÔÚÔËÐÐlinuxµÄARM»úÆ÷ÉϱàÒëÏԵøü¼ÓºÍг¡£
¡¡¡¡arm-elf-*ÔòÊÇÒ»¸ö¶ÀÁ¢µÄ±àÒëÌåϵ£¬²»ÒÀÀµÓÚÖ¸¶¨µÄCÓïÑÔ¿âGlibc£¬¿ÉÒÔʹÓÃnewlibµÈÆäËûCÓïÑԿ⣬²»ÒªÇó²Ù×÷ϵͳ֧³Ö£¬µ±ÆäʹÓÃΪǶÈëʽϵͳ¶øÉè¼ÆµÄһЩÇáÇɵÄCÓïÑÔ¿âʱ±àÒëÂã»ú³ÌÐò(ûÓÐlinuxµÈ´óÐͲÙ×÷ϵͳµÄ³ÌÐò)£¬Èç¼à¿Ø³ÌÐò£¬bootloaderµÈÄÜʹµÃϵͳ³ÌÐò¸ü¼ÓСÇÉ¿ì½Ý¡£