[OSy] Linkovani

Petr Tuma petr.tuma at dsrg.mff.cuni.cz
Mon Dec 31 08:22:59 CET 2007


Nasel jste to dobre :) dokonce to neni bug ale feature:

      The linker will search an archive only once, at the location where
      it is specified on the command line.  If the archive defines a
      symbol which was undefined in some object which appeared before
      the archive on the command line, the linker will include the
      appropriate file(s) from the archive.  However, an undefined
      symbol in an object appearing later on the command line will not
      cause the linker to search the archive again.

      See the `-(' option for a way to force the linker to search
      archives multiple times.

S temi archivy je zda se malem vic prace nez uzitku :(

Petr Tuma


Miloslav Beno wrote:
> Uz jsme na to prisli. Pro ostatni co narazi na podobny problem:
> 
> Pred:
> $(LD) --verbose -T ../libc/binary.lds -G 0 -static ../libc/libc.a  $(OFILES_EXE)-o $@ -Map $(EXENAME).map
> 
> Po:
> $(LD) --verbose -T ../libc/binary.lds -G 0 -static $(OFILES_EXE) ../libc/libc.a -o $@ -Map $(EXENAME).map
> 
> 
> -----Original Message-----
> From: osy-bounces at dsrg.mff.cuni.cz [mailto:osy-bounces at dsrg.mff.cuni.cz] On Behalf Of Miloslav Beno
> Sent: Sunday, December 30, 2007 10:25 PM
> To: 'Operating Systems Course'
> Subject: Re: [OSy] Linkovani
> 
> Chybejici podtrzitko v __entry byl preklep v mailu, to se omlouvame
> 
> Zkusili jsme k uzivatelskemu programu prilinkovat object soubory definujici  printk (jinak obsazene v libc.a) a program se prelozil a spustil v poradku.
> 
> Problem tedy mame opravdu jen s tim, jak nacist tyto reference z archivu libc.a
> 
> 
> 
> -----Original Message-----
> From: osy-bounces at dsrg.mff.cuni.cz [mailto:osy-bounces at dsrg.mff.cuni.cz] On Behalf Of Petr Tuma
> Sent: Sunday, December 30, 2007 10:11 PM
> To: Operating Systems Course
> Subject: Re: [OSy] Linkovani
> 
> Dobry den,
> 
>> Pojmenovane stejne opravdu jsou. Co je mysleno tim, ze jsou na spravnem miste jako export a import?
>>
>> libc.a
>> 00000370 g     F .text  0000003c printk
>>
>> main.o
>> 00000000         *UND*  00000000 printk
> 
> Ten dump vypada v poradku, jestli neco nepletu tak libc.a spravne 
> exportuje globalni funkci printk a main.o importuje printk ...
> 
> Co ten postreh pana Jermare o nadbytecnem podtrzitku u _entry (jestli to 
> ovsem neni nejake jine __entry, ktere mate v entry.o a ne to _entry v 
> libc.a) ?
> 
> Z tech vypisu tabulek symbolu to opravdu vypada ze by vse melo byt OK. 
> Zkusil jste vyjmout ten soubor, ve kterem je printk, z libc.a a linkovat 
> primo s nim, jestli se neco nezmeni ?
> 
> Petr Tuma
> 
>>
>> -----Original Message-----
>> From: osy-bounces at dsrg.mff.cuni.cz [mailto:osy-bounces at dsrg.mff.cuni.cz] On Behalf Of Petr Tuma
>> Sent: Sunday, December 30, 2007 9:07 PM
>> To: Operating Systems Course
>> Subject: Re: [OSy] Linkovani
>>
>> Dobry vecer,
>>
>>> Zkusili jsme to prelozit do elf, ale linker funkci printk nenasel.
>>> Zkontrolovali jsme i nazvy a parametry,vse sedi. Pro jistotu
>>> prikladam vystup.
>> Zkusil bych objdump -t na tu .a knihovnu a main.o, jestli jsou ty 
>> symboly v obou souborech opravdu stejne pojmenovane a na spravnem miste 
>> jako export a import ...
>>
>> Petr Tuma
>>
>>
>>> STARTUP(../libc/entry.o) ENTRY(__entry)
>>>
>>> SECTIONS { .uspace 0x00000000 : { *(.text) *(.data) *(.rodata
>>> .rodata.*) *(.bss) *(COMMON) }
>>>
>>> /DISCARD/ : { *(.reginfo) } }
>>>
>>> ================================================== attempt to open
>>> ../libc/entry.o succeeded ../libc/entry.o attempt to open
>>> ../libc/libc.a succeeded (../libc/libc.a)_main.o attempt to open
>>> main.o succeeded main.o main.o: In function `main': 
>>> /afs/ms/u/b/benom4am/lammaos/apps/main.c:12: undefined reference to
>>> `printk' make: *** [app.lamma] Error 1
>>>
>>>
>>> -----Original Message----- From: osy-bounces at dsrg.mff.cuni.cz
>>> [mailto:osy-bounces at dsrg.mff.cuni.cz] On Behalf Of Petr Tuma Sent:
>>> Sunday, December 30, 2007 8:47 PM To: Operating Systems Course 
>>> Subject: Re: [OSy] Linkovani
>>>
>>> Dobry vecer,
>>>
>>> tusim tu pred nejakou dobou pan Decky zminoval, ze kdyz se jako
>>> vystupni format pouziva rovnou binary, linker nehlasi unresolved
>>> symbols. Cituji:
>>>
>>> "Jiny zadrhel (na ktery jsme tady uz upozornovali) by hypoteticky
>>> mohl byt v tom, ze linker pro MIPS, pokud vytvari primo flat soubor
>>> (tj. OUTPUT(binary)), tak si z nejakeho duvodu vubec nestezuje na
>>> chybejici symboly. Je potreba nejdrive linkovat do ELF a ten teprve
>>> pomoci objcopy zkonvertovat na binary."
>>>
>>> Zkuste vystup do elf, jestli dostanete nejakou rozumnou hlasku ?
>>>
>>> Petr Tuma
>>>
>>>
>>> Miloslav Beno wrote:
>>>> Dobry vecer,
>>>>
>>>> Mame knihovnu libc.a, ve ktere jsou funkce _entry, _main,  printk,
>>>> kazda ve svem object souboru.
>>>>
>>>> V uzivatelskem programu pak je funkce main, ze ktere  se vola
>>>> printk. Problem je, ze linker pri sestavovani uzivatelskeho
>>>> programu do binary formatu najde a prilinkuje funkce
>>>> (libc.a)_entry, (libc.a) _main, (main.o)main . ale uz neprilinkuje
>>>> (libc.a)printk. GCC nenahlasi ani, ze funkce printk neni definovana
>>>> a pri spusteni uzivatelsky program na tomto volani padne.
>>>>
>>>> $(LD) --verbose -T ../libc/binary.lds -G 0 -static ../libc/libc.a 
>>>> $(OFILES_EXE) -o $@
>>>>
>>>>
>>>> Binary.lds:
>>>>
>>>> STARTUP(../libc/entry.o) OUTPUT_FORMAT(binary) OUTPUT_ARCH(mips)
>>>>
>>>> SECTIONS { .uspace 0x00000000 : { *(.text) *(.data) *(.rodata
>>>> .rodata.*) *(.bss) *(COMMON) }  /DISCARD/ : { *(.reginfo) } }
>>>>
>>>>
>>>> Predem dekujeme za reakce.
>>>>
>>>>
>>>> _______________________________________________ OSy mailing list 
>>>> OSy at dsrg.mff.cuni.cz https://dsrg.mff.cuni.cz/mailman/listinfo/osy
> 

-- 
Petr Tuma
Distributed Systems Research Group
Department of Software Engineering
Faculty of Mathematics and Physics
Charles University, Czech Republic
   http://dsrg.mff.cuni.cz/~ceres




More information about the NSWI004 mailing list