https://bugs.llvm.org/show_bug.cgi?id=38794
Bug ID: 38794
Summary: GlobalAlias with non-zero offsets and public linkage
end of with wrong size
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: unassignedb...@nondot.org
Reporter: daphnedi...@mac.com
CC: llvm-bugs@lists.llvm.org
I've run into the case where global aliases are not getting the right symbol
sizes in object files.
Example:
...
%global.type = type <{ [7934 x i16] }>
@global = linkonce_odr global %global.type zeroinitializer, align 4
@my_alias = alias [1024 x i16], bitcast (i32* getelementptr inbounds (i32,
i32* bitcast (%global.type* @global to i32*), i32 512) to [1024 x i16]*)
...
nm -S file.o
...
00000000 00003dfc V global
00000800 00003dfc B my_alias
...
Location of bug appears to be llvm::AsmPrinter::emitGlobalIndirectSymbol which
seems to have a special case that ignores sizes of aliases but doesn't consider
non-zero offsets. Note because the size is the full size of the base symbol,
this means that the alias symbol appears to go beyond the base symbol in the
section.
Test in question from llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:
if (auto *GA = dyn_cast<GlobalAlias>(&GIS)) {
// If the aliasee does not correspond to a symbol in the output, i.e. the
// alias is not of an object or the aliased object is private, then set
the
// size of the alias symbol from the type of the alias. We don't do this
in
// other situations as the alias and aliasee having differing types but
same
// size may be intentional.
const GlobalObject *BaseObject = GA->getBaseObject();
if (MAI->hasDotTypeDotSizeDirective() && GA->getValueType()->isSized() &&
(!BaseObject || BaseObject->hasPrivateLinkage())) {
const DataLayout &DL = M.getDataLayout();
uint64_t Size = DL.getTypeAllocSize(GA->getValueType());
OutStreamer->emitELFSize(Name, MCConstantExpr::create(Size,
OutContext));
}
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs