Previous Next Contents

5. Primary C library·Î ¼³Ä¡Çϱâ

Glibc 2¸¦ ÁÖ C ¶óÀ̺ê·Î¸®·Î ¼³Ä¡ÇÏ´Â ¹æ¹ýÀ» ¼³¸íÇÏ°Ú´Ù. ÁÖ C ¶óÀ̺귯¸®·Î ¼³Ä¡ ÇÑ´Ù´Â °ÍÀº ´ç½ÅÀÌ ÄÄÆÄÀÏÇÏ´Â ÇÁ·Î±×·¥À» glibc·Î ¸µÅ©µÇ°Ô ÇÏ´Â °ÍÀÌ´Ù. ¹°·Ð, ´Ù¸¥ ¹öÀü¿¡ ¸µÅ©½Ãų·Á¸é ÄÄÆÄÀÏ ¿É¼ÇÀ» Ãß°¡½ÃÄѼ­ ÄÄÆÄÀÏÇÏ¸é µÈ´Ù.

¸¸¾à ´ç½ÅÀÌ ·¹µåÇòÀ̳ª µ¥ºñ¾ÈÀ» »ç¿ëÇÏ°í ÀûÀýÇÑ rpm ÆÄÀÏÀ̳ª deb ÆÄÀÏÀ» ´Ù¿îÇß¾ú´Ù¸é, ·¹µåÇòÀ̳ª µ¥ºñ¾ÈÀÇ ¼³Ä¡ ¾È³»¸¦ ÀÐ¾î º¸¾Æ¶ó. ±×·¯¸é, ¿©±âÀÖ´Â ³»¿ëÀ» ÀÐÁö ¾Ê¾Æµµ µÈ´Ù.

5.1 ¼Ò½º·ÎºÎÅÍ ¶óÀ̺귯¸®¸¦ ¼³Ä¡Çϱâ

¿©±â¿¡¼­´Â ¼Ò½º·ÎºÎÅÍ glibc 2¿Í add-ons¸¦ ÄÄÆÄÀÏÇÏ´Â ¹æ¹ýÀ» ¼³¸íÇÏ·Á°í ÇÑ´Ù. ÃÖÀûÈ­ ¿É¼ÇÀ̳ª ±¸¼º ¿É¼ÇÀ» º¯°æÇÏ°í ½Í°Å³ª ¹ÙÀ̳ʸ®¿¡ ¾ø´Â ÆÐÅ°Áö¸¦ »ç¿ëÇÏ·Á°í ÇÒ ¶§ ¶óÀ̺귯¸®¸¦ ÄÄÆÄÀÏÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

ÀüÁ¦ Á¶°Ç

RAM 64 MBÀÎ i586@133 ÄÄÇ»ÅÍ¿¡¼­ Ãß°¡ ¶óÀ̺귯¸®(add-ons)Æ÷ÇÔÇÑ Àüü ¶óÀ̺귯¸® ¸¦ ÄÄÆÄÀÏÇϴµ¥ ¼Ò¿ä ½Ã°£Àº ¾à 3½Ã°£À̸ç, i686@2¿¡ ÄÄÇ»ÅÍÀÇ °æ¿ì´Â ¾à 1½Ã°£ 30ºÐ Á¤µµ °É·È´Ù.

¼Ò½º¸¦ ÃßÃâÇϱâ

¼Ò½º ÆÄÀÏÀ» ÄÄÆÄÀÏÇϱâ À§Çؼ­´Â Archives¿¡¼­ ¼Ò½º ÆÄÀÏÀ» ÃßÃâÇؾ߸¸ ÇÑ´Ù. ¾Æ·¡¿Í °°ÀÌ ÇÏ¸é µÈ´Ù:

 tar xzf glibc-2.0.5.tar.gz
 cd glibc-2.0.5
 cat ../glibc-2.0.5-2.0.5c.diff.gz | gzip -d | patch -p0
 tar xzf ../glibc-linuxthreads-2.0.5.tar.gz
 tar xzf ../glibc-crypt-2.0.5.tar.gz
 tar xzf ../glibc-localedata-2.0.5.tar.gz
 
À§ÀÇ ¹æ¹ýó·³ Çϸé, glibc-2.0.5 µð·ºÅ丮¿¡ linuxthreads, crypt, localeddata µð·ºÅ丮°¡ »ý¼ºµÈ´Ù. ÀÌ·¸°Ô ÇؾßÁö¸¸ configure°¡ Ãß°¡µÈ ¶óÀ̺귯¸® µð·ºÅ丮¸¦ ãÀ» ¼ö ÀÖ´Ù.

Configure¸¦ ½ÇÇàÇϱâ

