public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: "David S. Miller" <dm@neteng.engr.sgi.com>
To: gcc2@cygnus.com
Cc: gas2@cygnus.com
Subject: global vars and symbol visibility for mips32/elf
Date: Fri, 09 Aug 1996 02:46:00 -0000	[thread overview]
Message-ID: <199608090946.CAA27226@neteng.engr.sgi.com> (raw)

I have this problem and I don't know who exactly (binutils or gcc) is
causing the problem.  Hopefully with the homework I have done my
debugging information will allow someone to see what and where the
problem is.

I have support for Linux/MIPS written for gcc/binutils.  It uses the
generic elf32-mips support in binutils.  I am also using GNU libc to
link against.  Here is the delimma:

When running c-torture I get a failure for execute/960218-1.c which
looks like:

int glob;

g (x)
{
  glob = x;
  return 0;
}

f (x)
{
  int a = ~x;
  while (a)
    a = g (a);
}

main ()
{
  f (3);
  if (glob != -4)
    abort ();
  exit (0);
}

The problem is caused by the symbol 'glob'.  GNU libc also has a
symbol glob.  The assembly output by gcc for the glob variable in the
960218-1.c test case looks like:

        .comm   glob,4,4

And that is it.  When assembled by gas into an object file it's symbol
entry looks like.

00000004 C glob

Now when it is linked, the problem occurs, the linker decides to
override this symbol with the symbol for 'glob' in GNU libc, so in the
final executable image glob is undefined and will be resolved at
dynamic link time.  This of course causes the test to erroneously
write into the elf pltgot stub instructions when assigning values to
the variable 'glob' in the test program.

More data points.  The symbol table entry for 'glob' in my shared GNU
libc looks like:

600462f0 A glob

I played around with the native assembler/linker under IRIX6.2 using
gcc and here is what I found them to be doing when compiling this
program.

gcc for the IRIX6.2 target outputs the glob symbol information in the
same way as my MIPS/Linux gcc does:

        .comm   glob,4

The IRIX6.2 assembler also created the symbol in the same way within
the object file:

00000004 C glob

The IRIX6.2 linker however places this symbol in the MIPS_ACOMMON
section of the resulting executable and does not override using the
libc symbol of the same name (the shared IRIX libc does in fact have a
symbol named 'glob' just like my MIPS/Linux GNU libc does).

[37]    | 268505200|       4|OBJT |GLOB |DEFAULT  |MIPS_ACOMMON|glob

The IRIX6.2 compiler outputs the 'glob' symbol differently in the
resulting assembly.

        .globl  glob
        .lcomm  glob 4

Does anyone know who is at fault here (gcc, binutils, or my GNU libc
for some reason) and how this problem can be resolved?

This is all using the latest snapshots of gas and gcc btw.

dm@engr.sgi.com

'Ooohh.. "FreeBSD is faster over loopback, when compared to
Linux over the wire". Film at 11.' -Linus


             reply	other threads:[~1996-08-09  2:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-09  2:46 David S. Miller [this message]
1996-08-09  5:24 ` David S. Miller
1996-08-09  9:01   ` Ian Lance Taylor
1996-08-09  8:30 ` Ian Lance Taylor
1996-08-09 13:13   ` Ulrich Drepper
1996-08-09 15:30     ` Ian Lance Taylor
1996-08-10 17:37       ` Richard Stallman
1996-08-10 19:41         ` Ian Lance Taylor
1996-08-10 23:26           ` Jim Wilson
1996-08-11  1:44           ` Richard Stallman
1996-08-13 10:58           ` Ruediger Helsch
1996-08-13 13:36             ` Jim Wilson
1996-08-13 16:06               ` Ruediger Helsch
1996-08-13 19:04                 ` Jim Wilson
1996-08-13 21:02                   ` Richard Stallman
1996-08-14  3:06                     ` Ruediger Helsch
1996-08-14 23:44                       ` Richard Stallman
1996-08-14  0:18                 ` Nick Ing-Simmons
1996-08-14  3:06                   ` Ruediger Helsch
1996-08-15 11:24                   ` H.J. Lu
1996-08-13  9:06 ` Ruediger Helsch
1996-08-13 10:58   ` Richard Stallman
1996-08-13 13:36     ` Ruediger Helsch
1996-08-13 13:36       ` Richard Stallman
1996-08-13 14:40       ` H.J. Lu
1996-08-13 16:06       ` Ulrich Drepper
1996-08-13 16:06         ` Joe Buck
1996-08-13 17:02         ` Rohan LENARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199608090946.CAA27226@neteng.engr.sgi.com \
    --to=dm@neteng.engr.sgi.com \
    --cc=gas2@cygnus.com \
    --cc=gcc2@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).