This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: R_X86_64_COPY bug
- From: Fredrick Prashanth John Berchmans <fredrickprashanth at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org, Suresh Siddha <sbsiddha at gmail dot com>, binutils at sourceware dot org, hjl dot tools at gmail dot com, nasuku at yahoo dot com, Alexander Ivchenko <aivchenk at gmail dot com>
- Date: Mon, 8 Apr 2013 09:50:39 -0700
- Subject: Re: R_X86_64_COPY bug
- References: <CACwgvgW5SNsXL2vND_qhgqO7RRsHwKyk+N-q5sTakeC9vwV0BA at mail dot gmail dot com> <20130406071305 dot GD3208 at bubble dot grove dot modra dot org> <CALmL7E92MjbsXbou8T3w895G9ahtd1tvC2JwREwV9EzT4Px20Q at mail dot gmail dot com> <CACysShj5aH4pWZHjxj74-B7z8a8d_NTKUyEcN8DFJXxaCa5=6g at mail dot gmail dot com> <CACwgvgXgjfwK9+HNRwyJMO-uJWM+WU9idj5gdBxJWr538rQRWQ at mail dot gmail dot com> <CACwgvgU9Gs0HUMU+Q2Hojx-y4s+FLzWarBEPHq+DCWfvTBa34A at mail dot gmail dot com> <51614E9B dot 4080007 at redhat dot com>
On Sun, Apr 7, 2013 at 3:46 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 04/07/2013 03:48 AM, Fredrick Prashanth John Berchmans wrote:
>>
>> A struct with zero length array is defined in a shared library as a global
>> data.
>> A binary links with this shared library and accesses the struct.
>> Because of copy relocation semantics, the binary linking with that
>> library sees(correctly) only the portion of the struct without the
>> zero length array.
>> We understand that it is due to the wrong or apparent size calculation
>> of the struct by GCC and using copy relocation semantics to resolve this
>> shared symbol is causing this problem.
>
>
> This seems to be a bug in GCC:
>
>
> .globl test_dynamic
> .data
> .align 4
> .type test_dynamic, @object
> .size test_dynamic, 4
> test_dynamic:
> .long 6
> .long 1
> .long 2
> .long 3
> .long 4
> .long 5
> .long 6
>
> The .size directive is wrong. I couldn't find anything matching in
> Bugzilla, so you probably should file a new bug.
>
Filed.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56880
> As a workaround, you could declare the struct object in question as static.
> This should disable copy relocation.
>
> --
> Florian Weimer / Red Hat Product Security Team