Apories (kai pali :))

Alexios Chouchoulas alexios at vennea.demon.co.uk
Wed Apr 30 05:06:10 EEST 1997


On Wed, 30 Apr 1997, Harris Kosmidhs wrote:

> Alla den katalaba kati.
> Ego otan kano compile ena programma px to xearth auto kanei automata link?
> Mporo na to po na mhn kanei h na kanei statically?
> Otan apo thn allh kano ena diko mou programmataki px "Hello world !" auto
> ti ginetai? 

  Otan kaleis ton gcc xwris sygkekrimenes odhgies, pernaei ton kwdika sou
apo ta ekshs stadia:

  * Preprocessing: expand macros, include header files.
  * Compilation: C -> Assembly.
  * Assembly: C -> Object code.
  * Linking. Object code -> Executable binary file.

  Afto tha ginei otan kaneis, px, "gcc hello_world.c -o hello_world". Sto
man page/info page tou GCC leei pws na ton anagkaseis na kanei mono ena apo
ta parapanw stadia. Synithws ton trexoume ws katharo compiler (me to -c) mia
fora gia kathe module tou kwdika kai meta kanoume link ta modules (to
katalabainei monos tou otan tou dineis object files (.o) ws source files).

  Twra, to linking ginetai me to ld(1), ara eksartatai apo to leitourgiko
kai thn ekdosh tou ld(1).

  Se ena Linux me shared libraries, exeis dyo eidh linking:

  Static linking (-static parametros): static kwdikas olwn twn apaitoumenwn
      bibliothikwn eisagetai sto binary, fouskwnontas to san mpaloni. 
      Prosoxh: merikes bibliothikes mporei na mhn yparxoun se static morfh
      (.a synithws), opote mporei kapoies bibliothikes na ginoun dynamically
      linked.

  Dynamic linking: sto stadio tou linking pou ginetai apo to ld(1) otan to
      kalei o GCC (h otan to kaleis esy me to xeri), ta unresolved symbols
      ginontai resolved basei twn symbol tables pou exoun oi shared
      bibliothikes. Ta onomata twn apaitoumenwn bibliothikwn katagrafontai
      (dokimase kai san ldd /bin/bash gia na to deis afto) kai dhmiourgeitai
      ena hmiteliko symbol table pou leei se poia bibliothikh kai pou tha
      breis ta symbola pou leipoun apo to programma sou. An kapoio symbolo
      den brethei katholou stis bibliothikes, to ld(1) sou ftynei lathos.

      Otan trekseis to programma, ginetai aftomata "dynamic linking": oi
      bibliothikes pou apaitei to programma fortwnontai sthn mnhmh kai to
      symbol table tou programmatos diorthwnetai gia na deixnei sta library
      functions sthn mnhmh. Afto einai teleiws aorato apo ton xrhsth kai
      toso grhgoro pou den to prosexeis genika.

  Yp'opsin oti afta ta egrapsa apo genikes gnwseis panw stous
compilers/linkers kai ta DLLs/shared objects. Den kserw leptomereies gia thn
leitourgia tou ELF, opote o,ti egrapsa parapanw mporei na einai blakeia. Oi
basikes arxes paramenoun, pantws (dyo kommatia tou linking otan
xrhsimopoieis shared libraries, ena kommati gia ta static binaries).


Alexios Chouchoulas          '88    ,88'   ,88'     alexios at vennea.demon.co.uk
The Unpronouncable One      ,o88oooo88ooooo88oo,              axc at dcs.ed.ac.uk

--
====================================================================
Gia na mathete pos na xrisimopoiite ton majordomo, stilte e-mail
sto "majordomo at argeas.argos.hol.gr" me 1 grammi sto keimeno: help
Ta archives tis listas einai sto http://www.argos.hol.gr/lists
Gia opoiodipote problima stilte  e-mail ston owner-linux-greek-users
====================================================================



More information about the Linux-greek-users mailing list