This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug uprobes/12851] Wrong section group usage in <sys/sdt.h>


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]