public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug uprobes/12851] Wrong section group usage in <sys/sdt.h>
Date: Tue, 07 Jun 2011 14:42:00 -0000	[thread overview]
Message-ID: <bug-12851-6586-Yh1kpGLvxE@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-12851-6586@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=12851

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2011-06-07 14:42:08 UTC ---
(In reply to comment #3)
> 
> Why does it matter whether they are in the same section group or not?
> .stapsdt.base is in a comdat group, and so one copy will always be retained.
> 
> It looks like the linker is picking the wrong section, one that does get
> discarded. While ignoring the section that is being kept and should be used to
> link against.

No. Linker is correct.  YOU CAN'T HAVE LOCAL REFERENCES OUTSIDE OF
A COMDAT GROUP. In your case, you have

.pushsection .note.stapsdt,"?","note"
.balign 4
.4byte 992f-991f,994f-993f,3
991: .asciz "stapsdt"
992: .balign 4
993: .8byte 990b
.8byte _.stapsdt.base
.8byte 0
.asciz "libgcc"
.asciz "unwind"
.asciz "8@%rdi 8@%rsi"
994: .balign 4
.popsection

# 0 "" 2
# 1555 "/export/gnu/import/git/gcc-x32/libgcc/../gcc/unwind-dw2.c" 1
        .ifndef _.stapsdt.base
.pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat
.weak _.stapsdt.base
.hidden _.stapsdt.base
_.stapsdt.base: .space 1
.size _.stapsdt.base,1

Non comdat member section, .note.stapsdt, has a local
reference of _.stapsdt.base, which is defined in a comdat
section. Did you mean to put .note.stapsdt section in the same
comdat group as .stapsdt.base section?
> I am curious why we haven't seen this before.
> Against which binutils/linker is this?

You need glibc with systemtap support, like Fedora 15, to
see the problem:

[hjl@gnu-6 tmp]$ cat gcsec-1.c
/* AIX gld supports garbage collection. But AIX gcc does not support 
   -ffunction-sections or -fdata-sections.  */
/* { dg-do run { xfail rs6000-*-aix* powerpc*-*-aix* } } */
/* { dg-require-gc-sections "" } */

/* { dg-options "-ffunction-sections -fdata-sections -Wl,--gc-sections" } */
/* { dg-options "-ffunction-sections -fdata-sections -Wl,--gc-sections -static"
{ target static } } */

#include <stdlib.h>

static int unusedint=5;

static int usedint=1;

int unused(void) {
    return 1;
}

int foo(void) {
    return usedint;
}

int main(void) {

    if (foo())
        exit(0);
    else
        abort();
}
[hjl@gnu-6 tmp]$ gcc gcsec-1.c -ffunction-sections -fdata-sections
-Wl,--gc-sections -static -B/usr/bin/
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(setjmp.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(dl-lookup.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(__longjmp.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(__longjmp.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(dl-runtime.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(dl-runtime.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(dl-sym.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/libgcc_eh.a(unwind-dw2.o): defined in
discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
`.text' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(fork.o):
defined in discarded section `.text' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(fork.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(fork.o):
defined in discarded section `.stapsdt.base[.stapsdt.base]' of
/usr/lib/gcc/x86_64-redhat-linux/4.6.0/../../../../lib64/libc.a(libc-lowlevellock.o)
collect2: ld returned 1 exit status
[hjl@gnu-6 tmp]$

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

  parent reply	other threads:[~2011-06-07 14:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07  3:15 [Bug uprobes/12851] New: " hjl.tools at gmail dot com
2011-06-07 11:33 ` [Bug uprobes/12851] " mjw at redhat dot com
2011-06-07 13:11 ` hjl.tools at gmail dot com
2011-06-07 13:59 ` mjw at redhat dot com
2011-06-07 14:42 ` hjl.tools at gmail dot com [this message]
2011-06-08 15:16 ` mjw at redhat dot com
2011-06-08 15:44 ` hjl.tools at gmail dot com
2011-06-08 15:44 ` hjl.tools at gmail dot com
2011-06-08 17:39 ` [Bug ld/12851] " hjl.tools at gmail dot com
2011-06-08 17:40 ` [Bug ld/12851] --gc-sections doesn't work on comdat sections hjl.tools at gmail dot com
2011-06-08 20:09 ` [Bug ld/12851] --gc-sections doesn't work on note sections hjl.tools at gmail dot com
2011-06-08 20:11 ` hjl.tools at gmail dot com
2011-06-09  4:53 ` cvs-commit at gcc dot gnu.org
2011-06-09 12:43 ` hjl.tools at gmail dot com
2011-06-14  2:46 ` cvs-commit at gcc dot gnu.org
2011-06-14  2:48 ` cvs-commit at gcc dot gnu.org

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=bug-12851-6586-Yh1kpGLvxE@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /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).