Commit 267f2bf9 by John Porto

Subzero. Fixes valgrind errors.

Valgrind used to report errors about uninitialized variable access in Subzero, when it was built with -O2. The problem was traced to size_t Alignment = Var->getAlignment; Alignment = std::max(MinAlignment, Var->getAlignment()) Apparently, the compiler will not correctly zero-extend Var->getAlignment(), and thus Alignment's upper 32-bits would be garbage. BUG= R=kschimpf@google.com, stichnot@chromium.org Review URL: https://codereview.chromium.org/1825363003 .
parent abe7dd5f
......@@ -388,9 +388,8 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
// entry will be created separately.
if (!Var->hasInitializer())
continue;
Elf64_Xword Align = Var->getAlignment();
constexpr Elf64_Xword MinAlign = 1;
Align = std::max(Align, MinAlign);
const auto Align = std::max<Elf64_Xword>(MinAlign, Var->getAlignment());
Section->padToAlignment(Str, Align);
SizeT SymbolSize = Var->getNumBytes();
bool IsExternal = Var->isExternal() || Ctx.getFlags().getDisableInternal();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment