From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id 072253858C31 for ; Mon, 10 Jul 2023 18:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 072253858C31 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-401d1d967beso39751cf.0 for ; Mon, 10 Jul 2023 11:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689012459; x=1691604459; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=y9gVPr4dA0pysJqYOdeLqwDpT/MAbSwRbrHXbYCKA4M=; b=15v+FGFG0VBaoqPpEmXV02POuQkkKhJzH5htdAMzRay8cAsc4TV0Y6jsFlAeBNgIgg Eepz7oJN0JSF8H7M6COlzA2lATdBGeDgxyT9WnRP+yG0UQHqHZxE3HVLn50lg0r/3FhG 7tu6Iy+SozyhQkdg33WGnb7SB2NmLDcDvP0f9KpB669lAgRRfjipWuy/ZNP/cqDJvJlF yn5k/Ahtxi/FM1MyQC3CKlSPkM67dBdJV13XUOKY6KxyDO+PTz2J5thLOqWXmBAfMrQb 7oiYjMr84UUrAoT/Mg0YS6InM8FO2H0E58DppPUf8cg1IvNAFSkvwJplqpuTgfVA6PEt 3O6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689012459; x=1691604459; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y9gVPr4dA0pysJqYOdeLqwDpT/MAbSwRbrHXbYCKA4M=; b=Z/JqrL3p9uHZ4KwyIsvH3fXLn1Onjv0Tl7b45fUWUMwwVCRNwB4D6l50wbmYYXk6xM uLifsmcEOh/Hv8aq04WvXiyU9RCV37Bhw0MIh9YfRPLO/c28ci8vAOeFI4YwCaTywRhT pbAhqzjS8UgJvdsSRFcmhxUf98Z7tD/Sm34mbZg0FX0qKX6M9sCO4inYdondOAkD6r80 taGMpfcg9OhT/f50GYZsz3XgkvvZ78DDEYPxO4M/sGk5fRADCzBSZhrm4liFanSEfmKT s2xQMxkHVn2ao5LLdO1awlq9wzUxAdCFh+MDS3AINSwUPYSsDjJbn1R/OBfk+GxuBZn6 OYvQ== X-Gm-Message-State: ABy/qLaRhkYHAX8U9nIKG3E4Sil8sSuCUWA9ALThMktmn6c9xmQpH0OJ lPad0qs9/ZYoSLvqYgwyW9ecgMd373xpqI3IJe3tGw== X-Google-Smtp-Source: APBJJlGAY3ARrbHAV12GR3lW9e5n8YOpein329GyuXL893StXxFZpaXMhGVbyqBrRLRBo84lOK8ppA== X-Received: by 2002:a05:622a:1aa8:b0:3f4:f0fd:fe7e with SMTP id s40-20020a05622a1aa800b003f4f0fdfe7emr10867qtc.3.1689012459126; Mon, 10 Jul 2023 11:07:39 -0700 (PDT) Received: from google.com ([2620:15c:2d3:205:1736:7c81:1bc8:20f3]) by smtp.gmail.com with ESMTPSA id c3-20020aa781c3000000b0067978a01246sm117202pfn.14.2023.07.10.11.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 11:07:38 -0700 (PDT) Date: Mon, 10 Jul 2023 11:07:34 -0700 From: Fangrui Song To: Jan Beulich Cc: binutils@sourceware.org Subject: Re: [PATCH v4] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE Message-ID: <20230710180734.tfgfctsvl7ipo6at@google.com> References: <20230708053035.528911-1-maskray@google.com> <2a422912-1b90-d1d0-49ba-c2898680a6fe@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2a422912-1b90-d1d0-49ba-c2898680a6fe@suse.com> X-Spam-Status: No, score=-20.0 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,FSL_HELO_FAKE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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; >> } >> > >