This is https://bugs.llvm.org//show_bug.cgi?id=38750.
If script references empty sections in LOADADDR/ADDR commands
.empty : { *(.empty ) } .text : AT(LOADADDR (.empty) + SIZEOF (.empty)) { *(.text) }
then an empty section will be removed and LOADADDR/ADDR will evaluate to null.
It is not that user may expect from using of the generic script, what is a common case.
There is a trivial fix for that, so I would do that.
I think it might be best to keep Sec.ExpressionsUseSymbols and introduce a new bool variable called something like UsedInExpression and set that whenever ADDR and LOADADDR uses the name. Even though the effect (keep section) is the same, I think the reason to keep it is different and it gets lost in the comment. Perhaps something like: