<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - functions with weak_odr linkage place in 32-bit code section in arm coff"
href="https://llvm.org/bugs/show_bug.cgi?id=24808">24808</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>functions with weak_odr linkage place in 32-bit code section in arm coff
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pagingio@163.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>given
target datalayout =
"e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7--windows-msvc"
; Function Attrs: inlinehint nounwind
define weak_odr arm_aapcs_vfpcc i32 @vsprintf(i8* %_Buffer, i8* %_Format, i8*
%_ArgList) #0 {
%1 = alloca i8*, align 4
%2 = alloca i8*, align 4
%3 = alloca i8*, align 4
store i8* %_ArgList, i8** %1, align 4
store i8* %_Format, i8** %2, align 4
store i8* %_Buffer, i8** %3, align 4
%4 = load i8** %1, align 4
%5 = load i8** %2, align 4
%6 = load i8** %3, align 4
%7 = call arm_aapcs_vfpcc i32 @_vsnprintf_l(i8* %6, i32 -1, i8* %5,
%struct.__crt_locale_pointers* null, i8* %4)
ret i32 %7
}
Section selection for "vsprintf" is wrong. In generated coff object file,
vsprintf is placed in 32-bit code section. When linking with other object
files, instructions calling this function will be fixed with a "blx". This will
cause a run time crash since it will trigger a mode switch from thumb-2 into
arm, while instruction set for windows on arm is strictly limited to thumb-2.
A possible fix:
const MCSection *TargetLoweringObjectFileCOFF::
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler &Mang, const TargetMachine &TM) const {
// If we have -ffunction-sections then we should emit the global value to a
// uniqued section specifically for it.
bool EmitUniquedSection;
if (Kind.isText())
EmitUniquedSection = TM.getFunctionSections();
else
EmitUniquedSection = TM.getDataSections();
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
// Section names depend on the name of the symbol which is not feasible if
the
// symbol has private linkage.
if ((GV->isWeakForLinker() || EmitUniquedSection || GV->hasComdat()) &&
!Kind.isCommon()) {
const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
unsigned Characteristics = getCOFFSectionFlags(Kind);
Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
int Selection = getSelectionForCOFF(GV);
if (!Selection)
Selection = COFF::IMAGE_COMDAT_SELECT_NODUPLICATES;
const GlobalValue *ComdatGV;
if (GV->hasComdat())
ComdatGV = getComdatGVForCOFF(GV);
else
ComdatGV = GV;
if (!ComdatGV->hasPrivateLinkage()) {
MCSymbol *Sym = TM.getSymbol(ComdatGV, Mang);
StringRef COMDATSymName = Sym->getName();
+ if (Kind.isText()) {
+ const Triple &T = getContext().getObjectFileInfo()->getTargetTriple();
+ if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
+ Characteristics |= COFF::IMAGE_SCN_MEM_16BIT;
+ }
return getContext().getCOFFSection(Name, Characteristics, Kind,
COMDATSymName, Selection);
}
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>