From: Alan Modra <amodra@gmail.com>
To: Fangrui Song <maskray@google.com>
Cc: binutils@sourceware.org, Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v3] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
Date: Fri, 7 Jul 2023 17:54:27 +0930 [thread overview]
Message-ID: <ZKfLuzDgUg6w2j31@squeak.grove.modra.org> (raw)
In-Reply-To: <20230707054306.2810080-1-maskray@google.com>
On Thu, Jul 06, 2023 at 10:43:06PM -0700, Fangrui Song via Binutils wrote:
> include/
> * elf/common.h: Define SHF_X86_64_LARGE to be used by elf.c.
Don't do this.
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -1045,6 +1045,11 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
> if ((hdr->sh_flags & SHF_EXCLUDE) != 0)
> flags |= SEC_EXCLUDE;
>
> + bed = get_elf_backend_data (abfd);
> + if (bed->elf_machine_code == EM_X86_64 &&
> + (hdr->sh_flags & SHF_X86_64_LARGE) != 0)
> + flags |= SEC_ELF_LARGE;
Or this. Instead write an elf_backend_section_flags for x86_64.
> @@ -3912,6 +3916,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 (bed->elf_machine_code == EM_X86_64 && (asect->flags & SEC_ELF_LARGE) != 0)
> + this_hdr->sh_flags |= SHF_X86_64_LARGE;
>
Or this. Instead write elf_backend_fake_sections for x86_64.
> /* If the section has relocs, set up a section header for the
> SHT_REL[A] section. If two relocation sections are required for
> @@ -8508,6 +8514,10 @@ _bfd_elf_init_private_section_data (bfd *ibfd,
> elf_section_flags (osec) = (elf_section_flags (isec)
> & (SHF_MASKOS | SHF_MASKPROC));
>
> + /* objcopy --set-section-flags without "large" drops SHF_X86_64_LARGE. */
> + if (get_elf_backend_data (ibfd)->elf_machine_code == EM_X86_64)
> + elf_section_flags (osec) = (elf_section_flags (isec) & ~SHF_X86_64_LARGE);
> +
> /* Copy sh_info from input for mbind section. */
> if ((elf_tdata (ibfd)->has_gnu_osabi & elf_gnu_osabi_mbind) != 0
> && elf_section_flags (isec) & SHF_GNU_MBIND)
And this should be done in a bfd_elf64_bfd_copy_private_symbol_data
for x86_64.
--
Alan Modra
Australia Development Lab, IBM
prev parent reply other threads:[~2023-07-07 8:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 5:43 Fangrui Song
2023-07-07 8:24 ` Alan Modra [this message]
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=ZKfLuzDgUg6w2j31@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=jbeulich@suse.com \
--cc=maskray@google.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).