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]

[RFA/Darwin] Fix starting address scan for binary with only one section


When binary has only one section, bfd_mach_o_scan_start_address
do not calculate properly starting address.

This patch fixes it.

gdb/ChangeLog:

        * mach-o.c (bfd_mach_o_scan_start_address): Handle binary
        with only one section.
---
 bfd/mach-o.c  | 2 +-
 gdb/ChangeLog | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index f26be0c73e..3312882e16 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -4827,7 +4827,7 @@ bfd_mach_o_scan_start_address (bfd *abfd)
 	thr = &cmd->command.thread;
 	break;
       }
-    else if (cmd->type == BFD_MACH_O_LC_MAIN && mdata->nsects > 1)
+    else if (cmd->type == BFD_MACH_O_LC_MAIN && mdata->nsects >= 1)
       {
 	bfd_mach_o_main_command *main_cmd = &cmd->command.main;
 	bfd_mach_o_section *text_sect = mdata->sections[0];
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 59265157b4..087cf53775 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-01  Tristan Gingold  <gingold@adacore.com>
+
+	Pushed by Xavier Roirand <roirand@adacore.com>
+	* mach-o.c (bfd_mach_o_scan_start_address): Handle binary
+	with only one section.
+
 2018-02-28  Sergio Durigan Junior  <sergiodj@redhat.com>
 	    Simon Marchi  <simon.marchi@polymtl.ca>
 
-- 
2.14.3 (Apple Git-98)


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