Date: Tue, 21 Jan 2025 01:51:01 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: bf3fbf74d12c - main - rtld obj_remap_relro(): unindent the loop body Message-ID: <202501210151.50L1p17X074140@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bf3fbf74d12cc6dff54ed17acf4a680cc0c9cdee commit bf3fbf74d12cc6dff54ed17acf4a680cc0c9cdee Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-01-18 23:23:28 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-01-21 01:44:22 +0000 rtld obj_remap_relro(): unindent the loop body Discussed with: emaste, imp Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D48509 --- libexec/rtld-elf/rtld.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 8ec883227908..169ec0200ea5 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -5987,20 +5987,18 @@ obj_remap_relro(Obj_Entry *obj, int prot) for (ph = obj->phdr; (const char *)ph < (const char *)obj->phdr + obj->phsize; ph++) { - switch (ph->p_type) { - case PT_GNU_RELRO: - relro_page = obj->relocbase + - rtld_trunc_page(ph->p_vaddr); - relro_size = rtld_round_page(ph->p_vaddr + - ph->p_memsz) - rtld_trunc_page(ph->p_vaddr); - if (mprotect(relro_page, relro_size, prot) == -1) { - _rtld_error( + if (ph->p_type != PT_GNU_RELRO) + continue; + relro_page = obj->relocbase + rtld_trunc_page(ph->p_vaddr); + relro_size = rtld_round_page(ph->p_vaddr + ph->p_memsz) - + rtld_trunc_page(ph->p_vaddr); + if (mprotect(relro_page, relro_size, prot) == -1) { + _rtld_error( "%s: Cannot set relro protection to %#x: %s", - obj->path, prot, rtld_strerror(errno)); - return (-1); - } - break; + obj->path, prot, rtld_strerror(errno)); + return (-1); } + break; } return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501210151.50L1p17X074140>