From 3bb01b2a961362910ffd0af69676045b970c3dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Thu, 16 Mar 2023 19:31:51 +0100 Subject: [PATCH] PC-relative adress for scalar variables (backported from 47bee47) * Example use of pcrel addressing for variables * const qualifier also puts data into .text section! --- include/cdefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/cdefs.h b/include/cdefs.h index 009644d3..99658c3a 100644 --- a/include/cdefs.h +++ b/include/cdefs.h @@ -15,7 +15,15 @@ #undef __aligned #define __aligned(x) __attribute__((aligned(x))) +/* Annotate variable to be put into text section. This should be used only on + * scalar variable if you want it to be accessed with PC-relative addressing. + * This saves 4 cycles / 2 bytes of instruction memory / 1 relocation. */ +#define __code __attribute__((section(".text"))) +/* Annotate initialized variable to be put into memory accessible + * by custom chipset. */ #define __data_chip __attribute__((section(".datachip"))) +/* Annotate uninitialized variable to be put into memory accessible + * by custom chipset. */ #define __bss_chip __attribute__((section(".bsschip"))) #if __GNUC_PREREQ__(4, 1)