The majority of stuff is defined in utility-sprites.lua. However some tech effect bonus icons appear to derive their base layer from an entity icon. Ones I've spotted so far are lab speed research
That bonus icon is based on a low-level lab icon that vanilla doesn't know about. So clearly it is automatically deriving these icons based on known prototypes, but I can't locate where this is being done (utility-sprites.lua only seems to specify some temporary sprite for them in a function called make_default_modifier_icon).
My question is: how is the entity icon selected? First found? Based on their order property?