[PATCH v4] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
Fangrui Song
i@maskray.me
Wed Jul 12 15:42:00 GMT 2023
On Wed, Jul 12, 2023 at 7:32 AM Jan Beulich via Binutils
<binutils@sourceware.org> wrote:
>
> On 10.07.2023 20:07, Fangrui Song wrote:
> > On 2023-07-10, Jan Beulich wrote:
> >> On 08.07.2023 07:30, Fangrui Song via Binutils wrote:
> >>> @@ -2631,6 +2634,19 @@ check_new_section_flags (flagword flags, bfd * abfd, const char * secname)
> >>> bfd_get_filename (abfd), secname);
> >>> flags &= ~ SEC_COFF_SHARED;
> >>> }
> >>> +
> >>> + /* Report a fatal error if 'large' is used with a non-x86-64 ELF target.
> >>> + Suppress the error for non-ELF targets to allow -O binary and formats that
> >>> + use the bit value SEC_ELF_LARGE for other purposes. */
> >>> + if ((flags & SEC_ELF_LARGE) != 0
> >>> + && bfd_get_flavour (abfd) == bfd_target_elf_flavour
> >>> + && get_elf_backend_data (abfd)->elf_machine_code != EM_X86_64)
> >>
> >> DYM
> >>
> >> if ((flags & SEC_ELF_LARGE) != 0
> >> && (bfd_get_flavour (abfd) != bfd_target_elf_flavour
> >> || get_elf_backend_data (abfd)->elf_machine_code != EM_X86_64))
> >>
> >> ?
> >
> > I do mean that this check is fired only when the output bfd (abfd) is
> > ELF and the architecture is different from x86-64.
> >
> > The bit value SEC_ELF_LARGE is shared with other object file formats
> > (COFF SEC_TIC54X_BLOCK; I don't know what this target is).
> > If TMS320C54X has a section with the SEC_TIC54X_BLOCK flag, we
> > don't want to report a fatal error.
>
> Hmm, I think I see what you mean. May I then suggest to re-order like
> this:
>
> if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
> && (flags & SEC_ELF_LARGE) != 0
> && get_elf_backend_data (abfd)->elf_machine_code != EM_X86_64)
>
> ?
>
> Jan
Yes, I think we can do this, but the current order likely leads to
better performance (does not matter, though)
since `flags` is a variable that's immediately available. and matches
the style of flags & SEC_COFF_SHARED.
That said, I do not insist that we insist on doing this. Feel free to
change if you feel strongly:)
More information about the Binutils
mailing list