glibc-2.0.5 µð·ºÅ丮¿¡¼­ "compile"À̶õ µð·ºÅ丮¸¦ ¸¸µé°í, cd·Î 'compile' µð·ºÅ丮·Î ¿Â´Ù. ¸ðµç ÀÛ¾÷Àº ÀÌ compile µð·ºÅ丮¿¡¼­ ÀÌ·ç¾îÁø´Ù.

mkdir compile
cd compile

À§ÀÇ °úÁ¤À» ¸¶ÃÆÀ¸¸é, '../configure'À» ½ÇÇà½ÃÅ°¸é µÈ´Ù. Ãß°¡ ÆÐÅ°Áö¸¦ »ç¿ëÇÏ°í ½ÍÀ¸¸é, Ãß°¡ ÆÐÅ°Áö¿¡ ´ëÇÑ ¿É¼Ç(--enable-add-ons <¿¹> --enable-add-ons=linuxthreads,crypt,localedata)À» Æ÷ÇÔ½ÃÄÑ¾ß ÇÑ´Ù. ¶Ç ¼³Ä¡ÇÏ°í ½ÍÀº µð·ºÅ丮¸¦ ¼±ÅÃÇØ¾ß ÇÑ´Ù. º¸Åë ¼³Ä¡ µð·ºÅ丮·Î '--prefix=/usr'À» »ç¿ëÇÑ´Ù. ´ÙÀ½Àº configure lineÀÇ ¿¹ÀÌ´Ù:

 ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr

ÄÄÆÄÀÏÇϱâ

ÄÄÆÄÀÏÇÏ°í Á¦´ë·Î µÇ¾ú´ÂÁö È®ÀÎÇÏ´Â ÀýÂ÷´Â ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

 make
 make check
 

5.2 ¼³Ä¡Çϱâ À§ÇÑ Áغñ ÀÛ¾÷Çϱâ

