aboutsummaryrefslogtreecommitdiff
path: root/elf/check-textrel.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-01-09 23:39:03 +0000
committerUlrich Drepper <drepper@redhat.com>2006-01-09 23:39:03 +0000
commit3ca66a2c647ab627933c3617a25f2e8d08a32a25 (patch)
treeef1559880a06b900fb434e5d47a2fb50ec4aede3 /elf/check-textrel.c
parent8dd18431a124679e413e92a9b1f3b38e1387b735 (diff)
downloadglibc-3ca66a2c647ab627933c3617a25f2e8d08a32a25.tar
glibc-3ca66a2c647ab627933c3617a25f2e8d08a32a25.tar.gz
glibc-3ca66a2c647ab627933c3617a25f2e8d08a32a25.tar.bz2
glibc-3ca66a2c647ab627933c3617a25f2e8d08a32a25.zip
(AB): Also check for writable and executable segments.
Diffstat (limited to 'elf/check-textrel.c')
-rw-r--r--elf/check-textrel.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/elf/check-textrel.c b/elf/check-textrel.c
index ec97e4b0c9..a39174dc3a 100644
--- a/elf/check-textrel.c
+++ b/elf/check-textrel.c
@@ -1,5 +1,5 @@
/* Check for text relocations in DSOs.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contribute by Ulrich Drepper <drepper@redhat.com>. 2002.
@@ -79,20 +79,28 @@ AB(handle_file) (const char *fname, int fd)
/* Search for the PT_DYNAMIC entry. */
size_t cnt;
+ E(Phdr) *dynphdr = NULL;
for (cnt = 0; cnt < phnum; ++cnt)
if (SWAP (phdr[cnt].p_type) == PT_DYNAMIC)
- break;
-
- if (cnt == phnum)
+ dynphdr = &phdr[cnt];
+ else if (SWAP (phdr[cnt].p_type) == PT_LOAD
+ && (SWAP (phdr[cnt].p_flags) & (PF_X | PF_W)) == (PF_X | PF_W))
+ {
+ printf ("%s: segment %zu is executable and writable\n",
+ fname);
+ return 1;
+ }
+
+ if (dynphdr == NULL)
{
printf ("%s: no DYNAMIC segment found\n", fname);
return 1;
}
/* Read the dynamic segment. */
- size_t pmemsz = SWAP(phdr[cnt].p_memsz);
+ size_t pmemsz = SWAP(dynphdr->p_memsz);
E(Dyn) *dyn = alloca (pmemsz);
- if (pread (fd, dyn, pmemsz, SWAP(phdr[cnt].p_offset)) != pmemsz)
+ if (pread (fd, dyn, pmemsz, SWAP(dynphdr->p_offset)) != pmemsz)
goto read_error;
/* Search for an DT_TEXTREL entry of DT_FLAGS with the DF_TEXTREL