SIZEOF(section)
Return the size in bytes of the named section, if that section has been allocated.
SIZEOF(section) often used in scripts. Few examples from the wild:
https://github.com/chipKIT32/pic32-Arduino-USB-Bootloader-original/blob/master/boot-linkerscript.ld
https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/gba_cart.ld
Patch implements it.
I don't think it's beautiful as you are holding a pointer to a factory just to get sizes of sections. Factory is too powerful to be here.
LinkerScript creates output sections. Why don't you save it instead?
Also, as I described in https://reviews.llvm.org/D22740, this is yet another example that you are accessing something other than Dot to evaluate expressions. I do not see a reason to handle Dot as a special case. If you like to pass all variables as parameters, why don't you pass it as a Expr's parameter?