commit: 2020f0c37a487cbf01e87b6e923e9cb3dbed0087 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Wed Aug 20 22:17:46 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Aug 20 22:17:46 2025 +0000 URL: https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/commit/?id=2020f0c3
9999: switch to H.J.'s section size patch Signed-off-by: Sam James <sam <AT> gentoo.org> ...ntsize-when-clearing-SEC_MERGE-SEC_STRING.patch | 87 ++++++++++++++++++++++ 9999/0006-ld-section-size.patch | 75 ------------------- 2 files changed, 87 insertions(+), 75 deletions(-) diff --git a/9999/0006-elf-Clear-entsize-when-clearing-SEC_MERGE-SEC_STRING.patch b/9999/0006-elf-Clear-entsize-when-clearing-SEC_MERGE-SEC_STRING.patch new file mode 100644 index 0000000..b9c30be --- /dev/null +++ b/9999/0006-elf-Clear-entsize-when-clearing-SEC_MERGE-SEC_STRING.patch @@ -0,0 +1,87 @@ +From 3e39ade99e4e24f741c7d5631412e89d1bc5bde4 Mon Sep 17 00:00:00 2001 +Message-ID: <3e39ade99e4e24f741c7d5631412e89d1bc5bde4.1755728184.git....@gentoo.org> +From: "H.J. Lu" <[email protected]> +Date: Wed, 20 Aug 2025 12:27:53 -0700 +Subject: [PATCH] elf: Clear entsize when clearing SEC_MERGE|SEC_STRINGS + +When generating an output from input SEC_MERGE|SEC_STRINGS sections with +different entsize, 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 <[email protected]> +--- + ld/ldlang.c | 1 + + ld/testsuite/ld-elf/pr33291.d | 9 +++++++++ + ld/testsuite/ld-elf/pr33291a.s | 8 ++++++++ + ld/testsuite/ld-elf/pr33291b.s | 7 +++++++ + 4 files changed, 25 insertions(+) + create mode 100644 ld/testsuite/ld-elf/pr33291.d + create mode 100644 ld/testsuite/ld-elf/pr33291a.s + create mode 100644 ld/testsuite/ld-elf/pr33291b.s + +diff --git a/ld/ldlang.c b/ld/ldlang.c +index 8ba95b04e23..0bb4a17df19 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 00000000000..9f08118433e +--- /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 00000000000..07e9f7c2c21 +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr33291a.s +@@ -0,0 +1,8 @@ ++ .globl foo ++ .section .rodata.cst8,"aM",%progbits,8 ++ .align 8 ++ .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 00000000000..69f6b3db594 +--- /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 + +base-commit: fbcdc06c238be4fd6da7fb9bff4dd4c7f749ae07 +-- +2.51.0 + diff --git a/9999/0006-ld-section-size.patch b/9999/0006-ld-section-size.patch deleted file mode 100644 index 7526cbd..0000000 --- a/9999/0006-ld-section-size.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 79b01a9700c96203028dc8c9472e91c38eda5e83 Mon Sep 17 00:00:00 2001 -Message-ID: <79b01a9700c96203028dc8c9472e91c38eda5e83.1755600645.git....@gentoo.org> -From: Jan Beulich <[email protected]> -Date: Tue, 19 Aug 2025 10:35:38 +0200 -Subject: [PATCH] ld: entry size and merge/strings attributes propagation - -PR ld/33291 - -As indicated in other recent commits, the three properties can be -largely independent (ELF generally being the target here): Entry size -doesn't require either of merge/strings, and strings also doesn't -require merge. Commit 98e6d3f5bd4e ("gas/ELF: allow specifying entity -size for arbitrary sections") uncovered issues with ld's handling. - -Zap entry size when it doesn't match between input sections. In that -case SEC_MERGE and SEC_STRINGS also need to be removed, as their -underlying granularity is lost. Then deal with SEC_MERGE and -SEC_STRINGS separately. - -Otoh record entry size from the first input independent of SEC_MERGE. ---- - ld/ldlang.c | 27 ++++++++++++++++++--------- - 1 file changed, 18 insertions(+), 9 deletions(-) - -diff --git a/ld/ldlang.c b/ld/ldlang.c -index 8ba95b04e23..54292a8dfe1 100644 ---- a/ld/ldlang.c -+++ b/ld/ldlang.c -@@ -2854,14 +2854,24 @@ lang_add_section (lang_statement_list_type *ptr, - /* Only set SEC_READONLY flag on the first input section. */ - flags &= ~ SEC_READONLY; - -- /* Keep SEC_MERGE and SEC_STRINGS only if they are the same. */ -- if ((output->bfd_section->flags & (SEC_MERGE | SEC_STRINGS)) -- != (flags & (SEC_MERGE | SEC_STRINGS)) -- || ((flags & SEC_MERGE) != 0 -- && output->bfd_section->entsize != section->entsize)) -+ /* Keep entry size, SEC_MERGE, and SEC_STRINGS only if entry sizes are -+ the same. */ -+ if (output->bfd_section->entsize != section->entsize) - { -- output->bfd_section->flags &= ~ (SEC_MERGE | SEC_STRINGS); -- flags &= ~ (SEC_MERGE | SEC_STRINGS); -+ output->bfd_section->entsize = 0; -+ flags &= ~(SEC_MERGE | SEC_STRINGS); -+ } -+ -+ /* Keep SEC_MERGE and SEC_STRINGS (each) only if they are the same. */ -+ if ((output->bfd_section->flags ^ flags) & SEC_MERGE) -+ { -+ output->bfd_section->flags &= ~SEC_MERGE; -+ flags &= ~SEC_MERGE; -+ } -+ if ((output->bfd_section->flags ^ flags) & SEC_STRINGS) -+ { -+ output->bfd_section->flags &= ~SEC_STRINGS; -+ flags &= ~SEC_STRINGS; - } - } - output->bfd_section->flags |= flags; -@@ -2876,8 +2886,7 @@ lang_add_section (lang_statement_list_type *ptr, - link_info.output_bfd, - output->bfd_section, - &link_info); -- if ((flags & SEC_MERGE) != 0) -- output->bfd_section->entsize = section->entsize; -+ output->bfd_section->entsize = section->entsize; - } - - if ((flags & SEC_TIC54X_BLOCK) != 0 - -base-commit: 09292f4ae2ccb46130652f6b310ee7a5227326d3 --- -2.51.0 -
