This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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

2009-11-02  Daniel Jacobowitz  <>

	* 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)
-      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));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]