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

login
register
mail settings
Submitter Xavier Roirand
Date March 1, 2018, 5:15 p.m.
Message ID <20180301171525.15714-1-roirand@adacore.com>
Download mbox | patch
Permalink /patch/26142/
State New
Headers show

Comments

Xavier Roirand - March 1, 2018, 5:15 p.m.
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(-)
Simon Marchi - March 8, 2018, 11:02 p.m.
On 2018-03-01 12:15, Xavier Roirand wrote:
> 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>

Makes sense, please push.

Thanks!

Simon

Patch

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>