mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-01 13:20:25 +00:00
[ELF] - Do not crash if common symbol has alignment 0.
Testcase contains a common symbol with zero alignment, previously lld would crash, patch fixes that. Differential revision: https://reviews.llvm.org/D25085 llvm-svn: 283197
This commit is contained in:
parent
5cbf23664d
commit
0c82561c4c
@ -400,6 +400,9 @@ SymbolBody *elf::ObjectFile<ELFT>::createSymbolBody(const Elf_Sym *Sym) {
|
||||
/*CanOmitFromDynSym*/ false, this)
|
||||
->body();
|
||||
case SHN_COMMON:
|
||||
if (Sym->st_value == 0)
|
||||
fatal(getFilename(this) + ": common symbol '" + Name +
|
||||
"' alignment is 0");
|
||||
return elf::Symtab<ELFT>::X->addCommon(Name, Sym->st_size, Sym->st_value,
|
||||
Binding, Sym->st_other,
|
||||
Sym->getType(), this)
|
||||
|
BIN
lld/test/ELF/invalid/Inputs/common-symbol-alignment.elf
Normal file
BIN
lld/test/ELF/invalid/Inputs/common-symbol-alignment.elf
Normal file
Binary file not shown.
6
lld/test/ELF/invalid/common-symbol-alignment.s
Normal file
6
lld/test/ELF/invalid/common-symbol-alignment.s
Normal file
@ -0,0 +1,6 @@
|
||||
# REQUIRES: x86
|
||||
|
||||
## common-symbol-alignment.elf contains common symbol with zero alignment.
|
||||
# RUN: not ld.lld %S/Inputs/common-symbol-alignment.elf \
|
||||
# RUN: -o %t 2>&1 | FileCheck %s
|
||||
# CHECK: common symbol 'bar' alignment is 0
|
Loading…
Reference in New Issue
Block a user