bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/13621] New: dangling global hidden symbol in symtab


From: mjw at redhat dot com
Subject: [Bug ld/13621] New: dangling global hidden symbol in symtab
Date: Tue, 24 Jan 2012 23:13:17 +0000

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

             Bug #: 13621
           Summary: dangling global hidden symbol in symtab
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: address@hidden
        ReportedBy: address@hidden
                CC: address@hidden
    Classification: Unclassified


gcc 4.7 (not yet released) introduces a new __TMC_END__ global hidden symbol to
mark the end of a .tm_clone_table section. When linking a program that doesn't
use any tm_clone_table entries the __TMC_END__ symbol is left in .symtab
pointing outside any section. For example just compiling an empty program int
main(int argc, char **argv) { return 0; } produces on x86_64 with gcc (GCC)
4.7.0 20120119
(Red Hat 4.7.0-0.8) and binutils-2.22-4.fc17.x86_64  a __TMC_END__ symbol in
.symtab that looks as follows:
   66: 0000000000600850      0 OBJECT  GLOBAL HIDDEN        24 __TMC_END__
Section 24 is:
[24] .data                PROGBITS     0000000000600848 00000848 00000004  0 WA
    0   0  4
So the address of __TMC_END__ is outside that section.

With gcc < 4.7 the following mimics what happens:

$ cat attrsec.c
typedef void (*func_ptr) (void);
static func_ptr __TMC_LIST__[]
  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void*))))
  = { };
extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden")));

void
deregister_tm_clones (void)
{
  if (__TMC_END__ - __TMC_LIST__ == 0)
    return;
}

func_ptr __TMC_END__[]
  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void *))))
  __attribute__((__visibility__ ("hidden"))) = { };

$ gcc -c attrsec.c 

$ readelf -a attrsec.o

[...]
  [ 5] .tm_clone_table   PROGBITS         0000000000000000  00000068
       0000000000000000  0000000000000000  WA       0     0     8
[...]
Symbol table '.symtab' contains 12 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS attrsec.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 
     5: 0000000000000000     0 SECTION LOCAL  DEFAULT    5 
     6: 0000000000000000     0 OBJECT  LOCAL  DEFAULT    5 __TMC_LIST__
     7: 0000000000000000     0 SECTION LOCAL  DEFAULT    7 
     8: 0000000000000000     0 SECTION LOCAL  DEFAULT    8 
     9: 0000000000000000     0 SECTION LOCAL  DEFAULT    6 
    10: 0000000000000000    34 FUNC    GLOBAL DEFAULT    1 deregister_tm_clones
    11: 0000000000000000     0 OBJECT  GLOBAL HIDDEN     5 __TMC_END__

$ cat attrsecmain.c 
int main (int argc, char **argv)
{
  deregister_tm_clones ();
  return 0;
}

$ gcc -o attrsec attrsec.o attrsecmain.c 

$ readelf -a attrsec
[...]
  [24] .data             PROGBITS         0000000000600898  00000898
       0000000000000004  0000000000000000  WA       0     0     4
[...]
    64: 00000000006008a0     0 OBJECT  GLOBAL HIDDEN    24 __TMC_END__

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]