diff options
author | Alan Modra <amodra@gmail.com> | 2025-03-10 23:02:19 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-03-10 23:02:19 +1030 |
commit | ebed0bfecc7f482a2c284947527427625ee42c1a (patch) | |
tree | abb75c821553baa1df2a61b2771c883f16704e60 | |
parent | b8c5ada1742586d389cec1b82f69c895976b1849 (diff) | |
download | binutils-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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 |