From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74340 invoked by alias); 20 Apr 2017 09:27:45 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 74320 invoked by uid 89); 20 Apr 2017 09:27:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=HX-Google-DKIM-Signature:reply-to X-HELO: mail-oi0-f49.google.com Received: from mail-oi0-f49.google.com (HELO mail-oi0-f49.google.com) (209.85.218.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Apr 2017 09:27:43 +0000 Received: by mail-oi0-f49.google.com with SMTP id y11so10286982oie.0 for ; Thu, 20 Apr 2017 02:27:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to; bh=fEhucTkC5HMAmDigGk2EEP5ehkWkLLehwRqqPKmgDUk=; b=bFObxL2Cfg8aXMzXlFVEIgwCmrM6DfU/oeiiIWduuSsFT+4/0CdNhQ9pJszeTOCcU3 g4qYgSHiXY8whJhQeO5fhe1JDhxRqZPO7Qscra3eW0oVUyiYJ9RcQcubDpV/vWAti+Hj +0G83cbDrWhw05ANxNJBqfOE3H1Zlg237DlRVonQJ/cpAtrVRV8mLKPYaLRJa84f9Bom MtfaS3YEgxyw78t1z2cZGpzdupQOLExAvWHlS1LFZOMR06hIcNDKDOiXK83FnKcnxrXN bNxdUiLXJQ/0CksQpbYS/UfZZ0UAUkbh+2hRbmekcvvlshWyDWW6IamAOhhUWWyZjB+b UMCw== X-Gm-Message-State: AN3rC/7wrkSAVj8GjY/2693Ajkm8oUbtO2uTYvBErENp3VXfOLGd7gJo b57OwacATdDBMCyt5WaTw1E46HutrvJ6sbU= X-Received: by 10.157.8.98 with SMTP id 89mr3752626oty.234.1492680463268; Thu, 20 Apr 2017 02:27:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.139.199 with HTTP; Thu, 20 Apr 2017 02:27:42 -0700 (PDT) Reply-To: noloader@gmail.com In-Reply-To: References: From: Jeffrey Walton Date: Thu, 20 Apr 2017 09:27:00 -0000 Message-ID: Subject: Re: How to save and restore a symbol value in Aarch64? To: Binutils Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2017-04/txt/msg00168.txt.bz2 On Thu, Apr 20, 2017 at 5:16 AM, Jeffrey Walton wrote: > I'm trying to save (and restore) the original value of a symbol under > Aarch64. The code runs on a variety of machines, and it looks like I > need a solution for Binutils 2.24 and above. > > I know .set allows me to set the symbol value: > > asm(".set .cpu, generic+crc \n" ... ); > > I need the method to get the previous .cpu value and save it for the > restore. About all I have been able to do is cause assembler errors. > For example: > > __inline unsigned int GCC_INLINE_ATTRIB > CRC32B(unsigned int crc, unsigned char v) > { > unsigned int r; > asm (".set old_cpu, .cpu \n" > ".cpu generic+crc \n" > "crc32w %w2, %w1, %w0 \n" > ".set .cpu, old_cpu \n" > : "=r"(r) : "r"(crc), "r"((unsigned int)v) > ); > return r; > } > > It results in: > > Adding a leading dot results in: > > My question is, how do I save and restore a symbol value for Binutils > 2.2.4 and above on Aarch64? Sorry about the truncated message. Here are the error messages. For ".set old_cpu, .cpu \n" (no leading dot): /tmp/ccbAvT3u.s: Assembler messages: /tmp/ccbAvT3u.s:32: Error: unknown mnemonic `old_cpu' -- `old_cpu .equ .cpu' /tmp/ccbAvT3u.s:35: Error: unknown mnemonic `set' -- `set .cpu,old_cpu' For ".set .old_cpu, .cpu \n" (leading dot): /tmp/cc0r6bvh.s: Assembler messages: /tmp/cc0r6bvh.s:32: Error: unknown pseudo-op: `.old_cpu' Here's the relevant AS manual section that discusses symbols: http://tigcc.ticalc.org/doc/gnuasm.html#SEC45 Jeff