| OLD | NEW |
| 1 /* Work with executable files, for GDB. | 1 /* Work with executable files, for GDB. |
| 2 | 2 |
| 3 Copyright (C) 1988-2003, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1988-2003, 2007-2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 231 } |
| 232 #endif | 232 #endif |
| 233 if (scratch_chan < 0) | 233 if (scratch_chan < 0) |
| 234 perror_with_name (filename); | 234 perror_with_name (filename); |
| 235 exec_bfd = bfd_fopen (scratch_pathname, gnutarget, | 235 exec_bfd = bfd_fopen (scratch_pathname, gnutarget, |
| 236 write_files ? FOPEN_RUB : FOPEN_RB, | 236 write_files ? FOPEN_RUB : FOPEN_RB, |
| 237 scratch_chan); | 237 scratch_chan); |
| 238 | 238 |
| 239 if (!exec_bfd) | 239 if (!exec_bfd) |
| 240 { | 240 { |
| 241 close (scratch_chan); | |
| 242 error (_("\"%s\": could not open as an executable file: %s"), | 241 error (_("\"%s\": could not open as an executable file: %s"), |
| 243 scratch_pathname, bfd_errmsg (bfd_get_error ())); | 242 scratch_pathname, bfd_errmsg (bfd_get_error ())); |
| 244 } | 243 } |
| 245 | 244 |
| 246 /* At this point, scratch_pathname and exec_bfd->name both point to the | 245 /* At this point, scratch_pathname and exec_bfd->name both point to the |
| 247 same malloc'd string. However exec_close() will attempt to free it | 246 same malloc'd string. However exec_close() will attempt to free it |
| 248 via the exec_bfd->name pointer, so we need to make another copy and | 247 via the exec_bfd->name pointer, so we need to make another copy and |
| 249 leave exec_bfd as the new owner of the original copy. */ | 248 leave exec_bfd as the new owner of the original copy. */ |
| 250 scratch_pathname = xstrdup (scratch_pathname); | 249 scratch_pathname = xstrdup (scratch_pathname); |
| 251 cleanups = make_cleanup (xfree, scratch_pathname); | 250 cleanups = make_cleanup (xfree, scratch_pathname); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 if (writebuf) | 656 if (writebuf) |
| 658 res = bfd_set_section_contents (p->bfd, p->the_bfd_section, | 657 res = bfd_set_section_contents (p->bfd, p->the_bfd_section, |
| 659 writebuf, memaddr - p->addr, | 658 writebuf, memaddr - p->addr, |
| 660 len); | 659 len); |
| 661 else | 660 else |
| 662 res = bfd_get_section_contents (p->bfd, p->the_bfd_section, | 661 res = bfd_get_section_contents (p->bfd, p->the_bfd_section, |
| 663 readbuf, memaddr - p->addr, | 662 readbuf, memaddr - p->addr, |
| 664 len); | 663 len); |
| 665 return (res != 0) ? len : 0; | 664 return (res != 0) ? len : 0; |
| 666 } | 665 } |
error: old chunk mismatch |
None
| OLD | NEW |