×ðÁú¿­Ê±¹ÙÍøµÇ¼

LinuxÏÂʹÓÃGCC¾ÙÐÐARM±à³ÌµÄÍƼöÉèÖÃ

linuxÏÂʹÓÃgcc¾ÙÐÐarm±à³ÌµÄÍƼöÉèÖÃ

ÕªÒª£ºGCCÊÇÒ»¿î¹¦Ð§Ç¿Ê¢µÄ±àÒëÆ÷£¬ÔÚLinuxÇéÐÎϾÙÐÐARM±à³ÌʱºÜÊÇÊÊÓᣱ¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÏÂÉèÖÃGCCÒÔ¼°Ê¹ÓÃGCC¾ÙÐÐARM±à³ÌµÄһЩÍƼöÉèÖá£

Ò»¡¢×°ÖÃGCC

ÔÚLinuxÇéÐÎÏ£¬GCCͨ³£ÊÇĬÈÏ×°ÖõÄ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¼ì²éGCCÊÇ·ñÒÑ×°Öãº

gcc --version

µÇ¼ºó¸´ÖÆ

ÈôÊÇGCCûÓÐ×°Öã¬ÇëÖ´ÐÐÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt-get install gcc

µÇ¼ºó¸´ÖÆ

¶þ¡¢×°ÖÃARM½»Ö¯±àÒ빤¾ßÁ´

GCCĬÈÏÊÇΪÖ÷»ú±àÒë³ÌÐòµÄ£¬ÎªÁËÄܹ»ÔÚLinuxÉϱàÒëARMÄ¿µÄ³ÌÐò£¬ÎÒÃÇÐèҪװÖÃARM½»Ö¯±àÒ빤¾ßÁ´¡£ÒÔÏÂÒÔARM Cortex-AϵÁÐΪÀý¾ÙÐÐ˵Ã÷¡£

ÏÂÔØARM½»Ö¯±àÒ빤¾ßÁ´

ARM¹ÙÍøÌṩÁËÒ»Ì×ARM½»Ö¯±àÒ빤¾ßÁ´£¬¿ÉÒÔÔÚ¹ÙÍøÏÂÔØ×îа汾¡£ÏÂÔØÁ´½Ó£ºhttps://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm¡£ÏÂÔØÍê³Éºó£¬½«Ñ¹Ëõ°ü½âѹµ½í§ÒâĿ¼¡£

ÉèÖÃÇéÐαäÁ¿

½ÓÏÂÀ´£¬ÐèÒª½«½»Ö¯±àÒ빤¾ßÁ´µÄĿ¼Ìí¼Óµ½ÏµÍ³µÄÇéÐαäÁ¿ÖС£·­¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁ

export PATH=$PATH:/path/to/toolchain/bin

µÇ¼ºó¸´ÖÆ

½«/path/to/toolchainÌ滻ΪÄã½âѹ¹¤¾ßÁ´µÄĿ¼¡£

Èý¡¢±àдARMÔ´Â벢ʹÓÃGCC±àÒë

ÒÔÏÂչʾһ¸ö¼òÆÓµÄARM»ã±à´úÂëʾÀý£¬ÏÈÈÝÔõÑùʹÓÃGCC±àÒëARMÔ´Âë¡£

½¨ÉèÒ»¸öеÄÎļþ£¬ÀýÈçhello.S£¬È»ºóʹÓÃÎı¾±à¼­Æ÷·­¿ª£º

vi hello.S

µÇ¼ºó¸´ÖÆ

ÔÚhello.SÖÐÊäÈëÒÔÏ´úÂ룺

.global _start
.section .data
 msg:    .asciz "Hello, ARM!
"
 len = . - msg
.section .text
_start:
 mov r0, 1
 ldr r1, =msg
 ldr r2, =len
 mov r7, 4
 swi 0
 mov r7, 1
 swi 0

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢Í˳öÎı¾±à¼­Æ÷¡£

ʹÓÃÒÔÏÂÏÂÁԴÂë±àÒëΪARM¶þ½øÖÆ¿ÉÖ´ÐÐÎļþ£º

as -o hello.o hello.S
ld -o hello hello.o

