Fix warning: Invalid entry in .debug_gdb_scripts section

Message ID 20170316154110.GA20969@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil March 16, 2017, 3:41 p.m. UTC
  Hi,

https://bugzilla.redhat.com/show_bug.cgi?id=1429598

there remains questionable whether bfd_get_section_by_name() should not return
an error for !SEC_LOAD but I haven't investigated that.

Also it could have a testcase.

OK for check-in?


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

	* auto-load.c (auto_load_section_scripts): Check also SEC_LOAD.
  

Comments

Pedro Alves March 16, 2017, 5:03 p.m. UTC | #1
On 03/16/2017 03:41 PM, Jan Kratochvil wrote:
> Hi,
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1429598
> 
> there remains questionable whether bfd_get_section_by_name() should not return
> an error for !SEC_LOAD but I haven't investigated that.
> 
> Also it could have a testcase.
> 
> OK for check-in?

I don't think you've supplied enough rationale.

Why is this the right thing to do?

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

A testcase would indeed be good to have.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..63b54b8 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_LOAD) == 0)
     return;
 
   if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))