You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
From 27c951adbd5d7ebe95f08c18257ea031bdd59ee1 Mon Sep 17 00:00:00 2001
|
|
From: Vincent Mihalkovic <vmihalko@redhat.com>
|
|
Date: Mon, 6 Feb 2023 15:00:16 +0100
|
|
Subject: [PATCH] For dynamic binaries let the df_1 pie flag determine if we
|
|
are pie or a shared object, and ignore the mode bits.
|
|
|
|
upstream commit: 03084b161cf888b5286dbbcd964c31ccad4f64d9
|
|
---
|
|
src/readelf.c | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/readelf.c b/src/readelf.c
|
|
index 94cdaca..9c75c0a 100644
|
|
--- a/src/readelf.c
|
|
+++ b/src/readelf.c
|
|
@@ -1058,7 +1058,7 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
|
|
|
switch (xdh_tag) {
|
|
case DT_FLAGS_1:
|
|
- if (xdh_val == DF_1_PIE)
|
|
+ if (xdh_val & DF_1_PIE)
|
|
ms->mode |= 0111;
|
|
else
|
|
ms->mode &= ~0111;
|
|
@@ -1611,6 +1611,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
|
switch (xph_type) {
|
|
case PT_DYNAMIC:
|
|
offset = 0;
|
|
+ // Let DF_1 determine if we are PIE or not.
|
|
+ ms->mode &= ~0111;
|
|
for (;;) {
|
|
if (offset >= (size_t)bufsize)
|
|
break;
|
|
--
|
|
2.39.1
|
|
|