linuxϵÄELFÎļþ·ÖÎö
from:http://www.dzjs.net/html/qianrushixitong/2008/0509/3125.html
1 ÒýÑÔ
ELF(Executable and Linkable Format)¼´¿ÉÖ´ÐÐÁ¬½ÓÎļþ¸ñʽ£¬ÊÇLinux£¬SVR4ºÍSolaris2.0ĬÈϵÄÄ¿±êÎļþ¸ñʽ£¬Ä¿Ç°±ê×¼½Ó¿ÚίԱ»áTISÒѽ«ELF±ê×¼»¯ÎªÒ»ÖÖ¿ÉÒÆÖ²µÄÄ¿±êÎļþ¸ñʽ£¬ÔËÐÐÓÚ32-bit IntelÌåϵ΢»úÉÏ£¬¿ÉÓë¶àÖÖ²Ù×÷ϵͳ¼æÈÝ¡£·ÖÎöelfÎļþÓÐÖúÓÚÀí½âһЩÖØÒªµÄϵͳ¸ÅÄÀýÈç³ÌÐòµÄ±àÒëºÍÁ´½Ó£¬³ÌÐòµÄ¼ÓÔغÍÔËÐеÈ
2 ELFÎļþ¸ñʽ
2.1 ELFÎļþµÄÀàÐÍ
ELFÎļþÖ÷ÒªÓÐÈýÖÖÀàÐÍ£º
(1)¿ÉÖض¨Î»Îļþ°üº¬ÁË´úÂëºÍÊý¾Ý£®¿ÉÓëÆäËüELFÎļþ½¨Á¢Ò»¸ö¿ÉÖ´Ðлò¹²ÏíµÄÎļþ£º
(2)¿ÉÖ´ÐÐÎļþʱ¿ÉÖ±½ÓÖ´ÐеijÌÐò£º
(3)¹²ÏíÄ¿±êÎļþ°üÀ¨´úÂëºÍÊý¾Ý£¬¿ÉÒÔÔÚÁ½¸öµØ·½Á´½Ó¡£µÚÒ»£¬Á¬½ÓÆ÷¿ÉÒÔ°ÑËüºÍÆäËü¿ÉÖض¨Î»ÎļþºÍ¹²ÏíÎļþÒ»Æð´¦ÀíÒÔ½¨Á¢ÁíÒ»¸öELFÎļþ;µÚ¶þ£¬¶¯Ì¬Á´½ÓÆ÷°ÑËüºÍÒ»¸ö¿ÉÖ´ÐÐÎļþºÍÆäËü¹²ÏíÎļþ½áºÏÔÚÒ»Æð½¨Á¢Ò»¸ö½ø³ÌÓ³Ïñ¡£
2.2 ELFÎļþµÄ×éÖ¯
ELFÎļþ²ÎÓë³ÌÐòµÄÁ¬½Ó(½¨Á¢Ò»¸ö³ÌÐò)ºÍ³ÌÐòµÄÖ´ÐÐ(ÔËÐÐÒ»¸ö³ÌÐò)£¬±àÒëÆ÷ºÍÁ´½ÓÆ÷½«ÆäÊÓΪ½ÚÍ·±í(section header table)ÃèÊöµÄһЩ½Ú(section)µÄ¼¯ºÏ£¬¶ø¼ÓÔØÆ÷Ôò½«ÆäÊÓΪ³ÌÐòÍ·±í(program header table)ÃèÊöµÄ¶Î(segment)µÄ¼¯ºÏ£¬Í¨³£Ò»¸ö¶Î¿ÉÒÔ°üº¬¶à¸ö½Ú¡£¿ÉÖض¨Î»Îļþ¶¼°üº¬Ò»¸ö½ÚÍ·±í£¬¿ÉÖ´ÐÐÎļþ¶¼°üº¬Ò»¸ö³ÌÐòÍ·±í¡£¹²ÏíÎļþÁ½Õ߶¼°üº¬ÓС£Îª´Ë£¬ELFÎļþ¸ñʽͬʱÌṩÁËÁ½ÖÖ¿´´ýÎļþÄÚÈݵķ½Ê½£¬·´Ó³Á˲»Í¬ÐÐΪµÄ²»Í¬ÒªÇó¡£ÏÂͼÏÔʾÁËELFÎļþµÄ×éÖ¯¡£
2.3 ÎļþÍ·(Elf header)
ElfÍ·ÔÚ³ÌÐòµÄ¿ªÊ¼²¿Î»£¬×÷ΪÒý·±íÃèÊöÕû¸öELFµÄÎļþ½á¹¹£¬ÆäÐÅÏ¢´óÖ·ÖΪËIJ¿·Ö£ºÒ»ÊÇϵͳÏà¹ØÐÅÏ¢£¬¶þÊÇÄ¿±êÎļþÀàÐÍ£¬ÈýÊǼÓÔØÏà¹ØÐÅÏ¢£¬ËÄÊÇÁ´½ÓÏà¹ØÐÅÏ¢ ÆäÖÐϵͳÏà¹ØÐÅÏ¢°üÀ¨elfÎļþħÊý(±êʶelfÎļþ)£¬Æ½Ì¨Î»Êý£¬Êý¾Ý±àÂ뷽ʽ£¬elfÍ·²¿°æ±¾£¬Ó²¼þƽ̨e_machine£¬Ä¿±êÎļþ°æ±¾e_version£¬´¦ÀíÆ÷Ìض¨±êÖ¾e_ftags£ºÕâЩÐÅÏ¢µÄÒýÈ뼫´óÔöÇ¿ÁËelfÎļþµÄ¿ÉÒÆÖ²ÐÔ£¬Ê¹½»²æ±àÒë³ÉΪ¿ÉÄÜ¡£Ä¿±êÎļþÀàÐÍÓÃe_typeµÄÖµ±íʾ£¬¿ÉÖض¨Î»ÎļþΪ1£¬¿ÉÖ´ÐÐÎļþΪ2£¬¹²ÏíÎļþΪ3;¼ÓÔØÏà¹ØÐÅÏ¢ÓУº³ÌÐò½øÈëµãe_entry£®³ÌÐòÍ·±íÆ«ÒÆÁ¿e_phoff£¬elfÍ·²¿³¤¶Èe_ehsize£¬³ÌÐòÍ·±íÖÐÒ»¸öÌõÄ¿µÄ³¤¶Èe_phentsize£¬³ÌÐòÍ·±íÌõÄ¿ÊýÄ¿e_phnum;Á´½ÓÏà¹ØÐÅÏ¢ÓУº½ÚÍ·±íÆ«ÒÆÁ¿e_shoff£¬½ÚÍ·±íÖÐÒ»¸öÌõÄ¿µÄ³¤¶Èe_shentsize£¬½ÚÍ·±íÌõÄ¿¸öÊýe_shnum £¬½ÚÍ·±í×Ö·ûË÷Òýe shstmdx¡£¿ÉʹÓÃreadelf -h
Ïà¹ØÎĵµ£º
ÓÉÓÚ Linux Á¼ºÃµÄÓû§È¨ÏÞ¹ÜÀíÌåϵ£¬²¡¶¾ÍùÍùÊÇ Linux ϵͳ¹ÜÀíÔ±×îºó²ÅÐèÒª¿¼ÂǵÄÎÊÌâ¡£ÒÔÍù£¬Linux ÉϵÄɱ¶¾Èí¼þÖ÷ÒªÊÇΪÆóÒµµÄÓʼþºÍÎļþ·þÎñÆ÷ËùÉè¼ÆµÄ¡£Èç½ñ£¬Ëæ×Å Linux ×ÀÃæÓû§ÊýÁ¿µÄÔö³¤£¬×ÀÃæÓû§ÔÚÊÜÒæÓÚ Linux ϵͳ¶Ô²¡¶¾½ÏÇ¿µÄÌìÈ»ÃâÒßÁ¦µÄͬʱ£¬Ò²ÐèҪɱ¶¾Èí¼þÇåÀí´ÓÍøÂç»òUÅÌ´øÀ´µÄWIndows²¡¶¾¡£¾¡¹ÜÄÇЩ ......
1£º Can’t connect to [local] MySQL server´íÎó
Ò»¸öMySQL¿Í»§¿ÉÒÔÁ½ÖÖ²»Í¬µÄ·½Ê½Á¬½Ómysqld·þÎñÆ÷£ºUnixÌ×½Ó×Ö£¬Ëüͨ¹ýÔÚÎļþϵͳÖеÄÒ»¸öÎļþ(ȱʡ“/tmp /mysqld.sock”)½øÐÐÁ¬½Ó£»»òTCP/IP£¬Ëüͨ¹ýÒ»¸ö¶Ë¿ÚºÅÁ¬½Ó¡£UnixÌ×½Ó×Ö±ÈTCP/IP¸ü¿ì£¬µ«ÊÇÖ»ÓÐÓÃÔÚÁ¬½Óͬһ̨¼ÆËã»úÉϵķþÎñÆ÷¡£Èç¹ûÄ ......
MACµØַΪÍø¿¨µÄÎïÀíµØÖ·£¬ÔÚWindowsϵͳÏ·dz£ÈÝÒ×Ð޸ģ¬ÔÚlinuxģʽÏÂÔòÓÐЩ¸´ÔÓ£¬ ÎÒÃÇ¿´¿´VMwareÐéÄâ»úÖÐÐÞ¸ÄLinux MACµØÖ·µÄ·½·¨
·½·¨Ò»£º
Õâ¸ö·½·¨×îÖ±½Ó¼òµ¥ÓÐЧ£¬ÐÞ¸ÄLinuxϵͳÀïÏà¹Ørc.localÎļþMACÖµ¼´¿É¡£
·½·¨¶þ£º
ÐÞ¸ÄÐéÄâ»úµÄ*.vmxÎļþ,ÕâÖÖ·½·¨×îÖµµÃÍƼö£¬ÒòΪÕâÑù¾ÍÀàËÆÓÚÖØГÉÕ¼”ÁËVMw ......
# uname -a
Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
(²é¿´µ±Ç°²Ù×÷ϵͳÄÚºËÐÅÏ¢)
# cat /etc/issue | grep Linux
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
(²é¿´µ±Ç°²Ù×÷ϵͳ·¢ÐаæÐÅÏ¢)
# cat /proc/cpuinfo | grep name | cut -f2 -d: ......
LinuxµÄI/O»úÖƾÀúÁËһϼ¸¸ö½×¶ÎµÄÑݽø£º
1. ͬ²½×èÈûI/O: Óû§½ø³Ì½øÐÐI/O²Ù×÷£¬Ò»Ö±×èÈûµ½I/O²Ù×÷Íê³ÉΪֹ¡£
2. ͬ²½·Ç×èÈûI/O: Óû§³ÌÐò¿ÉÒÔͨ¹ýÉèÖÃÎļþÃèÊö·ûµÄÊôÐÔO_NONBLOCK£¬I/O²Ù×÷¿ÉÒÔÁ¢¼´·µ»Ø£¬µ«ÊDz¢²»±£Ö¤I/O²Ù×÷³É¹¦¡£
3. Ò첽ʼþ×èÈûI/O: Óû§½ø³Ì¿ÉÒÔ¶ÔI/Oʼþ½øÐÐ×èÈû£¬µ«ÊÇI/O²Ù×÷²¢²»×èÈû¡£Í¨¹ýse ......