[PATCH] D36138: [ELF] - Don't segfault when accessing location counter inside MEMORY command.
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 06:51:34 PDT 2017
peter.smith added a comment.
I don't know whether it helps much at all, but here goes. The idea behind CurAddressState was to make sure we kept together all the information that needed to be cleared between successive calls to assignAddresses(). The two places I could spot from our existing test cases was that processCommands() and assignAddresses() that traversed the command list and evaluated expressions so that is where I thought that getSymbolValue() would actually be evaluated.
I think that this one must come from readMemoryAssignment( ) in ScriptParser as it calls readExpr()().getValue() and if readExpr happens to return "." then we will evaluate "." which to my understanding isn't allowed as the manual says "The expression must evaluate to a constant before memory allocation is performed, which means that you may not use any section relative symbols."
The places that could go wrong and access a Null Pointer are I think restricted to where .getValue() is called on an expression containing "." outside the context of processCommands() or assignAddresses(), which I believe is where the ScriptParser is expecting a constant. As such I think the fix should at least give an error message, and if you are looking for more test cases then using "." in areas where the parser is expecting a constant will be a good place to look.
For reference CurAddressState was put in under https://reviews.llvm.org/D34345, although comments will probably need to be found on the list as I don't think that they automatically get added to Phab..
https://reviews.llvm.org/D36138
More information about the llvm-commits
mailing list