¼Ò½º·ÎºÎÅÍ ¼³Ä¡Çßµç, ¹ÙÀ̳ʸ® ÆÄÀÏ·Î ¼³Ä¡Çßµç glibc 2¶óÀ̺귯¸® ¼³Ä¡ ÁغñÇϱâ À§Çؼ± ¾î¶² ÆÄÀÏÀ» ¿Å±æ ÇÊ¿ä°¡ ÀÖ´Ù. ÀÌÀ¯´Â ¾ÕÀ¸·Î ÄÄÆÄÀÏ ÇÒ »õ·Î¿î ÇÁ·Î±×·¥À» glibc¿¡ ¸µÅ©½ÃÅ°°í, Á¤ÀûÀ¸·Î ¸µÅ©µÇÁö ¾Ê´Â ±¸ ÇÁ·Î±×·¥Àº ¿©ÀüÈ÷ libc 5¿¡ ÀÇÁ¸ ÇÏ°Ô ÇϱâÀ§Çؼ­ÀÌ´Ù. °í·Î ±¸ ¹öÀü¿¡ µ¤¾î ¾²Áö ¾Ê¾Æ¾ßÇÑ´Ù.

  1. ±¸ ÆÄÀÏ(libc 5)À» ÀúÀåÇÒ »õ·Î¿î µð·ºÅ丮¸¦ ¸¸µç´Ù:
     mkdir -p /usr/i486-linuxlibc5/lib
     
    
  2. ±¸(libc 5¿ë) Çì´õ ÆÄÀÏÀ» /usr/include ¿¡¼­ ´Ù¸¥ µð·ºÅ丮·Î ¿Å±ä´Ù:
     mv /usr/include /usr/i486-linuxlibc5/include
     
    
  3. »õ·Î¿î(glibc 2¿ë) include µð·ºÅ丮¸¦ ¸¸µé°í, ´Ù¸¥ include¿¡ ¸µÅ©½ÃŲ´Ù:
     mkdir /usr/include
    
     ln -s /usr/src/linux/include/linux /usr/include/linux
     ln -s /usr/src/linux/include/asm /usr/include/asm
     ln -s /usr/X11R6/include/X11 /usr/include/X11
     ln -s /usr/lib/g++-include /usr/include/g++
     
    
    ¸µÅ©´Â ¹èÆ÷ÆÇ¿¡ µû¶ó¼­ ¾à°£ ´Ù¸¦¼ö ÀÖ´Ù. Àû¾îµµ ½½·º¿þ¾îÀÇ °æ¿ì /usr/local/g++-include¿¡ g++ Çì´õÆÄÀÏÀÌ ÀÖ°í, ¹Ý¸é¿¡ µ¥ºñ¾È ÆÐÅ°Áö °æ¿ì /usr/include/g++¿¡ g++Çì´õÆÄÀÏÀÌ ÀÖ°í, /usr/lib/g++-include´Â /usr/include/g++ ¿¡ ¸µÅ©µÇ¾î ÀÖ´Ù. ÈÄÀÚÀÇ °æ¿ì, ¾Æ¸¶ ´ç½ÅÀº ¿ø·¡ g++ include µð·ºÅ丮¸¦ /usr/include¿¡ ¿Å±â±æ ¿øÇÒ °ÍÀÌ´Ù.
  4. ´Ù¸¥ Çì´õ ÆÄÀÏÀ» º¹¿øÇÏ°í ¸µÅ©ÇÑ´Ù. ¾î¶² ºñÇ¥ÁØ ¶óÀ̺귯¸®°æ¿ì, ¿¹·Î ncureses, /usr/include¿¡ Çì´õÆÄÀÏÀ» ³õ°Å³ª /usr/include ¹Ø¿¡ ÀÖ´Â ±×µéÀÇ include µð·ºÅ丮¿¡ ¸µÅ©¸¦ ÇÑ´Ù. ÀÌ ÆÄÀϵéÀ̳ª ¸µÅ©´Â ´Ù¸¥ ¶óÀ̺귯¸®¸¦ ÀûÀýÈ÷ »ç¿ëµÉ¼ö ÀÖ°Ô º¹¿øÀ» ÇØ µÑ ÇÊ¿ä°¡ ÀÖ´Ù.
  5. /etc/ld.so.confÆÄÀÏ ¸ÇÀ§¿¡ glibc 2¿ë ¶óÀ̺귯¸® µð·ºÅ丮(¿¹, / usr/i486-linuxlibr/lib)¸¦ Ãß°¡ÇÑ´Ù. glibc¸¦ ¼³Ä¡ÇÒ ¶§ ÀÌ»óÇÑ ¸Þ¼¼Áö¸¦ ÇÇÇϱâ À§Çؼ­´Â ld.so-1.8.8ÀÌ»óÀÇ ¹öÀüÀ» ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù.
  6. ±¸ C ¶óÀ̺귯¸®¸¦ »õ·Î¿î µð·ºÅ丮(/usr/i486-linuxlibc5/lib)·Î ¿Å±â°Å³ª º¹»çÇÑ´Ù.
     mv /usr/lib/libbsd.a /usr/i486-linuxlibc5/lib
     mv /usr/lib/libc.a /usr/i486-linuxlibc5/lib
     mv /usr/lib/libgmon.a /usr/i486-linuxlibc5/lib
     mv /usr/lib/libm.a /usr/i486-linuxlibc5/lib
     mv /usr/lib/libmcheck.a /usr/i486-linuxlibc5/lib
     mv /usr/lib/libc.so /usr/i486-linuxlibc5/lib
     mv /usr/lib/libm.so /usr/i486-linuxlibc5/lib
     cp /lib/libm.so.5.* /usr/i486-linuxlibc5/lib
     cp /lib/libc.so.5.* /usr/i486-linuxlibc5/lib
     
    
    ¸¸¾à /usrÀÌ /¿Í ´Ù¸¥ ÆÄƼ¼Ç¿¡ ÀÖ´Ù¸é, libm.so.5¿Í libc.so.5´Â move°¡ ¾Æ´Ñ º¹»çµÇ¾î¾ß ÇÑ´Ù. ÀÌÀ¯´Â ¸®´ª½º¸¦ ½ÃÀÛÇϴµ¥ ÇÊ¿äÇÑ ÇÁ·Î±×·¥ÀÌ libm.so.5¿Í libc.so.5¸¦ »ç¿ëÇϱ⶧¹®ÀÌ°í À̰͵éÀº ·çÆ® µð·ºÅ丮¿¡ ÀÖ¾î¾ß¸¸ ÇÑ´Ù.
  7. /usr/lib/*.o ÆÙÀÏÀ» »õ·Î¿î µð·ºÅ丮·Î ¿Å±ä´Ù.
     mv /usr/lib/crt1.o /usr/i486-linuxlibc5/lib
     mv /usr/lib/crti.o /usr/i486-linuxlibc5/lib
     mv /usr/lib/crtn.o /usr/i486-linuxlibc5/lib
     mv /usr/lib/gcrt1.o /usr/i486-linuxlibc5/lib
     
    
  8. ´ç½ÅÀÇ ¶óÀ̺귯¸®¸¦ ¿Å°åÀ¸¸é ¶óÀ̺귯¸® cache¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù.
     ldconfig -v
     
    

5.3 ¹ÙÀ̳ʸ® ÆÐÅ°Áö·ÎºÎÅÍ ¼³Ä¡Çϱâ

¹Ì¸® ÄÄÆÄÀÏµÈ ¹ÙÀ̳ʸ®·ÎºÎÅÍ glibc¸¦ ¼³Ä¡ÇÏ°íÀÚ Çϸé, ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

 cd /
 gzip -dc glibc-2.0.bin.i386.tar.gz | tar tvvf -
 gzip -dc glibc-crypt-2.0.bin.i386.tar.gz | tar tvvf -
 ldconfig -v
 
´Ù¸¥ architecture³ª ´Ù¸¥ ¹öÀüÀ» °¡Áö°í ÀÖ´Ù¸é, ÀûÀýÇÑ ÆÄÀÏ À̸§À¸·Î ¹Ù²Ù¸é µÈ´Ù.

5.4 ¼Ò½º·ÎºÎÅÍ ¼³Ä¡Çϱâ

¼Ò½º·ÎºÎÅÍ ¶óÀ̺귯¸®¸¦ ¼³Ä¡ÇÏ·Á¸é, ´ÙÀ½À» ½ÇÇàÇ϶ó:

 make install
 ldconfig -v
 

5.5 gcc specs À» ¾÷µ¥ÀÌÆ®Çϱâ

¹ÙÀ̳ʸ®·ÎºÎÅÍ ¼³Ä¡ÀÌµç ¼Ò½º·ÎºÎÅÍ ¼³Ä¡ÇÏµç ¸¶Áö¸· ´Ü°è´Â gcc specs ÆÄÀÏÀ» ¾÷µ¥ÀÌÆ®ÇÏ´Â °ÍÀÌ´Ù. ±×·¡¾ß¸¸ ´ç½Å ÇÁ·Î±×·¥ÀÌ ÀûÀýÇÏ°Ô ¸µÅ©µÉ ¼ö ÀÖ´Ù. gcc°¡ »ç¿ëÇÏ´Â specs ÆÄÀÏÀ» ¾Ë¾Æ³»±â À§Çؼ­´Â ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù:

 % gcc -v
 reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
 gcc version 2.7.2.2
 

ÀÌ °æ¿ì´Â i486-unknown-linux ½Ã½ºÅÛÀÌ°í ¹öÀüÀÌ 2.7.2.2ÀÌ´Ù. ´ç½ÅÀÌ ÇؾßÇÒ ÀÏÀº /usr/lib/gcc-lib/<system>À» ±¸ ½Ã½ºÅÛ µð·ºÅ丮·Î º¹»çÇÏ´Â °ÍÀÌ´Ù:

 cd /usr/lib/gcc-lib/
 cp -r i486-unknown-linux i486-linuxlibc5
 

±× ´ÙÀ½ ´ÙÀ½°ú °°ÀÌ Ç϶ó.

 cd /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2
 

ÀÌ µð·ºÅ丮¿¡¼­ 'specs'ÆÄÀÏÀ» ÆíÁýÇÑ´Ù. Áï specs ÆÄÀϳ»¿¡ /lib/ld-linux.so.1À» /lib/ld-linux.so.2·Î ¹Ù²Û´Ù. ¶Ç %{...:-lgmon} °¡ µé¾î°£ ¸ðµç ¹®ÀåÀ» Áö¿ö¶ó. ¿Ö³Ä¸é glibc´Â profileÇϱâ À§Çؼ­ gmon ¶óÀ̺귯¸®¸¦ »ç¿ëÇÏÁö ¾Ê±â ¶§¹®ÀÌ´Ù. »ùÇà specs ÆÄÀÏÀº »ùÇà specs ÆÄÀÏ´Ü¿ø¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

5.6 ¼³Ä¡µÈ°ÍÀ» Å×½ºÆ®Çϱâ

¿ì¼± ´ÙÀ½°ú °°Àº ÆÄÀÏ(glibc.c)¸¦ ¸¸µç´Ù:

 #include <stdio.h>

 main()
 {
     printf("hello world!\n");
 }
 
±×¸®°í ÄÄÆÄÀÏÇÑ´Ù.
 % gcc glibc.c -o glibc
 
ldd¸¦ ÀÌ¿ëÇÏ¿©¼­ ÇÁ·Î±×·¥ÀÌ glibc2¿¡ ¸µÅ©µÇ¾ú´ÂÁö È®ÀÎÇغ»´Ù:
 % ldd glibc
 libc.so.6 => /lib/libc.so.6 (0x4000e000)
 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
 
ÄÄÆÄÀÏÀÌ µÇ°í, ¸µÅ© °úÁ¤µµ Á¤»óÀ̸ç, ½ÇÇà½Ã "hello world!" °¡ Ãâ·ÂÀÌ µÈ´Ù¸é, ¼³Ä¡´Â ¼º°øÀûÀ¸·Î ³¡³­ °ÍÀÌ´Ù. (ÃàÇÏ....^^)


Previous Next Contents