kabi-dw/0002-fix-ET_DYN-vmlinux-namespace-support.patch
Čestmír Kalina 8983dccd42 Fix ET_DYN vmlinux namespace support
Resolves: https://issues.redhat.com/browse/RHEL-78572

Signed-off-by: Čestmír Kalina <ckalina@redhat.com>
2025-02-10 14:27:42 +01:00

54 lines
1.4 KiB
Diff

From e3d294f6a003e8f0330a24964fd1ec554016c494 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=8Cestm=C3=ADr=20Kalina?= <ckalina@redhat.com>
Date: Mon, 10 Feb 2025 14:24:27 +0100
Subject: [PATCH] fix ET_DYN vmlinux namespace support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Čestmír Kalina <ckalina@redhat.com>
---
ksymtab.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/ksymtab.c b/ksymtab.c
index f7ad9ea..333db84 100644
--- a/ksymtab.c
+++ b/ksymtab.c
@@ -158,6 +158,20 @@ struct elf_data *elf_open(const char *filename)
goto out;
}
+ switch (ehdr->e_type) {
+ case ET_EXEC:
+ case ET_DYN:
+ case ET_REL:
+ break;
+ default:
+ printf("Unsupported object filetype of %s: %d\n", filename,
+ ehdr->e_type);
+ free(ehdr);
+ (void) elf_end(elf);
+ (void) close(fd);
+ goto out;
+ }
+
/*
* Get section index of the string table associated with the section
* headers in the ELF file.
@@ -459,7 +473,10 @@ static void ns_filter(const char *name, uint64_t value, int bind, void *_ctx)
name += strlen(STRTAB_NS_PREFIX);
ns = (char *) ctx->ksymtab_strings;
- ns += (ctx->e_type == ET_EXEC) ? value - ctx->sh_addr : value;
+ if (ctx->e_type == ET_EXEC || ctx->e_type == ET_DYN)
+ ns += value - ctx->sh_addr;
+ else if (ctx->e_type == ET_REL)
+ ns += value;
if (!strlen(ns))
return;
--
2.48.1