[PATCH] [Request, 8 lines] D25085: [ELF] - Do not crash if common symbol has alignment 0.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 02:22:09 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael, davide.
grimar added subscribers: llvm-commits, grimar.
id_000024,sig_08,src_000002,op_arith16,pos_94,val_-16
contains a common symbol with zero alignment. I did not found
in specification that it is correct (like it says that for sections) and
since we were fine living without it, I made it an error instead
of assigning 1 like we do for sections.
https://reviews.llvm.org/D25085
Files:
ELF/Symbols.cpp
test/ELF/invalid/Inputs/common-symbol-alignment.elf
test/ELF/invalid/common-symbol-alignment.s
Index: test/ELF/invalid/common-symbol-alignment.s
===================================================================
--- test/ELF/invalid/common-symbol-alignment.s
+++ test/ELF/invalid/common-symbol-alignment.s
@@ -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
Index: ELF/Symbols.cpp
===================================================================
--- ELF/Symbols.cpp
+++ ELF/Symbols.cpp
@@ -212,6 +212,8 @@
uint8_t StOther, uint8_t Type, InputFile *File)
: Defined(SymbolBody::DefinedCommonKind, N, StOther, Type),
Alignment(Alignment), Size(Size) {
+ if (Alignment == 0)
+ fatal(getFilename(File) + ": common symbol '" + N + "' alignment is 0");
this->File = File;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25085.73016.patch
Type: text/x-patch
Size: 941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/377dec75/attachment.bin>
More information about the llvm-commits
mailing list