Found during ongoing attempts to link the FreeBSD base system with lld.
For processing .text relocations the runtime loader temporarily maps the segment with write permission. I discovered that we have an issue in FreeBSD's runtime loader: it expects the first PT_LOAD segment to be .text, and unprotects only that one. (That issue is tracked in http://bugs.freebsd.org/207631.)
This uncovered two lld issues, however.
First, lld should set DT_TEXTREL or DF_TEXTREL if the output contains relocations in non-writable segments.
If this flag is not set, no relocation entry should cause a modification to a non-writable segment, as specified by the segment permissions in the program header table. If this flag is set, one or more relocation entries might request modifications to a non-writable segment, and the dynamic linker can prepare accordingly.
The real issue here though is that the relocation exists at all.