[PATCH] objcopy: Add elf header e_flags option in objcopy.

Alan Modra amodra@gmail.com
Fri Apr 15 02:03:33 GMT 2022
On Thu, Apr 14, 2022 at 07:29:06PM +0800, liuzhensong wrote:
> @@ -660,6 +666,7 @@ copy_usage (FILE *stream, int exit_status)
>       --weaken-symbols <file>       -W for all symbols listed in <file>\n\
>       --add-symbol <name>=[<section>:]<value>[,<flags>]  Add a symbol\n\
>       --alt-machine-code <index>    Use the target's <index>'th alternative machine\n\
> +     --alt-elf-eflags=<value> 	   Use the alternative elf header e_flags\n\

Don't use tabs in help messages.

>       --writable-text               Mark the output text as writable\n\
>       --readonly-text               Make the output text write protected\n\
>       --pure                        Mark the output file as demand paged\n\
> @@ -3496,6 +3503,11 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
>  	}
>      }
>  
> +  if (alt_elf_eflags_set)
> +    {
> +      elf_elfheader (obfd)->e_flags = alt_elf_eflags;
> +    }
> +

Needs a check bfd_get_flavour (obfd) == bfd_target_elf_flavour before
writing a field only in ELF bfd, and no need for braces.

Also, please update binutils/doc.texi with the new objcopy option.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list