This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Disable warning message about a program header with no associated sections when that header's file s
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 2 Mar 2017 14:48:35 -0000
- Subject: [binutils-gdb] Disable warning message about a program header with no associated sections when that header's file s
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f98450c6eee6878ebf5b052d231758026d250427
commit f98450c6eee6878ebf5b052d231758026d250427
Author: Nick Clifton <nickc@redhat.com>
Date: Thu Mar 2 14:47:29 2017 +0000
Disable warning message about a program header with no associated sections when that header's file size is non-zero.
PR ld/21212
* elf.c (rewrite_elf_program_header): Do not issue a warning for
empty segments which have a non-zero filesz.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elf.c | 13 +++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 607194f..4a27e04 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-03-02 Martin Bickel <binutils@ineranves.de>
+
+ PR ld/21212
+ * elf.c (rewrite_elf_program_header): Do not issue a warning for
+ empty segments which have a non-zero filesz.
+
2017-03-02 Alan Modra <amodra@gmail.com>
* elf32-ppc.c (ppc_elf_vle_split16): Correct insn mask typo.
diff --git a/bfd/elf.c b/bfd/elf.c
index 94726ba..9418e51 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6689,11 +6689,16 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
/* Special segments, such as the PT_PHDR segment, may contain
no sections, but ordinary, loadable segments should contain
something. They are allowed by the ELF spec however, so only
- a warning is produced. */
- if (segment->p_type == PT_LOAD)
+ a warning is produced.
+ 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
+ && (segment->p_filesz > 0 || segment->p_memsz == 0))
+ /* xgettext:c-format */
_bfd_error_handler (_("\
-%B: warning: Empty loadable segment detected, is this intentional ?"),
- ibfd);
+%B: warning: Empty loadable segment detected at vaddr=0x%.8x, is this intentional ?"),
+ ibfd, segment->p_vaddr);
map->count = 0;
*pointer_to_map = map;