[LLVMbugs] [Bug 9744] New: clang++ emits wrong section name for x86_64-w64-mingw32 target
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Apr 18 09:03:04 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9744
Summary: clang++ emits wrong section name for
x86_64-w64-mingw32 target
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: coolypf at qq.com
CC: llvmbugs at cs.uiuc.edu
Consider the following code:
#include <stdio.h>
#include <string>
using std::string;
int main()
{
string a(" test");
a = "a" + a;
printf("%s\n", a.c_str());
return 0;
}
'clang++ -m32 -S' generates code like this:
... ...
.def __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_;
.scl 2;
.type 32;
.endef
.section
.text$_ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_,"xr"
.linkonce discard
.globl __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_
.align 16, 0x90
__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_:
... ...
'clang++ -m64 -S' generates code like this:
... ...
.def _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_;
.scl 2;
.type 32;
.endef
.section
.text$ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_,"xr"
.linkonce discard
.globl _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_
.align 16, 0x90
_ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_:
... ...
The section name in the latter code is wrong.
It should still be
.text$_ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_
instead of
.text$ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_
Unlike symbol names, the underscore can't be removed.
For the wrong section name, as fails to generate COMDAT, leading to link errors
like this:
d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.4.6/libstdc++.a(string-inst.o): In
function `std::basic_string<char, std::char_traits<char>, std::allocator<char>
> std::operator+<char, std::char_traits<char>, std::allocator<char> >(char
const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&)':
D:/MinGW/build/x86_64-w64-mingw32/libstdc++-v3/include/bits/basic_string.tcc:694:
multiple definition of `std::basic_string<char, std::char_traits<char>,
std::allocator<char> > std::operator+<char, std::char_traits<char>,
std::allocator<char> >(char const*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
C:/Users/coolypf/AppData/Local/Temp/cc-939574.o:fake:(.text$ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_+0x0):
first defined here
collect2: ld returned 1 exit status
clang++: error: linker (via gcc) command failed with exit code 1 (use -v to see
invocation)
Link will succeed if I manually modify the section names, then as & ld.
--
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