This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/19636: [x86] Resolve undefweak and defined symbols in executable
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 24 Feb 2016 09:04:50 -0800
- Subject: Re: [PATCH] PR ld/19636: [x86] Resolve undefweak and defined symbols in executable
- Authentication-results: sourceware.org; auth=none
- References: <20160223175814 dot GA2858 at intel dot com> <alpine dot LSU dot 2 dot 20 dot 1602241541430 dot 20277 at wotan dot suse dot de> <CAMe9rOoxU43=dhGYZZGQtWhfbU-sGRoaiiJ7PfPNtzSc05-t-A at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1602241552020 dot 20277 at wotan dot suse dot de> <CAMe9rOpEWKVVP=-o0t0emkjKR0-xqnn-YZ5C5nfa=0E4BkEZaw at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1602241709410 dot 20277 at wotan dot suse dot de> <CAMe9rOr5qa_PBJA3oDENWErRfrojtzC1ncXaWwyh-1EAczPn-g at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1602241749340 dot 20277 at wotan dot suse dot de> <CAMe9rOrSNYV_x-5aU7K+hXHNrinE9Co8y1F5VUkY+SoRQize=g at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1602241753490 dot 20277 at wotan dot suse dot de>
On Wed, Feb 24, 2016 at 8:58 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Wed, 24 Feb 2016, H.J. Lu wrote:
>
>> >> My change will make ld guarantees the consistent behavior, regardless
>> >> PIC or non-PIC.
>> >
>> > As you keep repeating this, I'll do so as well: yes, and you resolved
>> > that consistency into the wrong direction, break PIC and non-PIC,
>> > instead of fixing both. That makes no sense, just because there are
>> > broken circumstances should not make us break all others as well.
>>
>> You keep saying non-PIC is broken, which I disagree.
>
> Simple, if this testcase (which unlike your made-up ones to show various
> inconsistencies actually does occur in the wild) doesn't print "works", I
> call it broken:
>
> % cat main.c
> extern int __attribute__ ((weak)) printme (void);
> void
> main (void)
> {
> if (printme)
> printme ();
> }
> % cat lib.c
> #include <stdio.h>
> void printme (void)
> {
> printf ("works\n");
> }
> % gcc -fPIC -shared -o lib.so lib.c
> % gcc -fPIC -o main main.c
> % LD_PRELOAD=./lib.so ./main
> works
>
> I can't fathom why anyone would call the above behaviour unexpected or
> broken, or would desire the above to _not_ print "works".
>
This is the unintended behavior, similar to LD_DYNAMIC_WEAK in
ld.so.
--
H.J.