public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: ld-related bug in LTTng
       [not found]   ` <CACsXv7BvXJR7+R_tTLk623Oez1ihhe1mL5HjowYqTunxsV_zqQ@mail.gmail.com>
@ 2014-05-01 23:23     ` Alan Modra
  2014-05-02 22:40       ` Martin Ünsal
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2014-05-01 23:23 UTC (permalink / raw)
  To: Martin Ünsal; +Cc: binutils

On Thu, May 01, 2014 at 10:52:23AM -0700, Martin Ãœnsal wrote:
[Re: http://gcc.gnu.org/ml/gcc-help/2014-04/msg00164.html
https://sourceware.org/ml/binutils/2012-06/msg00176.html and
https://sourceware.org/ml/binutils/2012-05/msg00232.html]

> So the real mystery is why the __start___tracepoints_ptrs symbol
> changed from local to global scope.

Right.

> Any ideas?

Is gcc emitting the reference to __start___tracepoints_ptrs as hidden?
(Look at an object with readelf -s to see)

> I am not a toolchain
> expert unfortunately. Do you think this could be an unintended side
> effect of your change, or should I be looking elsewhere?

It's not impossible that there was an unintended side effect, but I
did test current mainline, 2.24 and 2.23 without seeing a problem.

cat > sym.s <<EOF
 .text
 .weak start_text
 .hidden start_text
 .dc.a start_text

 .data
 .weak start_data
 .hidden start_data
 .dc.a start_data

 .weak __start_mysec
 .hidden __start_mysec
 .dc.a __start_mysec
EOF
cat > mysec.s <<EOF
 .section mysec,"aw",@progbits
 .dc.a 0xc0ffee
EOF
cat > sym.t <<EOF
SECTIONS
{
  . = SIZEOF_HEADERS;
  .text :
  {
    start_text = .;
    *(.text)
  }
  .data :
  {
    start_data = ABSOLUTE(.);
    *(.data)
  }
}
EOF
as -o sym.o sym.s
as -o mysec.o mysec.s
ld -o sym.so -shared sym.o mysec.o -T sym.t

On x86_64 using 2.22 ld, readelf -sD sym.so gives me
    3   1: 00000000000000b0     0 NOTYPE  LOCAL  DEFAULT   1 start_text
    4   2: 00000000000002c8     0 NOTYPE  LOCAL  DEFAULT ABS __start_mysec
    2   2: 00000000000001c8     0 NOTYPE  LOCAL  DEFAULT ABS start_data

For 2.23 and later
    3   1: 00000000000000b0     0 NOTYPE  LOCAL  DEFAULT   1 start_text
    4   2: 00000000000002c8     0 NOTYPE  LOCAL  DEFAULT   8 __start_mysec
    2   2: 00000000000001c8     0 NOTYPE  LOCAL  DEFAULT ABS start_data

As you can see, all the symbols are local..

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld-related bug in LTTng
  2014-05-01 23:23     ` ld-related bug in LTTng Alan Modra
@ 2014-05-02 22:40       ` Martin Ünsal
  2014-05-03 13:34         ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Ünsal @ 2014-05-02 22:40 UTC (permalink / raw)
  To: binutils

On Thu, May 1, 2014 at 4:23 PM, Alan Modra <amodra@gmail.com> wrote:
> Is gcc emitting the reference to __start___tracepoints_ptrs as hidden?
> (Look at an object with readelf -s to see)

Aha! No, it isn't.

With GCC 4.6.4 the symbol is correctly emitted as hidden visibility:

$ arm-linux-gnueabi-readelf -s pmtrace_bundle_provider.o | grep __start_
   153: 00000000     0 NOTYPE  WEAK   HIDDEN   UND __start___tracepoints_ptr

With GCC 4.7.2 the symbol is incorrectly emitted as default visibility:

$ arm-linux-gnueabi-readelf -s pmtrace_bundle_provider.o | grep __start_
   144: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __start___tracepoints_ptr

Here is the declaration:

extern struct tracepoint * const __start___tracepoints_ptrs[]
__attribute__((weak, visibility("hidden")));

This looks like it is clearly a compiler issue. I will take this back
to gcc-help mailing list.

Thanks for the help,
Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld-related bug in LTTng
  2014-05-02 22:40       ` Martin Ünsal
@ 2014-05-03 13:34         ` Alan Modra
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2014-05-03 13:34 UTC (permalink / raw)
  To: Martin Ünsal; +Cc: binutils

On Fri, May 02, 2014 at 03:40:10PM -0700, Martin Ãœnsal wrote:
> On Thu, May 1, 2014 at 4:23 PM, Alan Modra <amodra@gmail.com> wrote:
> > Is gcc emitting the reference to __start___tracepoints_ptrs as hidden?
> > (Look at an object with readelf -s to see)
> 
> Aha! No, it isn't.
> 
> With GCC 4.6.4 the symbol is correctly emitted as hidden visibility:
> 
> $ arm-linux-gnueabi-readelf -s pmtrace_bundle_provider.o | grep __start_
>    153: 00000000     0 NOTYPE  WEAK   HIDDEN   UND __start___tracepoints_ptr
> 
> With GCC 4.7.2 the symbol is incorrectly emitted as default visibility:
> 
> $ arm-linux-gnueabi-readelf -s pmtrace_bundle_provider.o | grep __start_
>    144: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __start___tracepoints_ptr
> 
> Here is the declaration:
> 
> extern struct tracepoint * const __start___tracepoints_ptrs[]
> __attribute__((weak, visibility("hidden")));
> 
> This looks like it is clearly a compiler issue. I will take this back
> to gcc-help mailing list.

It might be worth checking the assembly output, to rule out as
assembler issue.  gcc -S with

extern void *const x __attribute__ ((weak, visibility ("hidden")));
void *const foo (void) { return x; }

on my powerpc 4.7.2 compiler emits
...
	.weak	x
	.hidden	x

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-03 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CACsXv7DMNwLfR521KXEw7SkN7Y8Tm13m+=x_T9yuWMcT-SiRpQ@mail.gmail.com>
     [not found] ` <20140501073529.GI16139@bubble.grove.modra.org>
     [not found]   ` <CACsXv7BvXJR7+R_tTLk623Oez1ihhe1mL5HjowYqTunxsV_zqQ@mail.gmail.com>
2014-05-01 23:23     ` ld-related bug in LTTng Alan Modra
2014-05-02 22:40       ` Martin Ünsal
2014-05-03 13:34         ` Alan Modra

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).