public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH v4] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
Date: Mon, 10 Jul 2023 11:07:34 -0700	[thread overview]
Message-ID: <20230710180734.tfgfctsvl7ipo6at@google.com> (raw)
In-Reply-To: <2a422912-1b90-d1d0-49ba-c2898680a6fe@suse.com>

On 2023-07-10, Jan Beulich wrote:
>On 08.07.2023 07:30, Fangrui Song via Binutils wrote:
>> --- a/bfd/section.c
>> +++ b/bfd/section.c
>> @@ -359,6 +359,9 @@ CODE_FRAGMENT
>>  .     TMS320C54X only.  *}
>>  .#define SEC_TIC54X_BLOCK           0x10000000
>>  .
>> +.  {* This section has the SHF_X86_64_LARGE flag.  This is ELF x86-64 only.  *}
>> +.#define SEC_ELF_LARGE              0x10000000
>> +.
>>  .  {* Conditionally link this section; do not link if there are no
>>  .     references found to any symbol in the section.  This is for TI
>>  .     TMS320C54X only.  *}
>> @@ -2618,7 +2621,7 @@ merge_gnu_build_notes (bfd *          abfd,
>>  }
>>
>>  static flagword
>> -check_new_section_flags (flagword flags, bfd * abfd, const char * secname)
>> +check_new_section_flags (flagword flags, bfd *abfd, const char * secname)
>
>Nit: Stray (and inconsistent) change?

Sorry, this was an unneeded change.

I guess I formatted this line either in editor or via .clang-format but
I reverted `const char *secname` but not `bfd *abfd`...

>> @@ -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))
>
>?
>
>Jan

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.

In addition, abfd may specify a non-ELF bfd, e.g.,

     objcopy --set-section-flags .data=alloc,large -I elf64-x86-64 -O binary a.o a.bin

I assume that this case should receive no warning/error, just like how
many other flags like 'load', 'noload' behave today.

>> +    {
>> +      fatal (_ ("%s[%s]: 'large' flag is ELF x86-64 specific"),
>> +	     bfd_get_filename (abfd), secname);
>> +      flags &= ~SEC_ELF_LARGE;
>> +    }
>> +
>>    return flags;
>>  }
>>
>
>

  reply	other threads:[~2023-07-10 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08  5:30 Fangrui Song
2023-07-09 13:35 ` Alan Modra
2023-07-09 17:46   ` Fangrui Song
2023-07-10  6:37 ` Jan Beulich
2023-07-10 18:07   ` Fangrui Song [this message]
2023-07-12 14:32     ` Jan Beulich
2023-07-12 15:42       ` Fangrui Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230710180734.tfgfctsvl7ipo6at@google.com \
    --to=maskray@google.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).