This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: is main() provided by a library valid C ?
On Wed, May 18, 2005 at 10:23:24PM +0200, Peter S. Mazinger wrote:
> On Wed, 18 May 2005, Daniel Jacobowitz wrote:
>
> > On Wed, May 18, 2005 at 09:34:53PM +0200, Peter S. Mazinger wrote:
> > > On Fri, 13 May 2005, Daniel Jacobowitz wrote:
> > >
> > > > On Fri, May 13, 2005 at 09:47:01AM +0200, Peter S. Mazinger wrote:
> > > > > The circumstances:
> > > > > The weak definition of main() is moved from libc.so to crt1.o written in
> > > > > asm as '.protected main'.
> > > >
> > > > Why?
> > > >
> > > > You certainly can't declare main as a protected symbol if it lives in a
> > > > library. I don't see why you want it to be a protected symbol, either.
> > >
> > > I wasn't clear enough.
> > > libc does not define anything about main (not even as weak:
> > > glibc/uclibc/dietlibc). It is obvious that it can't be defined as
> > > protected in a library. To remove any weak declaration of main from libc,
> > > one solution was to put it into crt1.o. This change (although .protected)
> > > does not fail on most of the apps, but fails 2 tests (subversion and
> > > bind), because those tests "deliver" main() from a library.
> > >
> > > My question is:
> > > Is it valid to provide main() from a library or not? If it is valid, then
> > > the solution to do '.protected main' in crt1.S is not ok and/or linker
> > > fails. If it is not valid, then the apps themselves should be corrected.
> >
> > No, my question above is my response to this, which is what I figured
> > you were doing. You haven't explained why you're making this change.
> > What is the problem with a weak reference from libc?
>
> the change would be "good to have", to be able to build libc w/ -z defs,
> that weak is "disturbing" this ;)
Then how about doing it the same way glibc does, by a non-protected
reference?
You're going to a lot of effort to do something invalid, for a cosmetic
benefit.
--
Daniel Jacobowitz
CodeSourcery, LLC