[LLVMbugs] [Bug 9292] New: [MC assembler] .globl does not emit symbol if unreferenced

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 22 17:27:19 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9292

           Summary: [MC assembler] .globl does not emit symbol if
                    unreferenced
           Product: new-bugs
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: dimitry at andric.com
                CC: llvmbugs at cs.uiuc.edu


It looks like MC does not emit a global symbol into the destination
object file for a .globl directive, if the object is not referenced.

This is an unwanted optimization, since e.g. module loaders can depend
on specific symbols to always be available, so they use .globl to force
the linker to emit the symbol.

This substantially differs from GNU as's behaviour.  For example,
assemble the following sample file with GNU as and clang:

    .globl foo
    .globl bar
    mov %eax,bar

Running "readelf -s" over the object file that GNU as produces gives:

Symbol table '.symtab' contains 6 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1
     2: 00000000     0 SECTION LOCAL  DEFAULT    3
     3: 00000000     0 SECTION LOCAL  DEFAULT    4
     4: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND foo
     5: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND bar

Running "readelf -s" over the object file that GNU as produces gives:

Symbol table '.symtab' contains 5 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1
     2: 00000000     0 SECTION LOCAL  DEFAULT    2
     3: 00000000     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND bar

MC should *not* remove the 'foo' symbol from the table here.

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



More information about the llvm-bugs mailing list