aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2023-06-02 11:54:21 -0700
committerH.J. Lu <hjl.tools@gmail.com>2023-06-05 08:21:21 -0700
commit3f60b98298fd77dec3a9182797c9dd6d7796bcaf (patch)
tree2f728ec231ede67c9fd4bd4d6e7acece00f64868 /bfd
parentbaab375361c365afee2577c94cbbd3fdd443d6da (diff)
downloadgdb-3f60b98298fd77dec3a9182797c9dd6d7796bcaf.zip
gdb-3f60b98298fd77dec3a9182797c9dd6d7796bcaf.tar.gz
gdb-3f60b98298fd77dec3a9182797c9dd6d7796bcaf.tar.bz2
ELF: Don't warn an empty PT_LOAD with the program headers
When rewriting the program headers, don't warn an empty PT_LOAD with the program headers. bfd/ PR binutils/30508 * elf.c (rewrite_elf_program_header): Don't warn if an empty PT_LOAD contains the program headers. ld/ PR binutils/30508 * testsuite/ld-elf/pr30508.d: New file. * testsuite/ld-elf/pr30508.s: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 94954a8..81eb3ef 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7210,10 +7210,12 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize)
no sections, but ordinary, loadable segments should contain
something. They are allowed by the ELF spec however, so only
a warning is produced.
+ Don't warn if an empty PT_LOAD contains the program headers.
There is however the valid use case of embedded systems which
have segments with p_filesz of 0 and a p_memsz > 0 to initialize
flash memory with zeros. No warning is shown for that case. */
if (segment->p_type == PT_LOAD
+ && !map->includes_phdrs
&& (segment->p_filesz > 0 || segment->p_memsz == 0))
/* xgettext:c-format */
_bfd_error_handler