From patchwork Tue Jul 20 20:58:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 44441 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB6A6398AC27 for ; Tue, 20 Jul 2021 21:04:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB6A6398AC27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626815062; bh=vhEk1EPc+ZYUUn7kfzji9is9CpB0GJs19TqD003V6Vs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Q/U8+H5FaAD9ZB4rgCzAa0DLiRYwmiw/T+6yRpqweBQApFnRfIBWahiwYyGpbqCQV i6I+FqWvNfBbAQw4cDg7xegmZV0lcS2Evktm4/2TBhxh6Q2F5BI8J+vMwJdZN4l/up Rn1BykJBEHJcDg2tlqKzO6JCmAl6b8lDFsGUSEjc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.87.133]) by sourceware.org (Postfix) with ESMTPS id 6543C398D401 for ; Tue, 20 Jul 2021 20:58:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6543C398D401 Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 8C97EC378C; Tue, 20 Jul 2021 20:58:12 +0000 (UTC) Received: from vineetg-Latitude-7400.internal.synopsys.com (snps-fugpbdpduq.internal.synopsys.com [10.202.17.37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id BDDC7A026B; Tue, 20 Jul 2021 20:58:11 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Subject: [PATCH 2/2] ARC: elf: make type safe Date: Tue, 20 Jul 2021 13:58:00 -0700 Message-Id: <20210720205800.1056218-3-vgupta@synopsys.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210720205800.1056218-1-vgupta@synopsys.com> References: <20210720205800.1056218-1-vgupta@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vineet Gupta via Libc-alpha From: Vineet Gupta Reply-To: Vineet Gupta Cc: Vineet Gupta , linux-snps-arc@lists.infradead.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Vineet Gupta --- sysdeps/arc/dl-machine.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h index 60b49af0d5ca..e6ce7f0ff6d9 100644 --- a/sysdeps/arc/dl-machine.h +++ b/sysdeps/arc/dl-machine.h @@ -86,7 +86,7 @@ /* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (const Elf32_Ehdr *ehdr) +elf_machine_matches_host (const ElfW(Ehdr) *ehdr) { return (ehdr->e_machine == EM_ARCV2 /* ARC HS. */ || ehdr->e_machine == EM_ARC_COMPACT); /* ARC 700. */ @@ -124,7 +124,7 @@ static inline int __attribute__ ((always_inline)) elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) { - extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_resolve (void); if (l->l_info[DT_JMPREL] && lazy) { @@ -202,7 +202,7 @@ __start: \n\ /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ #define ELF_MACHINE_JMP_SLOT R_ARC_JUMP_SLOT -/* ARC uses Elf32_Rela relocations. */ +/* ARC uses Rela relocations. */ #define ELF_MACHINE_NO_REL 1 #define ELF_MACHINE_NO_RELA 0 @@ -211,19 +211,14 @@ __start: \n\ static inline ElfW(Addr) elf_machine_fixup_plt (struct link_map *map, lookup_t t, const ElfW(Sym) *refsym, const ElfW(Sym) *sym, - const Elf32_Rela *reloc, + const ElfW(Rela) *reloc, ElfW(Addr) *reloc_addr, ElfW(Addr) value) { return *reloc_addr = value; } /* Return the final value of a plt relocation. */ -static inline ElfW(Addr) -elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, - ElfW(Addr) value) -{ - return value; -} +#define elf_machine_plt_value(map, reloc, value) (value) /* Names of the architecture-specific auditing callback functions. */ #define ARCH_LA_PLTENTER arc_gnu_pltenter @@ -239,8 +234,9 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, const ElfW(Sym) *sym, const struct r_found_version *version, void *const reloc_addr_arg, int skip_ifunc) { + ElfW(Addr) r_info = reloc->r_info; + const unsigned long int r_type = ELFW (R_TYPE) (r_info); ElfW(Addr) *const reloc_addr = reloc_addr_arg; - const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); if (__glibc_unlikely (r_type == R_ARC_RELATIVE)) *reloc_addr += map->l_addr; @@ -334,11 +330,12 @@ elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr, const ElfW(Rela) *reloc, int skip_ifunc) { ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset); + const unsigned int r_type = ELFW (R_TYPE) (reloc->r_info); - if (ELF32_R_TYPE (reloc->r_info) == R_ARC_JUMP_SLOT) + if (r_type == R_ARC_JUMP_SLOT) *reloc_addr += l_addr; else - _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); + _dl_reloc_bad_type (map, r_type, 1); } #endif /* RESOLVE_MAP */