From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 2EAA53858D3C for ; Tue, 12 Sep 2023 10:02:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2EAA53858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy05.your-server.de ([78.46.172.2]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg0Dw-000EYY-8o for binutils@sourceware.org; Tue, 12 Sep 2023 12:02:24 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qg0Dw-000JiA-4n for binutils@sourceware.org; Tue, 12 Sep 2023 12:02:24 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id B2D66480051 for ; Tue, 12 Sep 2023 12:02:23 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10032) with ESMTP id 2RqvHUQTfSO4 for ; Tue, 12 Sep 2023 12:02:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 4FD794801AF for ; Tue, 12 Sep 2023 12:02:23 +0200 (CEST) X-Virus-Scanned: amavis at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10026) with ESMTP id 7MJM9yCNM76c for ; Tue, 12 Sep 2023 12:02:23 +0200 (CEST) Received: from [10.10.171.34] (unknown [10.10.171.34]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 0B3E9480051 for ; Tue, 12 Sep 2023 12:02:22 +0200 (CEST) Message-ID: <2d247374-92a2-463b-ba23-8a6dc36d13c0@embedded-brains.de> Date: Tue, 12 Sep 2023 12:02:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: binutils From: Sebastian Huber Subject: How to define a symbol with absolute address for AArch64? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldi-networks.de X-Virus-Scanned: Clear (ClamAV 0.103.8/27029/Tue Sep 12 09:38:51 2023) X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP 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: Hello, I would like to define a global symbol with an absolute address in an=20 assembly/C source file for the AArch64 target. This works for all other=20 architectures I tried so far, but not for AArch64: extern char abs_symbol[]; extern char abs_symbol_2[]; __asm__( "\t.globl abs_symbol\n" "\t.set abs_symbol, 0x123\n" ); unsigned long f_abs_symbol(void) { return (unsigned long)abs_symbol; } unsigned long f_abs_symbol_2(void) { return (unsigned long)abs_symbol_2; } unsigned long _start(void) { return f_abs_symbol() + f_abs_symbol_2(); } aarch64-rtems6-gcc abs.c -Wl,--gc-sections -Wl,--defsym=3Dabs_symbol_2=3D= 291 aarch64-rtems6-objdump -d a.out a.out: file format elf64-littleaarch64 Disassembly of section .text: 0000000000400000 : 400000: 90000000 adrp x0, 400000 400004: 91048c00 add x0, x0, #0x123 400008: d65f03c0 ret 000000000040000c : 40000c: 90ffe000 adrp x0, 0 400010: 91048c00 add x0, x0, #0x123 400014: d65f03c0 ret 0000000000400018 <_start>: 400018: a9be7bfd stp x29, x30, [sp, #-32]! 40001c: 910003fd mov x29, sp 400020: f9000bf3 str x19, [sp, #16] 400024: 97fffff7 bl 400000 400028: aa0003f3 mov x19, x0 40002c: 97fffff8 bl 40000c 400030: 8b000260 add x0, x19, x0 400034: f9400bf3 ldr x19, [sp, #16] 400038: a8c27bfd ldp x29, x30, [sp], #32 40003c: d65f03c0 ret On riscv it works for example: riscv-rtems6-gcc abs.c -Wl,--gc-sections -Wl,--defsym=3Dabs_symbol_2=3D29= 1=20 -O2 -march=3Drv64imafd -mabi=3Dlp64d -mcmodel=3Dmedany riscv-rtems6-objdump -d a.out a.out: file format elf64-littleriscv Disassembly of section .text: 00000000000100b0 : 100b0: 1230051b addiw a0,zero,291 100b4: 00008067 ret 00000000000100b8 : 100b8: 12300513 li a0,291 100bc: 00008067 ret 00000000000100c0 <_start>: 100c0: 12300793 li a5,291 100c4: 1230051b addiw a0,zero,291 100c8: 00f50533 add a0,a0,a5 100cc: 00008067 ret --=20 embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M=C3=BCnchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler Unsere Datenschutzerkl=C3=A4rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/