[LLVMbugs] [Bug 12623] New: [MC assembler] Using .symver directives can make symbols disappear
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Apr 22 13:29:17 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12623
Bug #: 12623
Summary: [MC assembler] Using .symver directives can make
symbols disappear
Product: new-bugs
Version: trunk
Platform: PC
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
Classification: Unclassified
Clang's integrated assembler seems to have trouble when .symver
directives are used in inline assembly, and even more so when using -g.
(I am currently using branches/release_31 r155231, but trunk has the
same behaviour.)
Consider the following sample code, extracted from FreeBSD's malloc
implementation:
const char *__malloc_options_1_0;
__asm__(".symver __malloc_options_1_0, _malloc_options at FBSD_1.0");
When this is compiled using gcc, the resulting .o file has:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 l d .comment 00000000 .comment
00000004 O *COM* 00000004 __malloc_options_1_0
00000004 O *COM* 00000004 _malloc_options at FBSD_1.0
Using -g makes no difference for gcc, at least not for the above
symbols:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_pubnames 00000000 .debug_pubnames
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 l d .comment 00000000 .comment
00000004 O *COM* 00000004 __malloc_options_1_0
00000004 O *COM* 00000004 _malloc_options at FBSD_1.0
When you use clang with its defaults, the resulting .o file misses both
the __malloc_options_1_0 and the _malloc_options at FBSD_1.0 symbols:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
When you use clang with just -g, the resulting .o file misses just the
__malloc_options_1_0 symbol, and has only the other one:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_macinfo 00000000 .debug_macinfo
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_pubtypes 00000000 .debug_pubtypes
00000000 l d .debug_str 00000000 .debug_str
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000004 O *UND* 00000004 _malloc_options at FBSD_1.0
Now, if you start using -no-integrated-as, the situation changes:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000004 O *COM* 00000004 __malloc_options_1_0
00000004 O *COM* 00000004 _malloc_options at FBSD_1.0
Similar for using -g -no-integrated-as:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_macinfo 00000000 .debug_macinfo
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_pubtypes 00000000 .debug_pubtypes
00000000 l d .debug_str 00000000 .debug_str
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000004 O *COM* 00000004 __malloc_options_1_0
00000004 O *COM* 00000004 _malloc_options at FBSD_1.0
So clang's integrated assembler seems to remove symbols in some cases.
Is this correct? The relevant assembly generated by clang shows:
# Start of file scope inline assembly
.symver __malloc_options_1_0, _malloc_options at FBSD_1.0
# End of file scope inline assembly
.type __malloc_options_1_0, at object # @__malloc_options_1_0
.comm __malloc_options_1_0,4,4
Last but not least, if you simply assign something to the global, the
problem seems to disappear, e.g:
const char *__malloc_options_1_0 = 0;
__asm__(".symver __malloc_options_1_0, _malloc_options at FBSD_1.0");
results in:
SYMBOL TABLE:
00000000 l df *ABS* 00000000 symcompat.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 g O .bss 00000004 __malloc_options_1_0
00000000 g O .bss 00000004 _malloc_options at FBSD_1.0
where the symbols end up in .bss, and apparently don't get eliminated.
--
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