aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2025-08-20 12:27:53 -0700
committerH.J. Lu <hjl.tools@gmail.com>2025-08-20 16:27:22 -0700
commit9c0adb10c7fcfb5a317095201cf144cdada6ca08 (patch)
tree1664fe5fe7fe54ddb0a3eafd37e100ab55285b15
parentfbcdc06c238be4fd6da7fb9bff4dd4c7f749ae07 (diff)
downloadgdb-9c0adb10c7fcfb5a317095201cf144cdada6ca08.zip
gdb-9c0adb10c7fcfb5a317095201cf144cdada6ca08.tar.gz
gdb-9c0adb10c7fcfb5a317095201cf144cdada6ca08.tar.bz2
elf: Clear entsize when clearing SEC_MERGE|SEC_STRINGS
When generating an output from input SEC_MERGE|SEC_STRINGS sections with different entsizes, we clear the SEC_MERGE|SEC_STRINGS bits. We also need to clear entsize. PR ld/33291 * ldlang.c (lang_add_section): Clearing entsize when clearing SEC_MERGE|SEC_STRINGS. * testsuite/ld-elf/pr33291.d: New file. * testsuite/ld-elf/pr33291a.s: Likewise. * testsuite/ld-elf/pr33291b.s: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r--ld/ldlang.c1
-rw-r--r--ld/testsuite/ld-elf/pr33291.d9
-rw-r--r--ld/testsuite/ld-elf/pr33291a.s8
-rw-r--r--ld/testsuite/ld-elf/pr33291b.s7
4 files changed, 25 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8ba95b0..0bb4a17 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2861,6 +2861,7 @@ lang_add_section (lang_statement_list_type *ptr,
&& output->bfd_section->entsize != section->entsize))
{
output->bfd_section->flags &= ~ (SEC_MERGE | SEC_STRINGS);
+ output->bfd_section->entsize = 0;
flags &= ~ (SEC_MERGE | SEC_STRINGS);
}
}
diff --git a/ld/testsuite/ld-elf/pr33291.d b/ld/testsuite/ld-elf/pr33291.d
new file mode 100644
index 0000000..22a8336
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr33291.d
@@ -0,0 +1,9 @@
+#source: pr33291a.s
+#source: pr33291b.s
+#ld: -shared
+#readelf: -S --wide
+#xfail: ![check_shared_lib_support]
+
+#...
+ \[[ 0-9]+\] \.rodata[ ]+PROGBITS[ ]+[0-9a-f]+ [0-9a-f]+ 0+9 00 +A +0 +0 +8
+#...
diff --git a/ld/testsuite/ld-elf/pr33291a.s b/ld/testsuite/ld-elf/pr33291a.s
new file mode 100644
index 0000000..587c0fb
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr33291a.s
@@ -0,0 +1,8 @@
+ .globl foo
+ .section .rodata.cst8,"aM",%progbits,8
+ .p2align 3
+ .type foo, %object
+ .size foo, 8
+foo:
+ .quad 131073
+ .section .note.GNU-stack,"",%progbits
diff --git a/ld/testsuite/ld-elf/pr33291b.s b/ld/testsuite/ld-elf/pr33291b.s
new file mode 100644
index 0000000..69f6b3d
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr33291b.s
@@ -0,0 +1,7 @@
+ .globl bar
+ .section .rodata.cst1,"aM",%progbits,1
+ .type bar, %object
+ .size bar, 1
+bar:
+ .byte 1
+ .section .note.GNU-stack,"",%progbits