git: 9b844b495e8e - main - rtld: fix processing of preloaded z_initfirst objects

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 20 Apr 2026 17:40:51 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=9b844b495e8e63439ffe523757ac7444a16317af

commit 9b844b495e8e63439ffe523757ac7444a16317af
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-04-16 23:07:43 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-04-20 17:25:20 +0000

    rtld: fix processing of preloaded z_initfirst objects
    
    After we found some preloaded z_initfirst object, we must process till
    the end of the preload list still, not stopping on the first found
    object.
    
    Reported by:    des
    Reviewed by:    des, markj, siderop1@netapp.com
    Fixes:  78aaab9f1cf359f3b7325e4369653f6b50593393
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D56466
---
 libexec/rtld-elf/rtld.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index e3f5aa5be9b4..29984e40b574 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2654,6 +2654,11 @@ initlist_add_objects(Obj_Entry *obj, Obj_Entry *tail, Objlist *list,
 			initlist_add_neededs(obj->needed_aux_filtees,
 			    NULL, iflist);
 		objlist_push_tail(iflist, obj);
+
+		/* Recursively process the successor objects. */
+		nobj = globallist_next(obj);
+		if (nobj != NULL && obj != tail)
+			initlist_add_objects(nobj, tail, list, iflist);
 	} else {
 		if (obj->init_scanned)
 			return;