[LLD][ELF] - Fix crash when using empty --defsym.
ClosedPublic

Authored by grimar on Aug 9 2018, 2:12 AM.

Details

Summary

We have a crash issue when handling the empty -defsym.

For parsing this option we are using ScriptParser class which is used
generally for reading the linker script. For empty defsym case, we
pass the empty memory buffer and crash in the place removed in https://reviews.llvm.org/rL336436.

But reverting of the above patch would not help here (we would still crash but a bit later). And
even after fixing the crash we would report something like
"lld.exe: error: -defsym:1: unexpected EOF"
It is probably not the appropriate message because mentions EOF.

I think the issue should be handled on a higher level like this patch does.
So we do not want to pass the empty memory buffer first of all I believe.

Diff Detail

Repository
rL LLVM
grimar created this revision.Aug 9 2018, 2:12 AM
ruiu accepted this revision.Aug 9 2018, 10:59 AM

LGTM

ELF/Driver.cpp
1030 ↗(On Diff #159881)

Please include the option value itself as well:

"-defsym: syntax error: " + Arg->getValue()

This revision is now accepted and ready to land.Aug 9 2018, 10:59 AM
This revision was automatically updated to reflect the committed changes.