bfd/ELF: slightly "better" file alignment for object files

Message ID 806f6674-62cd-4aeb-8210-cbe8a4a182e3@suse.com
State New
Headers
Series bfd/ELF: slightly "better" file alignment for object files |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jan Beulich Jan. 7, 2025, 10:12 a.m. UTC
  PR gas/32435

Commit 1f1b5e506bf0 ("bfd/ELF: restrict file alignment for object
files") caused an issue in the Linux kernels modpost utility, which was
building upon .rodata sections to be 4-byte aligned in the file when
they have 4-byte alignment. While we don't want to revert back to
original behavior, apply the same alignment "capping" as done originally
in two other places also for "ordinary" sections.
  

Patch

--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6811,8 +6811,12 @@  assign_file_positions_except_relocs (bfd
 	      hdr->sh_offset = -1;
 	    }
 	  else
+	    /* There shouldn't be a need to effect "capped" file alignment here,
+	       yet at least the Linux kernel's modpost utility was found to be
+	       unhappy without.  While the issue was addressed there, let's be
+	       kind for at least the foreseeable future ...  */
 	    off = _bfd_elf_assign_file_position_for_section (hdr, off, false,
-							     0);
+							     bed->s->log_file_align);
 	}
 
       elf_next_file_pos (abfd) = off;