From ee5365528ae7d769b35c2834a02de9138c1a85c7 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 24 Feb 2017 11:07:49 +0000 Subject: [PATCH] MFC r313494: Handle protected symbols in rtld. git-svn-id: svn://svn.freebsd.org/base/stable/10@314199 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- libexec/rtld-elf/rtld.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 1be409bef..337e58450 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3833,15 +3833,19 @@ symlook_default(SymLook *req, const Obj_Entry *refobj) donelist_init(&donelist); symlook_init_from_req(&req1, req); - /* Look first in the referencing object if linked symbolically. */ - if (refobj->symbolic && !donelist_check(&donelist, refobj)) { - res = symlook_obj(&req1, refobj); - if (res == 0) { - req->sym_out = req1.sym_out; - req->defobj_out = req1.defobj_out; - assert(req->defobj_out != NULL); - } + /* + * Look first in the referencing object if linked symbolically, + * and similarly handle protected symbols. + */ + res = symlook_obj(&req1, refobj); + if (res == 0 && (refobj->symbolic || + ELF_ST_VISIBILITY(req1.sym_out->st_other) == STV_PROTECTED)) { + req->sym_out = req1.sym_out; + req->defobj_out = req1.defobj_out; + assert(req->defobj_out != NULL); } + if (refobj->symbolic || req->defobj_out != NULL) + donelist_check(&donelist, refobj); symlook_global(req, &donelist); -- 2.45.0