µÇ¼ºó¸´ÖÆ

ÔÚÖÕ¶ËÖ´ÐÐÒÔÏÂÏÂÁîÔËÐгÌÐò£º

./hello

µÇ¼ºó¸´ÖÆ

³ÌÐò½«Êä³öHello, ARM!¡£

ËÄ¡¢GCCµÄ³£ÓòÎÊýºÍÑ¡Ïî

ÔÚ±àÒëARM³ÌÐòʱ£¬GCCÓÐһЩ³£ÓõIJÎÊýºÍÑ¡Ï¿ÉÒÔÓÅ»¯ÌìÉúµÄ´úÂ룬Ìá¸ß³ÌÐòÐÔÄܺÍЧÂÊ¡£

ÓÅ»¯¼¶±ð²ÎÊý£ºGCCÌṩÁËÓÅ»¯¼¶±ð²ÎÊý-O£¬¿ÉÒÔ¿ØÖƱàÒëÆ÷µÄÓÅ»¯Ë®Æ½¡£³£ÓõÄÓÅ»¯¼¶±ð²ÎÊýÓÐ-O0£¨²»¾ÙÐÐÓÅ»¯£©¡¢-O1£¨»ù±¾ÓÅ»¯£©ºÍ-O2£¨½Ï¸ßÓÅ»¯£©¡£

µ÷ÊÔÑ¡ÏGCCÌṩÁ˵÷ÊÔÏà¹ØµÄÑ¡Ï¿ÉÒÔÌìÉúÓÃÓÚµ÷ÊԵĶþ½øÖÆÎļþ¡£³£Óõĵ÷ÊÔÑ¡ÏîÓÐ-g£¨ÌìÉúµ÷ÊÔÐÅÏ¢£©ºÍ-ggdb£¨ÌìÉúgdbµ÷ÊÔÆ÷¿ÉÓõĵ÷ÊÔÐÅÏ¢£©¡£

¼Ü¹¹²ÎÊý£ºGCCÌṩÁ˼ܹ¹²ÎÊý£¬ÓÃÓÚÖ¸¶¨Ä¿µÄ´¦ÀíÆ÷µÄ¼Ü¹¹¡£ÀýÈ磬¿ÉÒÔʹÓÃ-march=armv7-aÖ¸¶¨ARM Cortex-AϵÁд¦ÀíÆ÷¡£

ÅþÁ¬Æ÷Ñ¡ÏGCCÌṩÁËÅþÁ¬Æ÷Ñ¡ÏÓÃÓÚ¿ØÖÆÅþÁ¬Æ÷µÄÐÐΪ¡£³£ÓõÄÅþÁ¬Æ÷Ñ¡ÏîÓÐ-nostdlib£¨²»Ê¹Óñê×¼¿â£©¡¢-nostartfiles£¨²»Ê¹ÓÃÆô¶¯Îļþ£©ºÍ-nodefaultlibs£¨²»Ê¹ÓÃĬÈϿ⣩¡£

Îå¡¢×ܽá

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑùÔÚLinuxÏÂÉèÖÃGCCÒÔ¼°Ê¹ÓÃGCC¾ÙÐÐARM±à³ÌµÄÍƼöÉèÖá£Í¨¹ý×°ÖÃARM½»Ö¯±àÒ빤¾ßÁ´£¬²¢ÎÞаÔËÓÃGCCµÄ²ÎÊýºÍÑ¡ÏÎÒÃÇ¿ÉÒÔÔ½·¢¸ßЧµØ¾ÙÐÐARM±à³Ì¡£

Ï£Íû±¾ÎĶԳõѧÕßÔÚLinuxÏÂʹÓÃGCC¾ÙÐÐARM±à³ÌÓÐËù×ÊÖú£¬Ï£Íû¶ÁÕßÄܹ»½øÒ»²½Ì½Ë÷ºÍѧϰARM±à³ÌµÄ¸ü¶à֪ʶºÍ¼¼ÇÉ¡£

ÒÔÉϾÍÊÇLinuxÏÂʹÓÃGCC¾ÙÐÐARM±à³ÌµÄÍƼöÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