openbsd-ports/devel/avr/binutils/patches/patch-binutils_objcopy_c
ckuethe ebcb40e5e1 Update to the latest AVR gcc, binutils, libc and gdb. Based on the FreeBSD
port, which is also in sync with winavr/avrstudio. Among other things, this
adds support for atmega328... which means new arduino boards should work.
2010-06-27 20:58:10 +00:00

104 lines
4.0 KiB
Plaintext

$OpenBSD: patch-binutils_objcopy_c,v 1.3 2010/06/27 20:58:10 ckuethe Exp $
--- binutils/objcopy.c.orig Sat Jun 26 11:22:44 2010
+++ binutils/objcopy.c Sat Jun 26 11:31:17 2010
@@ -32,6 +32,7 @@
#include "elf-bfd.h"
#include <sys/stat.h>
#include "libbfd.h"
+#include "debug.h"
#include "coff/internal.h"
#include "libcoff.h"
@@ -297,6 +298,8 @@ enum command_line_switch
OPTION_IMPURE,
OPTION_EXTRACT_SYMBOL,
OPTION_REVERSE_BYTES,
+ OPTION_CHANGE_PATHNAME,
+ OPTION_BASENAME,
OPTION_FILE_ALIGNMENT,
OPTION_HEAP,
OPTION_IMAGE_BASE,
@@ -346,10 +349,12 @@ static struct option copy_options[] =
{"adjust-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS},
{"adjust-warnings", no_argument, 0, OPTION_CHANGE_WARNINGS},
{"alt-machine-code", required_argument, 0, OPTION_ALT_MACH_CODE},
+ {"basename", no_argument, 0, OPTION_BASENAME},
{"binary-architecture", required_argument, 0, 'B'},
{"byte", required_argument, 0, 'b'},
{"change-addresses", required_argument, 0, OPTION_CHANGE_ADDRESSES},
{"change-leading-char", no_argument, 0, OPTION_CHANGE_LEADING_CHAR},
+ {"change-pathname", required_argument, 0, OPTION_CHANGE_PATHNAME},
{"change-section-address", required_argument, 0, OPTION_CHANGE_SECTION_ADDRESS},
{"change-section-lma", required_argument, 0, OPTION_CHANGE_SECTION_LMA},
{"change-section-vma", required_argument, 0, OPTION_CHANGE_SECTION_VMA},
@@ -543,6 +548,8 @@ copy_usage (FILE *stream, int exit_status)
--prefix-alloc-sections <prefix>\n\
Add <prefix> to start of every allocatable\n\
section name\n\
+ --change-pathname <old>=<new> Change debug pathnames from <old> to <new>\n\
+ --basename Strip directory part from debug pathnames\n\
--file-alignment <num> Set PE file alignment to <num>\n\
--heap <reserve>[,<commit>] Set PE reserve/commit heap to <reserve>/\n\
<commit>\n\
@@ -999,6 +1006,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
asymbol **from = isyms, **to = osyms;
long src_count = 0, dst_count = 0;
int relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0;
+ bfd_boolean need_for_debugging = convert_debugging
+ && bfd_get_arch (abfd) == bfd_arch_avr;
for (; src_count < symcount; src_count++)
{
@@ -1099,7 +1108,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
|| bfd_is_com_section (bfd_get_section (sym)))
keep = strip_symbols != STRIP_UNNEEDED;
else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */
- keep = (strip_symbols != STRIP_DEBUG
+ keep = need_for_debugging
+ || (strip_symbols != STRIP_DEBUG
&& strip_symbols != STRIP_UNNEEDED
&& ! convert_debugging);
else if (bfd_coff_get_comdat_section (abfd, bfd_get_section (sym)))
@@ -2817,6 +2827,10 @@ write_debugging_info (bfd *obfd, void *dhandle,
return write_ieee_debugging_info (obfd, dhandle);
if (bfd_get_flavour (obfd) == bfd_target_coff_flavour
+ && bfd_get_arch (obfd) == bfd_arch_avr)
+ return write_coff_debugging_info (obfd, dhandle, symcountp, symppp);
+
+ if (bfd_get_flavour (obfd) == bfd_target_coff_flavour
|| bfd_get_flavour (obfd) == bfd_target_elf_flavour)
{
bfd_byte *syms, *strings;
@@ -3639,6 +3653,30 @@ copy_main (int argc, char *argv[])
case OPTION_PREFIX_ALLOC_SECTIONS:
prefix_alloc_sections_string = optarg;
+ break;
+
+ case OPTION_CHANGE_PATHNAME:
+ {
+ const char *s;
+ int len;
+ char *name;
+
+ s = strchr (optarg, '=');
+ if (s == NULL)
+ fatal (_("bad format for %s"), "--change-pathname");
+
+ len = s - optarg;
+ name = (char *) xmalloc (len + 1);
+ strncpy (name, optarg, len);
+ name[len] = '\0';
+
+ debug_register_pathname_xlat (name, s + 1);
+ }
+ break;
+
+ case OPTION_BASENAME:
+ /* very special case of pathname translation */
+ debug_register_pathname_xlat (NULL, NULL);
break;
case OPTION_READONLY_TEXT: