commit: 61e1223b7d1b5bdc95fc287a9e9f7c48e9cb5127 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Mon Aug 18 15:39:20 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Aug 18 15:39:20 2025 +0000 URL: https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/commit/?id=61e1223b
9999: add section size fix Bug: https://sourceware.org/PR33291 Signed-off-by: Sam James <sam <AT> gentoo.org> 9999/0009-ld-section-size.patch | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/9999/0009-ld-section-size.patch b/9999/0009-ld-section-size.patch new file mode 100644 index 0000000..70f6f28 --- /dev/null +++ b/9999/0009-ld-section-size.patch @@ -0,0 +1,46 @@ +https://sourceware.org/bugzilla/show_bug.cgi?id=33291#c10 +--- a/ld/ldlang.c ++++ b/ld/ldlang.c +@@ -2857,14 +2857,24 @@ lang_add_section (lang_statement_list_ty + /* 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; +@@ -2879,8 +2889,9 @@ lang_add_section (lang_statement_list_ty + link_info.output_bfd, + output->bfd_section, + &link_info); +- if ((flags & SEC_MERGE) != 0) ++ //todo if (no earlier data statements) + output->bfd_section->entsize = section->entsize; ++ //todo also need to deal with later data statements + } + + if ((flags & SEC_TIC54X_BLOCK) != 0
