[PATCH] D37440: [ELF] - Linkerscript: do not hang linker on infinite nested INCLUDE command.

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 5 02:12:17 PDT 2017


peter.smith added a comment.

Looks like a useful error message. I've checked that ld.bfd matches its documentation and has a maximum limit of 10. I've spotted one typo in the error message, and have made a minor stylistic suggestion but don't have a strong opinion on it.



================
Comment at: ELF/ScriptLexer.cpp:93
+  if (Depth > 10)
+    setError("INCLUDE nesting up do 10 levels is allowed");
+
----------------
typo: I think you meant "up to" instead of "up do". It may also be worth expressing the error explicitly, at the moment the user has to imply that they have exceeded the maximum limit. Perhaps something like "Maximum include nesting level of 10 exceeded." 


================
Comment at: ELF/ScriptLexer.h:49
 
-  MemoryBufferRef getCurrentMB();
+  std::pair<MemoryBufferRef, int8_t> getCurrentMB();
 };
----------------
getCurrentMB() is now returning <MemoryBuffer, depth> pair. In each of the cases where it is called only one of the two fields of the pair is used. Would it be better to have getCurrentMB() return first, and add a new function getCurrentMBDepth() that returns the second. That should allow the .firsts and .second from the calling code.


https://reviews.llvm.org/D37440





More information about the llvm-commits mailing list