GNU Binutils with patches for OS216
Revisión | 6765ee1825d92d25d9b3f6260de3f8a2a27e4998 (tree) |
---|---|
Tiempo | 2019-11-19 17:56:40 |
Autor | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
PR24968, make objcopy use output ELF arch if -B not given
This should make objcopy -B redundant for the common case of producing
ELF output where the -O target defaults to the desired arch:mach.
PR 24968
* objcopy.c (copy_object): For ELF output and non-ELF input without
arch, take arch from output file if not given by -B. Don't
bfd_get_arch_info when we already have iarch.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2019-11-19 Alan Modra <amodra@gmail.com> |
2 | 2 | |
3 | + PR 24968 | |
4 | + * objcopy.c (copy_object): For ELF output and non-ELF input without | |
5 | + arch, take arch from output file if not given by -B. Don't | |
6 | + bfd_get_arch_info when we already have iarch. | |
7 | + | |
8 | +2019-11-19 Alan Modra <amodra@gmail.com> | |
9 | + | |
3 | 10 | PR 25191 |
4 | 11 | * objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour. |
5 | 12 | (copy_object): Likewise. |
@@ -2646,8 +2646,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) | ||
2646 | 2646 | imach = bfd_get_mach (ibfd); |
2647 | 2647 | if (input_arch) |
2648 | 2648 | { |
2649 | - if (bfd_get_arch_info (ibfd) == NULL | |
2650 | - || bfd_get_arch_info (ibfd)->arch == bfd_arch_unknown) | |
2649 | + if (iarch == bfd_arch_unknown) | |
2651 | 2650 | { |
2652 | 2651 | iarch = input_arch->arch; |
2653 | 2652 | imach = input_arch->mach; |
@@ -2656,6 +2655,14 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) | ||
2656 | 2655 | non_fatal (_("Input file `%s' ignores binary architecture parameter."), |
2657 | 2656 | bfd_get_archive_filename (ibfd)); |
2658 | 2657 | } |
2658 | + if (iarch == bfd_arch_unknown | |
2659 | + && bfd_get_flavour (ibfd) != bfd_target_elf_flavour | |
2660 | + && bfd_get_flavour (obfd) == bfd_target_elf_flavour) | |
2661 | + { | |
2662 | + const struct elf_backend_data *bed = get_elf_backend_data (obfd); | |
2663 | + iarch = bed->arch; | |
2664 | + imach = 0; | |
2665 | + } | |
2659 | 2666 | if (!bfd_set_arch_mach (obfd, iarch, imach) |
2660 | 2667 | && (ibfd->target_defaulted |
2661 | 2668 | || bfd_get_arch (ibfd) != bfd_get_arch (obfd))) |