openbsd-ports/devel/avr/binutils/patches/patch-binutils_objcopy_c

110 lines
4.3 KiB
Plaintext

$OpenBSD: patch-binutils_objcopy_c,v 1.1 2008/10/01 04:46:20 ckuethe Exp $
--- binutils/objcopy.c.orig Mon Aug 6 12:56:13 2007
+++ binutils/objcopy.c Sat Sep 27 20:20:27 2008
@@ -32,6 +32,7 @@
#include "elf-bfd.h"
#include <sys/stat.h>
#include "libbfd.h"
+#include "debug.h"
/* A list of symbols to explicitly strip out, or to keep. A linked
list is good enough for a small number from the command line, but
@@ -272,7 +273,9 @@ enum command_line_switch
OPTION_PURE,
OPTION_IMPURE,
OPTION_EXTRACT_SYMBOL,
- OPTION_REVERSE_BYTES
+ OPTION_REVERSE_BYTES,
+ OPTION_CHANGE_PATHNAME,
+ OPTION_BASENAME
};
/* Options to handle if running as "strip". */
@@ -316,10 +319,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},
@@ -504,6 +509,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\
-v --verbose List all object files modified\n\
@<file> Read options from <file>\n\
-V --version Display this program's version number\n\
@@ -911,6 +918,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++)
{
@@ -1010,9 +1019,10 @@ 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
- && strip_symbols != STRIP_UNNEEDED
- && ! convert_debugging);
+ 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)))
/* COMDAT sections store special information in local
symbols, so we cannot risk stripping any of them. */
@@ -2588,6 +2598,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;
@@ -3287,6 +3301,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: