[lld] r268410 - Check return value of addOptionalSynthetic before calling a member function on it.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 11:03:45 PDT 2016
Author: pcc
Date: Tue May 3 13:03:45 2016
New Revision: 268410
URL: http://llvm.org/viewvc/llvm-project?rev=268410&view=rev
Log:
Check return value of addOptionalSynthetic before calling a member function on it.
Found with UBSan.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=268410&r1=268409&r2=268410&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue May 3 13:03:45 2016
@@ -1207,9 +1207,11 @@ template <class ELFT> void Writer<ELFT>:
// On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
// start of function and 'gp' pointer into GOT.
- ElfSym<ELFT>::MipsGpDisp =
- addOptionalSynthetic(Symtab, "_gp_disp", Out<ELFT>::Got, MipsGPOffset)
- ->body();
+ Symbol *Sym =
+ addOptionalSynthetic(Symtab, "_gp_disp", Out<ELFT>::Got, MipsGPOffset);
+ if (Sym)
+ ElfSym<ELFT>::MipsGpDisp = Sym->body();
+
// The __gnu_local_gp is a magic symbol equal to the current value of 'gp'
// pointer. This symbol is used in the code generated by .cpload pseudo-op
// in case of using -mno-shared option.
More information about the llvm-commits
mailing list