This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Add a weak definition of mep_di to MeP's libgloss


> Hi Konrad,

> > If you wish to override the definition of a symbol, add an object
> > [...] defining that symbol
> > before the library containing the overridden definition.
> 
> The problem with this solution is that it requires a specific link 
> order.  I cannot guarantee that the user will specify the 
> libraries and 
> object files in the correct order on the linker command line 
> to achieve 
> this effect.

I don't use newlib at the moment, but: normally, when invoking the
linker through the compiler driver, the C library and other internal
libraries, such as libgloss.a should be added to the end of the user's
command line  automatically.

Furthermore, I'm not sure that weak does the right thing: if the
non-weak definition happens to be in an archive *behind* newlib (or
libgloss), and the symbol has already been resolved by the weak
definition in newlib, will the member containing the non-weak definition
be extracted?

 > Thus,
> > adding weak definitions to existing members (object files) 
> will bloat
> > the linker's output (perhaps only slightly, as in the case 
> below) when
> > that member is extracted for other reasons.  
> 
> True, but if the size of the final executable is a real concern then 
> compiling all archives with -ffunction-sections and enabling 
> link time 
> garbage collection would resolve this issue for most cases.  
> (Although 
> technically not in this particular case since the weak symbol is 
> explicitly placed in the same section as the function that 
> refers to it).

Exactly.  The user will need to know about these options; such a savvy
user will also know of the significance of archive order.  Note that
link time garbage collection is not enabled by default, probably with
good reason: because it is not always applicable.

All these complications are avoided if "fall-back" definitions are put
into individual .o files.  This is completely independent of whether to
mark the definition weak or not.

Newlib is a _library_.  By definition, it is used in projects we have
absolutely no knowledge about.  Who are we to decide whether the size of
the final executable is a real concern or not?

Regards,

Konrad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]