This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug report: objc classes linked in wrong order
- To: law at cygnus dot com
- Subject: Re: Bug report: objc classes linked in wrong order
- From: nicola at brainstorm dot co dot uk
- Date: Tue, 30 May 2000 12:20:39 +0100 (BST)
- cc: rth at cygnus dot com, hjl at lucon dot org, egcs at sourceware dot cygnus dot com, ovidiu at cup dot hp dot com, gcc at gcc dot gnu dot org
> > Can I make an objective-C class weak ?
> I can't think of a reason why that wouldn't work.
> > I found no evidence of this - because each module has a list of classes to
> > load, and loads them all - but I might be wrong - so please give me a hint
> > if I actually can in some way make a class weak.
> But they are "loaded" by the linker by including them in the final
> executable, right? If so, at the .s/.o level you make the appropriate
> function(s) weak, then you should be OK.
Uhm - hope you are right :-) - that would be nice if we could
have 'weak' classes.
To me it looks difficult because my understanding of it is as follows:
[from libobjc/init.c]
/* This function is called by constructor functions generated for each
module compiled. (_GLOBAL_$I$...) The purpose of this function is to
gather the module pointers so that they may be processed by the
initialization routines as soon as possible */
void
__objc_exec_class (Module_t module)
So, the constructor functions contain a call of this function for each
module that gets loaded (they indeed do). The module is represented by a
structure, created at compile time [defined in libobjc/objc/objc-api.h].
A pointer to this structure is passed as argument to __objc_exec_class ().
__objc_exec_class () accesses the members of the module structure
getting the list of selectors and classes to register.
It accesses the list of classes as follows:
loop on i
{
Class class = (Class) module->symtab->defs[i];
...
}
which returns a structure containing the information needed to register
the new class with the runtime.
I can't see any function or symbol we could make weak.
Making __objc_exec_class weak is not what we want - that function is
global. The classes to load are got accessing directly the pointer passed
as argument of __objc_exec_class - don't see what we can make weak here.
Any idea ?
Thanks for discussing - that helps a lot - sorry if I miss some basic
point.