gnupic: linker optimizations (was: Re: gplink missing symbols)


Previous by date: 23 Jan 2005 02:39:27 +0000 Re: gplink missing symbols, Craig Franklin
Next by date: 23 Jan 2005 02:39:27 +0000 Re: Pic18Forth pre-pre-pre-alpha, David McNab
Previous in thread:
Next in thread:

Subject: linker optimizations (was: Re: gplink missing symbols)
From: Craig Franklin ####@####.####
Date: 23 Jan 2005 02:39:27 +0000
Message-Id: <41F30EBB.5040406@users.sourceforge.net>

George M. Gallant wrote:

> What about "weak" symbols. Those that are declared extern but never 
> referenced. Any way
> to weed them out?
>
Done.

The changes will be in cvs and the snapshot shortly.  It has been on my 
TODO list for a while.

Any extern symbol which isn't used by a relocation is weak.  The weak 
symbols are removed from the objects when they are read from the file or 
extracted from an archive for linking.  Only the object in memory is 
modified, the file and the archive are untouched.  It is done before 
symbols are resolved, so it will prevent including unnecessary objects 
from archives.

This is the first step in gplink becoming an optimizing linker.  There 
are four levels 0 through 3.  The level is specified using -OX, were X 
is the optimization level.  0 is simple linking with no optimization.  1 
and higher enables removing weak symbols.  More optimizations are being 
defined and implemented.  Of course increasing the level will increase 
the link time speed.  For now, the default level is 1.

> George
>
> Craig Franklin wrote:
>
>> Vangelis Rokas wrote:
>>
>>> There is an issue with gplink when resolving symbols from archives.
>>> The problem appears when linking an object with two or more archives
>>> and the later archives depend on symbols defined in the earlier 
>>> archive.
>>>
>>> An example would be like this:
>>>
>>> gplink -m -o out main.o lib1.lib lib2.lib
>>>
>>> Suppose that lib1.lib contains the symbol foo1
>>> and lib2.lib uses this symbol.
>>>
>>> gplink exits with missing symbol error message.
>>>
>>> This could be fixed by modifying build_tables in gplink/gplink.c
>>> to pass twice while loop around the scan_archives() function
>>> call.
>>> This way missing symbols from libraries that will be introduced
>>> in later libraries (i.e. lib2.lib) can be resolved by symbols in 
>>> earlier
>>> libraries (i.e. lib1.lib).
>>>
>>> In fact 'twice' might not be the appropriate number, but we could
>>> continue passing until the is no change in the result of 
>>> count_missing()
>>> function.
>>>
>>> What's you opinion Craig?
>>>
>>>  
>>>
>> mplink does allow this, so I have modified gplink.  The update is in 
>> cvs and the snapshot.  Try it out and let me know how it works for you.
>>
>> The new version repeats the archive scan if there are missing symbols 
>> and if an object was loaded from an archive on that pass.  This 
>> should support any link list provided by the user.  Of course, the 
>> extra loops will require more link time, so it is best to keep the 
>> link list as simple as possible.
>>
>>
>>> regards,
>>> Vangelis
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ####@####.####
>>> For additional commands, e-mail: ####@####.####
>>>
>>>
>>>  
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ####@####.####
>> For additional commands, e-mail: ####@####.####
>>
>>
>
>
>


Previous by date: 23 Jan 2005 02:39:27 +0000 Re: gplink missing symbols, Craig Franklin
Next by date: 23 Jan 2005 02:39:27 +0000 Re: Pic18Forth pre-pre-pre-alpha, David McNab
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.