public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Weak symbols and gcc3.1
@ 2002-04-07 17:13 Boehm, Hans
  2002-04-07 20:54 ` Alan Modra
  2002-04-08 14:05 ` Richard Henderson
  0 siblings, 2 replies; 3+ messages in thread
From: Boehm, Hans @ 2002-04-07 17:13 UTC (permalink / raw)
  To: 'gcc@gcc.gnu.org'; +Cc: 'tromey@redhat.com'

My garbage collector contains code which can be distilled down to the
following test case:

#include <stdio.h>
#include <elf.h>
#include <link.h>

#pragma weak _DYNAMIC

int main()
{
  extern ElfW(Dyn) _DYNAMIC[];
  printf("%lx\n", &_DYNAMIC);
  return 0;
}

For old versions of gcc, this used to work as expected, i.e. it linked for
both dynamic and static executables, eventhough _DYNAMIC was not defined in
the latter case.  With gcc3.1, I get a link error in the static case.  The
reference to _DYNAMIC is no longer madee weak.  The .weak directive is no
longer in the assembly code.  (This was tested on IA64, but I suspect it's
more generic than that.)

This breaks statically linked gcj executables.

Questions:

1) Is this intentional?

2) If so, how should the above code be rewritten?

3) If this is unintentional, any hints as to where/how things broke?  In
this case, it seems to me that it needs to be fixed for 3.1.

Thanks.

Hans

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weak symbols and gcc3.1
  2002-04-07 17:13 Weak symbols and gcc3.1 Boehm, Hans
@ 2002-04-07 20:54 ` Alan Modra
  2002-04-08 14:05 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Modra @ 2002-04-07 20:54 UTC (permalink / raw)
  To: Boehm, Hans; +Cc: 'gcc@gcc.gnu.org', 'tromey@redhat.com'

On Sun, Apr 07, 2002 at 04:28:48PM -0700, Boehm, Hans wrote:
> 
> #pragma weak _DYNAMIC
> 
> int main()
> {
>   extern ElfW(Dyn) _DYNAMIC[];
>   printf("%lx\n", &_DYNAMIC);
>   return 0;
> }

Move the declaration of _DYNAMIC to give it file scope, or use
__attribute__ ((weak)).

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Weak symbols and gcc3.1
  2002-04-07 17:13 Weak symbols and gcc3.1 Boehm, Hans
  2002-04-07 20:54 ` Alan Modra
@ 2002-04-08 14:05 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2002-04-08 14:05 UTC (permalink / raw)
  To: Boehm, Hans; +Cc: 'gcc@gcc.gnu.org', 'tromey@redhat.com'

On Sun, Apr 07, 2002 at 04:28:48PM -0700, Boehm, Hans wrote:
> 1) Is this intentional?

No, but I can't think of how to fix it easily.

> 2) If so, how should the above code be rewritten?

Move the declaration of _DYNAMIC to file scope.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-08 20:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-07 17:13 Weak symbols and gcc3.1 Boehm, Hans
2002-04-07 20:54 ` Alan Modra
2002-04-08 14:05 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).