Skip to content

Commit

Permalink
PC-relative adress for scalar variables (backported from 47bee47)
Browse files Browse the repository at this point in the history
* Example use of pcrel addressing for variables
* const qualifier also puts data into .text section!
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent 6654e49 commit 3bb01b2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3bb01b2

Please sign in to comment.