From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id A17453858411; Sun, 9 Jan 2022 17:45:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A17453858411 Received: by mail-pj1-x102c.google.com with SMTP id rj2-20020a17090b3e8200b001b1944bad25so13614121pjb.5; Sun, 09 Jan 2022 09:45:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hIYsp7UksB7nJTqZkBuhrh0cj1moyfohTvtULKMQIbg=; b=tnEOQmfBZ5w0iDhKysUGfP52RUPIDH9cKfB1TaOBTjIZdhA8kSjwmXTAZYNku7R2aN C2WU6JF8Evedl2sGdC/7OMmE/ryRmq3ZIXuZBBVMUvt5sBaS3qlpkVOoG+9gI4EyZDaL rpAqpm++wllqakT/YGx6qFgg/VN5FpMs0KPtWVb/2eKI2YnAtVSb6WpWDgULTElsth4w 8lm4nzMGLjhffn5NtGmteAA95EQUB43aQo7lhKRGFkDL2mGQcHVJwmuHD5xBm2qSEAqt z2SFmZgjtNPo4J7RyMNINEdyU9toNqPyWUoUELkMZ5JXKhvuhXCRlaqrHhjpcOtO8oJF cvaw== X-Gm-Message-State: AOAM531ZpbSr75GfY22ibUs7YH90Wue9gZG2ZfcJVEdKC7M2WQZKKP90 M3CdWwgl6Zw6NSwCuXVf7NvDzktMCu4= X-Google-Smtp-Source: ABdhPJzTWqwc6YiChOkrUqkr8vjPyehW2SoWT5/p4KUYxZ763JLlFWe47VScRvjzrqdEZyQFExd/9Q== X-Received: by 2002:a17:902:9343:b0:148:a2e7:fb5f with SMTP id g3-20020a170902934300b00148a2e7fb5fmr75907365plp.160.1641750305822; Sun, 09 Jan 2022 09:45:05 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id f13sm4419688pfv.98.2022.01.09.09.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 09:45:05 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 3AF42C073B; Sun, 9 Jan 2022 09:45:04 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Cc: gdb-patches@sourceware.org, Fangrui Song Subject: [gdb-11-branch: Patch 3/3] bfd_section_from_shdr: Support SHT_RELR sections Date: Sun, 9 Jan 2022 09:45:04 -0800 Message-Id: <20220109174504.1120244-4-hjl.tools@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220109174504.1120244-1-hjl.tools@gmail.com> References: <20220109174504.1120244-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3028.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jan 2022 17:45:10 -0000 From: Fangrui Song If a.so contains an SHT_RELR section, objcopy a.so will fail with: a.so: unknown type [0x13] section `.relr.dyn' This change allows objcopy to work. bfd/ * elf.c (bfd_section_from_shdr): Support SHT_RELR. (cherry picked from commit a619b58721f0a03fd91c27670d3e4c2fb0d88f1e) --- bfd/elf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bfd/elf.c b/bfd/elf.c index 3d9c5ff03cc..985167fd85c 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -2358,16 +2358,22 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) case SHT_REL: case SHT_RELA: + case SHT_RELR: /* *These* do a lot of work -- but build no sections! */ { asection *target_sect; Elf_Internal_Shdr *hdr2, **p_hdr; unsigned int num_sec = elf_numsections (abfd); struct bfd_elf_section_data *esdt; + bfd_size_type size; - if (hdr->sh_entsize - != (bfd_size_type) (hdr->sh_type == SHT_REL - ? bed->s->sizeof_rel : bed->s->sizeof_rela)) + if (hdr->sh_type == SHT_REL) + size = bed->s->sizeof_rel; + else if (hdr->sh_type == SHT_RELA) + size = bed->s->sizeof_rela; + else + size = bed->s->arch_size / 8; + if (hdr->sh_entsize != size) goto fail; /* Check for a bogus link to avoid crashing. */ -- 2.34.1