From 7e95a981545700bf4f16fed70d8a00c6e410dd40 Mon Sep 17 00:00:00 2001
From: renoseven <dev@renoseven.net>
Date: Mon, 28 Apr 2025 12:16:26 +0800
Subject: [PATCH] upatch-diff: allow .debug_ section header changes

Signed-off-by: renoseven <dev@renoseven.net>
---
 upatch-diff/elf-compare.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/upatch-diff/elf-compare.c b/upatch-diff/elf-compare.c
index c31dbb9..56451af 100644
--- a/upatch-diff/elf-compare.c
+++ b/upatch-diff/elf-compare.c
@@ -132,18 +132,20 @@ static int compare_correlated_section(struct section *sec,
     struct section *sectwin)
 {
     /* compare section headers */
-    if ((sec->sh.sh_type != sectwin->sh.sh_type) ||
-        (sec->sh.sh_flags != sectwin->sh.sh_flags) ||
-        (sec->sh.sh_entsize != sectwin->sh.sh_entsize) ||
-        ((sec->sh.sh_addralign != sectwin->sh.sh_addralign) &&
-        !is_text_section(sec) &&
-        !is_string_section(sec) &&
-        !is_rodata_section(sec))) {
-        /* shaddralign of .rodata may be changed from 0 to 8 bytes
-           once string length is over 30 */
-        ERROR("%s section header details differ from %s",
-            sec->name, sectwin->name);
-        return -1;
+    if (!is_debug_section(sec)) {
+        if ((sec->sh.sh_type != sectwin->sh.sh_type) ||
+            (sec->sh.sh_flags != sectwin->sh.sh_flags) ||
+            (sec->sh.sh_entsize != sectwin->sh.sh_entsize) ||
+            ((sec->sh.sh_addralign != sectwin->sh.sh_addralign) &&
+            !is_text_section(sec) &&
+            !is_string_section(sec) &&
+            !is_rodata_section(sec))) {
+            /* shaddralign of .rodata may be changed from 0 to 8 bytes
+               once string length is over 30 */
+            ERROR("%s section header details differ from %s",
+                sec->name, sectwin->name);
+            return -1;
+        }
     }
 
     if (is_note_section(sec)) {
-- 
2.43.0