]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Keep _GLOBAL_OFFSET_TABLE_ for .eh_frame
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 30 Sep 2025 00:13:56 +0000 (08:13 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Oct 2025 22:08:42 +0000 (06:08 +0800)
Since x86 .eh_frame section may reference _GLOBAL_OFFSET_TABLE_, keep
_GLOBAL_OFFSET_TABLE_ if there is dynamic section and the output
.eh_frame section is non-empty.

PR ld/33499
* elfxx-x86.c (_bfd_x86_elf_late_size_sections): Keep
_GLOBAL_OFFSET_TABLE_ if there is dynamic section and the
output .eh_frame section is non-empty.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/elfxx-x86.c

index d8c653a9ad223639701d19bc5eaf13f05fab27b7..140e86888a6654fb9c1daae3b1732fe089e02d9f 100644 (file)
@@ -2456,6 +2456,8 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd,
 
   if (htab->elf.sgotplt)
     {
+      asection *eh_frame;
+
       /* Don't allocate .got.plt section if there are no GOT nor PLT
         entries and there is no reference to _GLOBAL_OFFSET_TABLE_.  */
       if ((htab->elf.hgot == NULL
@@ -2468,7 +2470,11 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd,
          && (htab->elf.iplt == NULL
              || htab->elf.iplt->size == 0)
          && (htab->elf.igotplt == NULL
-             || htab->elf.igotplt->size == 0))
+             || htab->elf.igotplt->size == 0)
+         && (!htab->elf.dynamic_sections_created
+             || (eh_frame = bfd_get_section_by_name (output_bfd,
+                                                     ".eh_frame")) == NULL
+             || eh_frame->rawsize == 0))
        {
          htab->elf.sgotplt->size = 0;
          /* Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it