From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34166 invoked by alias); 23 Jan 2018 03:32:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 34155 invoked by uid 89); 23 Jan 2018 03:32:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=meetings, HX-Received:10.99.110.78 X-HELO: mail-pf0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=VuKyw7l54wWW0AtNF6H5xfVVtvR2D8wQvOVymKeRXGk=; b=eMqbGL0TpKhEhm5hwnLTQne/oo7WxsD9itElytjqjOzlj7fbq4kzDZwDJdfBWuAcY2 u+6z+FJDl6vuCIkcFiXPE73ttQTDysXRbc8+GEXRuMlr6r/pouaY6Yq8cPWtcSQRCqqL /fhkse9QtNMQe/rGxlwNV9b70jrG4S07/cpm2p4CaZNvNLgpzQrIkWqG9ca0z0ynYTkE yzBZTjELRi8vOx9Qu5i0PSRnaIkdZlCiptff7vh5A21hBENjXfEyp5Y4NKnJ9+uqIVTm CMANWRplpVoVQoar59BG/p6jtIU2InxeLL4QaIFbDUEa+4NR5GtLtCWmtpa5z1FH3sNM vTNg== X-Gm-Message-State: AKwxyteK1/3jzEoFZjuScYfH+zdFPyD+WA+gEuvp3WkhzNUfIEoFkmCK UPrN+NuZL/62UvEgHXLAh7QaEqUsdDo= X-Google-Smtp-Source: AH8x226D+XKNMrPOzEcLrfDetsfYjiFP1ox9lnupxDbbh7+DNcrGzmPiD2iEVgvz1oaQPtXzK4/uzQ== X-Received: by 10.99.110.78 with SMTP id j75mr8101956pgc.96.1516678338203; Mon, 22 Jan 2018 19:32:18 -0800 (PST) Date: Tue, 23 Jan 2018 03:32:00 -0000 X-Google-Original-Date: Mon, 22 Jan 2018 19:31:59 PST (-0800) Subject: Re: [PATCH v4 06/17] RISC-V: Startup and Dynamic Loading Code In-Reply-To: CC: libc-alpha@sourceware.org, patches@groups.riscv.org From: Palmer Dabbelt To: joseph@codesourcery.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2018-01/txt/msg00734.txt.bz2 On Mon, 22 Jan 2018 15:08:55 PST (-0800), joseph@codesourcery.com wrote: > On Mon, 22 Jan 2018, Palmer Dabbelt wrote: > >> Ah, OK -- when I was going through something else I was wondering how that got >> enforced, I guess the answer is that it wasn't. I think something like this >> should do it >> >> diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h >> index 7d4fcee79662..21e401dbf2fb 100644 >> --- a/sysdeps/riscv/dl-machine.h >> +++ b/sysdeps/riscv/dl-machine.h >> @@ -57,7 +57,20 @@ >> static inline int __attribute_used__ >> elf_machine_matches_host (const ElfW (Ehdr) *ehdr) >> { >> - return ehdr->e_machine == EM_RISCV; >> + /* We can only run RISC-V binaries. */ >> + if (ehdr->e_machine != EM_RISCV) >> + return 1; > > This looks like it's inverted (should return 0 for non-RISCV, not 1). Thanks -- that's why I shouldn't try to squeeze this stuff in between meetings, I also left half of a comment in there. I think this should do it /* Return nonzero iff ELF header is compatible with the running host. */ static inline int __attribute_used__ elf_machine_matches_host (const ElfW (Ehdr) *ehdr) { /* We can only run RISC-V binaries. */ if (ehdr->e_machine != EM_RISCV) return 0; /* Ensure the library's floating-point ABI matches that of the running system. For now we don't support mixing XLEN, so there's no need (or way) to check it matches. */ #ifdef __ricsv_float_abi_double if ((ehdr->e_flags & EF_RISCV_FLOAT_ABI) != EF_RISCV_FLOAT_ABI_DOUBLE) return 0; #else if ((ehdr->e_flags & EF_RISCV_FLOAT_ABI) != EF_RISCV_FLOAT_ABI_SOFT) return 0; #endif return 1; }