This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [patch] Fix warning: Invalid entry in .debug_gdb_scripts section


On Thu, 16 Mar 2017 18:03:41 +0100, Pedro Alves wrote:
> I don't think you've supplied enough rationale.

I forgot to copy-paste prepared:

/usr/bin/rustc
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [15] .debug_gdb_scripts PROGBITS        00000000000008ed 0008ed 000022 00 AMS  0   0  1

/usr/lib/debug/usr/bin/rustc.debug
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [15] .debug_gdb_scripts NOBITS          00000000000008ed 000280 000022 00 AMS  0   0  1


> Shouldn't we be able to load scripts from debug-only sections?

I agree there is better to use SEC_HAS_CONTENTS, right?


> A testcase would indeed be good to have.

OK, I will update the patch later.


Jan
gdb/ChangeLog
2017-03-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..edaf264 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -1174,7 +1174,8 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
   bfd_byte *data = NULL;
 
   scripts_sect = bfd_get_section_by_name (abfd, section_name);
-  if (scripts_sect == NULL)
+  if (scripts_sect == NULL
+      || (bfd_get_section_flags (abfd, scripts_sect) & SEC_HAS_CONTENTS) == 0)
     return;
 
   if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))

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