This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Adjust elfread segment warning
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Mon, 2 Nov 2009 12:20:48 -0500
- Subject: [commit] Adjust elfread segment warning
elf_symfile_segments compares the ELF section and program header
tables, mapping each section to its segment so that we can relocate
the binary correctly if we only have 'text' and 'data' offsets.
It warns if it can't perform the mapping.
This patch disables the warning for one particular case. It's not
ideal - as in, we would do the wrong thing if such a binary was
relocated - but it only occurs in non-relocatable binaries. I decided
that this was the right compromise, rather than warning about
generally legitimate binaries.
Tested on x86_64-linux and checked in.
--
Daniel Jacobowitz
CodeSourcery
2009-11-02 Daniel Jacobowitz <dan@codesourcery.com>
* elfread.c (elf_symfile_segments): Do not warn about
uninitialized sections outside of load segments.
--- gdb/elfread.c (revision 227494)
+++ gdb/elfread.c (revision 227495)
@@ -114,7 +114,17 @@ elf_symfile_segments (bfd *abfd)
break;
}
- if (bfd_get_section_size (sect) > 0 && j == num_segments)
+ /* We should have found a segment for every non-empty section.
+ If we haven't, we will not relocate this section by any
+ offsets we apply to the segments. As an exception, do not
+ warn about SHT_NOBITS sections; in normal ELF execution
+ environments, SHT_NOBITS means zero-initialized and belongs
+ in a segment, but in no-OS environments some tools (e.g. ARM
+ RealView) use SHT_NOBITS for uninitialized data. Since it is
+ uninitialized, it doesn't need a program header. Such
+ binaries are not relocatable. */
+ if (bfd_get_section_size (sect) > 0 && j == num_segments
+ && (bfd_get_section_flags (abfd, sect) & SEC_LOAD) != 0)
warning (_("Loadable segment \"%s\" outside of ELF segments"),
bfd_section_name (abfd, sect));
}