630caa95d4
rtld preserves its current error message around calls to user init/fini lists, to not override original error with potential secondary errors caused by user code recursing into rtld. After 4d9128da54f8f8e2a29190, the preservation of the string itself is not enough, the 'seen' indicator must be preserved as well. Otherwise, since new code does not clear string (it cannot), call to _rtld_error() from errmsg_restore() revived whatever message was consumed last. Change errmsg_save() to return structure recording both 'seen' indicator and the message, if any. PR: 255698 Reported by: Eugene M. Kim <astralblue@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 3 days