[PATCH] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
Andreas Schwab
schwab@suse.de
Wed Jun 28 07:29:32 GMT 2023
On Jun 27 2023, Fangrui Song via Binutils wrote:
> diff --git a/bfd/elf.c b/bfd/elf.c
> index 8f6d7d1adba..d6e21b11419 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -1034,6 +1034,10 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
> if ((hdr->sh_flags & SHF_EXCLUDE) != 0)
> flags |= SEC_EXCLUDE;
>
> + if (get_elf_backend_data (abfd)->elf_machine_code == EM_X86_64)
> + if ((hdr->sh_flags & SHF_X86_64_LARGE) != 0)
> + flags |= SEC_ELF_LARGE;
> +
> switch (elf_elfheader (abfd)->e_ident[EI_OSABI])
> {
> /* FIXME: We should not recognize SHF_GNU_MBIND for ELFOSABI_NONE,
> @@ -3351,6 +3355,8 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
> }
> if ((asect->flags & (SEC_GROUP | SEC_EXCLUDE)) == SEC_EXCLUDE)
> this_hdr->sh_flags |= SHF_EXCLUDE;
> + if (asect->flags & SEC_ELF_LARGE)
> + this_hdr->sh_flags |= SHF_X86_64_LARGE;
Doesn't that need to be conditional on EM_X86_64 as well? I don't see
anything that blocks SEC_ELF_LARGE from being set on incompatible
objects.
> diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
> index 8c14d1121d9..4dd7b83aaa6 100644
> --- a/binutils/doc/binutils.texi
> +++ b/binutils/doc/binutils.texi
> @@ -1740,13 +1740,14 @@ Set the flags for any sections matching @var{sectionpattern}. The
> @var{flags} argument is a comma separated string of flag names. The
> recognized names are @samp{alloc}, @samp{contents}, @samp{load},
> @samp{noload}, @samp{readonly}, @samp{code}, @samp{data}, @samp{rom},
> -@samp{exclude}, @samp{share}, and @samp{debug}. You can set the
> -@samp{contents} flag for a section which does not have contents, but it
> -is not meaningful to clear the @samp{contents} flag of a section which
> -does have contents--just remove the section instead. Not all flags are
> -meaningful for all object file formats. In particular the
> -@samp{share} flag is only meaningful for COFF format files and not for
> -ELF format files.
> +@samp{exclude}, @samp{share}, @samp{debug}, and @samp{large}.
> +You can set the @samp{contents} flag for a section which does not have
> +contents, but it is not meaningful to clear the @samp{contents} flag of a
> +section which does have contents--just remove the section instead. Not all
> +flags are meaningful for all object file formats. In particular the
> +@samp{share} flag is only meaningful for COFF format files and not for ELF
> +format files. @samp{large} is an ELF x86-64 specific flag that corresponds to
> +SHF_X86_64_LARGE.
The last sentence needs to be rearranged so that it doesn't start with a
lower case word.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Binutils
mailing list