summaryrefslogtreecommitdiff
path: root/bfd/mach-o.c
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2013-01-31 09:55:40 +0000
committerTristan Gingold <gingold@adacore.com>2013-01-31 09:55:40 +0000
commit06c12972e5e656bdc30930d3435fa91e84f6eb37 (patch)
tree3ed60dbf51f5e564e15afa290590a42e8227f3a4 /bfd/mach-o.c
parent2e1861546a3200f4b98c889a3c4a57fd19145a2e (diff)
downloadgdb-06c12972e5e656bdc30930d3435fa91e84f6eb37.tar.gz
2013-01-31 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_scan): Call bfd_mach_o_flatten_sections earlier. Fix status checking of bfd_mach_o_scan_start_address. (bfd_mach_o_scan_start_address): Handle LC_MAIN.
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r--bfd/mach-o.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 7f4b968c9cf..e3bfa58182e 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3979,6 +3979,18 @@ bfd_mach_o_scan_start_address (bfd *abfd)
cmd = &mdata->commands[i].command.thread;
break;
}
+ else if (mdata->commands[i].type == BFD_MACH_O_LC_MAIN
+ && mdata->nsects > 1)
+ {
+ bfd_mach_o_main_command *main_cmd = &mdata->commands[i].command.main;
+ bfd_mach_o_section *text_sect = mdata->sections[0];
+ if (text_sect)
+ {
+ abfd->start_address = main_cmd->entryoff
+ + (text_sect->addr - text_sect->offset);
+ return TRUE;
+ }
+ }
if (cmd == NULL)
return FALSE;
@@ -4121,10 +4133,11 @@ bfd_mach_o_scan (bfd *abfd,
}
}
- if (bfd_mach_o_scan_start_address (abfd) < 0)
+ /* Sections should be flatten before scanning start address. */
+ bfd_mach_o_flatten_sections (abfd);
+ if (!bfd_mach_o_scan_start_address (abfd))
return FALSE;
- bfd_mach_o_flatten_sections (abfd);
return TRUE;
}