From d6a6d80eb21e0f69513eba6284aa4ebd3cf099d6 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 6 May 2024 12:09:19 -0400 Subject: [PATCH] add patch for binutils sh/fdpic bug 31619 --- .../0011-sh-fdpic-pr31619.diff | 33 +++++++++++++++++++ .../binutils-2.27/0008-sh-fdpic-pr31619.diff | 33 +++++++++++++++++++ .../binutils-2.32/0005-sh-fdpic-pr31619.diff | 33 +++++++++++++++++++ .../0005-sh-fdpic-pr31619.diff | 33 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 patches/binutils-2.25.1/0011-sh-fdpic-pr31619.diff create mode 100644 patches/binutils-2.27/0008-sh-fdpic-pr31619.diff create mode 100644 patches/binutils-2.32/0005-sh-fdpic-pr31619.diff create mode 100644 patches/binutils-2.33.1/0005-sh-fdpic-pr31619.diff diff --git a/patches/binutils-2.25.1/0011-sh-fdpic-pr31619.diff b/patches/binutils-2.25.1/0011-sh-fdpic-pr31619.diff new file mode 100644 index 0000000..9c57f39 --- /dev/null +++ b/patches/binutils-2.25.1/0011-sh-fdpic-pr31619.diff @@ -0,0 +1,33 @@ +--- binutils-2.33.1/bfd/elf32-sh.c.orig 2024-04-04 23:11:28.739136261 +0900 ++++ binutils-2.33.1/bfd/elf32-sh.c 2024-04-08 23:14:24.496915074 +0900 +@@ -61,7 +61,7 @@ + not. If the symbol is protected, we want the local address, but + its function descriptor must be assigned by the dynamic linker. */ + #define SYMBOL_FUNCDESC_LOCAL(INFO, H) \ +- (SYMBOL_REFERENCES_LOCAL (INFO, H) \ ++ (!(H) || (H)->dynindx < 0 || (H)->forced_local \ + || ! elf_hash_table (INFO)->dynamic_sections_created) + + #define SH_PARTIAL32 TRUE +@@ -4405,20 +4405,6 @@ + /* Undefined weak symbol which will not be dynamically + resolved later; leave it at zero. */ + goto funcdesc_leave_zero; +- else if (SYMBOL_CALLS_LOCAL (info, h) +- && ! SYMBOL_FUNCDESC_LOCAL (info, h)) +- { +- /* If the symbol needs a non-local function descriptor +- but binds locally (i.e., its visibility is +- protected), emit a dynamic relocation decayed to +- section+offset. This is an optimization; the dynamic +- linker would resolve our function descriptor request +- to our copy of the function anyway. */ +- dynindx = elf_section_data (h->root.u.def.section +- ->output_section)->dynindx; +- relocation += h->root.u.def.section->output_offset +- + h->root.u.def.value; +- } + else if (! SYMBOL_FUNCDESC_LOCAL (info, h)) + { + /* If the symbol is dynamic and there will be dynamic + diff --git a/patches/binutils-2.27/0008-sh-fdpic-pr31619.diff b/patches/binutils-2.27/0008-sh-fdpic-pr31619.diff new file mode 100644 index 0000000..9c57f39 --- /dev/null +++ b/patches/binutils-2.27/0008-sh-fdpic-pr31619.diff @@ -0,0 +1,33 @@ +--- binutils-2.33.1/bfd/elf32-sh.c.orig 2024-04-04 23:11:28.739136261 +0900 ++++ binutils-2.33.1/bfd/elf32-sh.c 2024-04-08 23:14:24.496915074 +0900 +@@ -61,7 +61,7 @@ + not. If the symbol is protected, we want the local address, but + its function descriptor must be assigned by the dynamic linker. */ + #define SYMBOL_FUNCDESC_LOCAL(INFO, H) \ +- (SYMBOL_REFERENCES_LOCAL (INFO, H) \ ++ (!(H) || (H)->dynindx < 0 || (H)->forced_local \ + || ! elf_hash_table (INFO)->dynamic_sections_created) + + #define SH_PARTIAL32 TRUE +@@ -4405,20 +4405,6 @@ + /* Undefined weak symbol which will not be dynamically + resolved later; leave it at zero. */ + goto funcdesc_leave_zero; +- else if (SYMBOL_CALLS_LOCAL (info, h) +- && ! SYMBOL_FUNCDESC_LOCAL (info, h)) +- { +- /* If the symbol needs a non-local function descriptor +- but binds locally (i.e., its visibility is +- protected), emit a dynamic relocation decayed to +- section+offset. This is an optimization; the dynamic +- linker would resolve our function descriptor request +- to our copy of the function anyway. */ +- dynindx = elf_section_data (h->root.u.def.section +- ->output_section)->dynindx; +- relocation += h->root.u.def.section->output_offset +- + h->root.u.def.value; +- } + else if (! SYMBOL_FUNCDESC_LOCAL (info, h)) + { + /* If the symbol is dynamic and there will be dynamic + diff --git a/patches/binutils-2.32/0005-sh-fdpic-pr31619.diff b/patches/binutils-2.32/0005-sh-fdpic-pr31619.diff new file mode 100644 index 0000000..9c57f39 --- /dev/null +++ b/patches/binutils-2.32/0005-sh-fdpic-pr31619.diff @@ -0,0 +1,33 @@ +--- binutils-2.33.1/bfd/elf32-sh.c.orig 2024-04-04 23:11:28.739136261 +0900 ++++ binutils-2.33.1/bfd/elf32-sh.c 2024-04-08 23:14:24.496915074 +0900 +@@ -61,7 +61,7 @@ + not. If the symbol is protected, we want the local address, but + its function descriptor must be assigned by the dynamic linker. */ + #define SYMBOL_FUNCDESC_LOCAL(INFO, H) \ +- (SYMBOL_REFERENCES_LOCAL (INFO, H) \ ++ (!(H) || (H)->dynindx < 0 || (H)->forced_local \ + || ! elf_hash_table (INFO)->dynamic_sections_created) + + #define SH_PARTIAL32 TRUE +@@ -4405,20 +4405,6 @@ + /* Undefined weak symbol which will not be dynamically + resolved later; leave it at zero. */ + goto funcdesc_leave_zero; +- else if (SYMBOL_CALLS_LOCAL (info, h) +- && ! SYMBOL_FUNCDESC_LOCAL (info, h)) +- { +- /* If the symbol needs a non-local function descriptor +- but binds locally (i.e., its visibility is +- protected), emit a dynamic relocation decayed to +- section+offset. This is an optimization; the dynamic +- linker would resolve our function descriptor request +- to our copy of the function anyway. */ +- dynindx = elf_section_data (h->root.u.def.section +- ->output_section)->dynindx; +- relocation += h->root.u.def.section->output_offset +- + h->root.u.def.value; +- } + else if (! SYMBOL_FUNCDESC_LOCAL (info, h)) + { + /* If the symbol is dynamic and there will be dynamic + diff --git a/patches/binutils-2.33.1/0005-sh-fdpic-pr31619.diff b/patches/binutils-2.33.1/0005-sh-fdpic-pr31619.diff new file mode 100644 index 0000000..9c57f39 --- /dev/null +++ b/patches/binutils-2.33.1/0005-sh-fdpic-pr31619.diff @@ -0,0 +1,33 @@ +--- binutils-2.33.1/bfd/elf32-sh.c.orig 2024-04-04 23:11:28.739136261 +0900 ++++ binutils-2.33.1/bfd/elf32-sh.c 2024-04-08 23:14:24.496915074 +0900 +@@ -61,7 +61,7 @@ + not. If the symbol is protected, we want the local address, but + its function descriptor must be assigned by the dynamic linker. */ + #define SYMBOL_FUNCDESC_LOCAL(INFO, H) \ +- (SYMBOL_REFERENCES_LOCAL (INFO, H) \ ++ (!(H) || (H)->dynindx < 0 || (H)->forced_local \ + || ! elf_hash_table (INFO)->dynamic_sections_created) + + #define SH_PARTIAL32 TRUE +@@ -4405,20 +4405,6 @@ + /* Undefined weak symbol which will not be dynamically + resolved later; leave it at zero. */ + goto funcdesc_leave_zero; +- else if (SYMBOL_CALLS_LOCAL (info, h) +- && ! SYMBOL_FUNCDESC_LOCAL (info, h)) +- { +- /* If the symbol needs a non-local function descriptor +- but binds locally (i.e., its visibility is +- protected), emit a dynamic relocation decayed to +- section+offset. This is an optimization; the dynamic +- linker would resolve our function descriptor request +- to our copy of the function anyway. */ +- dynindx = elf_section_data (h->root.u.def.section +- ->output_section)->dynindx; +- relocation += h->root.u.def.section->output_offset +- + h->root.u.def.value; +- } + else if (! SYMBOL_FUNCDESC_LOCAL (info, h)) + { + /* If the symbol is dynamic and there will be dynamic +