aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-03-10 23:02:19 +1030
committerAlan Modra <amodra@gmail.com>2025-03-10 23:02:19 +1030
commitebed0bfecc7f482a2c284947527427625ee42c1a (patch)
treeabb75c821553baa1df2a61b2771c883f16704e60
parentb8c5ada1742586d389cec1b82f69c895976b1849 (diff)
downloadbinutils-ebed0bfecc7f482a2c284947527427625ee42c1a.zip
binutils-ebed0bfecc7f482a2c284947527427625ee42c1a.tar.gz
binutils-ebed0bfecc7f482a2c284947527427625ee42c1a.tar.bz2
meaningless p_offset for zero p_filesz PT_LOAD
This patch avoids generating PT_LOAD segments that trip a bug in glibc's loader. PR 25237 PR 32763 * elf.c (assign_file_positions_for_load_sections): Don't put p_offset zero for empty PT_LOAD.
-rw-r--r--bfd/elf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 20f96e6..ee89dd9 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6170,7 +6170,10 @@ assign_file_positions_for_load_sections (bfd *abfd,
align = p->p_align;
if (align < 1)
align = 1;
- p->p_offset = off % align;
+ /* Avoid p_offset of zero, which might be wrongly
+ interpreted as the segment being the first one,
+ containing the file header. PR32763. */
+ p->p_offset = (off + align - 1) % align + 1;
}
}
else