Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Mathieu Lacage <mathieu.lacage@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: baffling assembly-level weirdness
Date: Tue, 27 Jan 2009 17:53:00 -0000	[thread overview]
Message-ID: <8ac60eac0901270953y5352df9bk8ffbccf5a84920f4@mail.gmail.com> (raw)
In-Reply-To: <74fef6df0901270509s3d6d2075rb08989ea7e886823@mail.gmail.com>

On Tue, Jan 27, 2009 at 5:09 AM, Mathieu Lacage
<mathieu.lacage@gmail.com> wrote:

> 3) the main executable has a global stdout variable which is
> referenced by the code in the main binary and initialized by a
> R_386_COPY relocation:
> mathieu@mathieu-boulot:~/code/elf-loader$ readelf -s /bin/ls|grep stdout@
>    93: 0805e3c0     4 OBJECT  GLOBAL DEFAULT   25 stdout@GLIBC_2.0 (2)
> mathieu@mathieu-boulot:~/code/elf-loader$ readelf -r /bin/ls|grep 0805e3c0
> 0805e3c0  00005d05 R_386_COPY        0805e3c0   stdout
> which is expected to copy the value of the stdout symbol from the libc.so.6
...
> As a side-note, I really wonder why (3): none of the executables I
> link myself contain an stdout variable so, I am somewhat curious as to
> where this is coming from (I would expect each access to stdout from
> the main binary to directly reference the symbol from the libc through
> the GOT). But, well, next time.

Seems pretty normal to me:

$ cat t.c
#include <stdio.h>

int main()
{
    fprintf(stdout, "Hello\n");
    return 0;
}

$ /usr/bin/gcc --version
gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
...

$ /usr/bin/gcc t.c && readelf -s a.out | grep stdout
     5: 080495a0     4 OBJECT  GLOBAL DEFAULT   23 stdout@GLIBC_2.0 (2)
    75: 080495a0     4 OBJECT  GLOBAL DEFAULT   23 stdout@@GLIBC_2.0

$ readelf -r a.out | grep 080495a0
080495a0  00000505 R_386_COPY        080495a0   stdout

Cheers,
-- 
Paul Pluzhnikov


      reply	other threads:[~2009-01-27 17:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-26 15:24 Mathieu Lacage
2009-01-26 15:38 ` Pierre Muller
2009-01-26 17:35   ` Mathieu Lacage
2009-01-26 15:41 ` Daniel Jacobowitz
2009-01-26 16:51   ` Paul Pluzhnikov
2009-01-27 13:09     ` Mathieu Lacage
2009-01-27 17:53       ` Paul Pluzhnikov [this message]

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=8ac60eac0901270953y5352df9bk8ffbccf5a84920f4@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb@sourceware.org \
    --cc=mathieu.lacage@gmail.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