Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1@@ -, +, @@
2---
3 bfd/elf32-arm.c | 8 +++++++-
4 1 file changed, 7 insertions(+), 1 deletion(-)
5--- a/bfd/elf32-arm.c
6+++ a/bfd/elf32-arm.c
7@@ -15398,7 +15398,11 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
8 linker to copy the initial value out of the dynamic object and into
9 the runtime process image. We need to remember the offset into the
10 .rel(a).bss section we are going to use. */
11- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
12+ if (info->nocopyreloc == 0
13+ && (h->root.u.def.section->flags & SEC_ALLOC) != 0
14+ /* PR 16177: A copy is only needed if the input section is readonly. */
15+ && (h->root.u.def.section->flags & SEC_READONLY) != 0
16+ && h->size != 0)
17 {
18 s = globals->root.sdynrelro;
19 srel = globals->root.sreldynrelro;
20@@ -15410,6 +15414,8 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
21 }
22 if (info->nocopyreloc == 0
23 && (h->root.u.def.section->flags & SEC_ALLOC) != 0
24+ /* PR 16177: A copy is only needed if the input section is readonly. */
25+ && (h->root.u.def.section->flags & SEC_READONLY) != 0
26 && h->size != 0)
27 {
28 elf32_arm_allocate_dynrelocs (info, srel, 1);
29