public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Geoff Keating <geoffk@ozemail.com.au>
To: hjl@lucon.org
Cc: drepper@cygnus.com, ian@cygnus.com,
	binutils@sourceware.cygnus.com,
	libc-hacker@sourceware.cygnus.com, jgg@ualberta.ca
Subject: Re: A glibc dynamic linker or gld bug?
Date: Mon, 05 Jul 1999 02:38:00 -0000	[thread overview]
Message-ID: <199907050455.OAA00862@geoffk.wattle.id.au> (raw)
In-Reply-To: <19990704205206.7C71E57B9@ocean.lucon.org>

> Mailing-List: contact libc-hacker-help@sourceware.cygnus.com; run by ezmlm
> Date: Sun, 4 Jul 1999 13:52:06 -0700 (PDT)
> Cc: ian@cygnus.com (Ian Lance Taylor), binutils@sourceware.cygnus.com,
>         libc-hacker@sourceware.cygnus.com (GNU C Library), jgg@ualberta.ca
> From: hjl@lucon.org (H.J. Lu)
> 
> Hi,
> 
> Here is a testcase for a glibc dynamic linker or gld bug:
> 
> # make
> cc -shared -o libfoo.so -fPIC -O -g foo.c
> cc -o bar1.o -c -fPIC -O -g bar.c
> cc -o foo1 -O -g libfoo.so main.c bar1.o -Wl,-rpath,.
> cc -o bar2.o -c -O -g bar.c
> cc -o foo2 -O -g libfoo.so main.c bar2.o -Wl,-rpath,.
> for f in foo1 foo2; do echo "Running: $f"; ./$f; \
>   if [ $? != 0 ]; then echo Failed; fi; done
> Running: foo1
> Failed
> Running: foo2
> 
> The same testcase ran fine under Solaris/x86 and Solaris/Sparc even
> with the GNU ld. I suspect the bug is in the weak symbol handling 
> in the glibc dynamic linker. Since the Solaris dynamic linker treats
> weak as strong, the bug may also be in gld.

I can't reproduce this on ppc with binutils snapshot from 981225, and
the released 2.1.1 ld.so.

I suspect there is a (possibly machine-specific) bug in your ld; in
fact, I would suspect the problem is in linking PIC code into
executables.

On my machine, the dynamic linker has no influence whatsoever on
whether 'abort' is called in foo1 or foo2.  The complete list of
relocations generated is:

[geoffk@geoffk shared2]$ objdump -R foo1

foo1:     file format elf32-powerpc

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE 
018406d4 R_PPC_JMP_SLOT    abort
018406dc R_PPC_JMP_SLOT    __libc_start_main

and it's the same for foo2.

This is correct.  There is no way that a weak symbol defined in an
executable can be overriden by anything else, so there should be no
relocations referring to it.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>

  reply	other threads:[~1999-07-05  2:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-04 13:52 H.J. Lu
1999-07-05  2:38 ` Geoff Keating [this message]
1999-07-05  7:41   ` Jason Gunthorpe
1999-07-05 20:48   ` Richard Henderson
1999-07-06  1:01     ` Geoff Keating
1999-07-06 12:16       ` Geoff Keating
1999-07-06 19:11     ` Ian Lance Taylor
1999-07-06 19:28       ` Richard Henderson
1999-07-06 19:31         ` Ian Lance Taylor
1999-07-06 21:45       ` H.J. Lu
1999-07-07  7:36         ` Ian Lance Taylor
1999-07-07  7:39           ` H.J. Lu
1999-07-07  7:44             ` Ian Lance Taylor
1999-07-07  7:57               ` H.J. Lu
1999-07-07  8:03                 ` Ian Lance Taylor
1999-07-07 20:12               ` Geoff Keating
1999-07-07 20:16                 ` Ian Lance Taylor
1999-07-07  1:33       ` Geoff Keating
1999-07-07  7:35         ` Ian Lance Taylor
1999-07-07 11:22         ` Ian Lance Taylor
1999-07-07 20:13           ` Geoff Keating
1999-07-07 20:28             ` Ian Lance Taylor
1999-07-08 17:29               ` Geoff Keating
1999-07-09  6:11                 ` Franz Sirl
1999-07-10  3:14                   ` Geoff Keating
1999-07-10  5:40                     ` Ian Lance Taylor

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=199907050455.OAA00862@geoffk.wattle.id.au \
    --to=geoffk@ozemail.com.au \
    --cc=binutils@sourceware.cygnus.com \
    --cc=drepper@cygnus.com \
    --cc=hjl@lucon.org \
    --cc=ian@cygnus.com \
    --cc=jgg@ualberta.ca \
    --cc=libc-hacker@sourceware.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).