Skip to content

Commit 50188b2

Browse files
author
George Rimar
committedOct 10, 2016
[ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX.
We have following code in lld, that truncates the alignment value to 32 bit. Big alignment in this case may give result 0 and crash later. template <class ELFT> CommonInputSection<ELFT>::CommonInputSection(std::vector<DefinedCommon *> Syms) : InputSection<ELFT>(nullptr, &Hdr, "") { .... for (DefinedCommon *Sym : Syms) { this->Alignment = std::max<uintX_t>(this->Alignment, Sym->Alignment); ... } } Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25235 llvm-svn: 283733
1 parent a9b79e6 commit 50188b2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 
Binary file not shown.

‎lld/test/ELF/invalid/common-symbol-alignment.s

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@
33
## common-symbol-alignment.elf contains common symbol with zero alignment.
44
# RUN: not ld.lld %S/Inputs/common-symbol-alignment.elf \
55
# RUN: -o %t 2>&1 | FileCheck %s
6-
# CHECK: common symbol 'bar' alignment is 0
6+
# CHECK: common symbol 'bar' has invalid alignment: 0
7+
8+
## common-symbol-alignment2.elf contains common symbol alignment greater
9+
## than UINT32_MAX.
10+
# RUN: not ld.lld %S/Inputs/common-symbol-alignment2.elf \
11+
# RUN: -o %t 2>&1 | FileCheck %s --check-prefix=BIG
12+
# BIG: common symbol 'bar' has invalid alignment: 271644049215

0 commit comments

Comments
 (0)