Lets get a bit closer to the metal than usual! The task is to pass a constant value between the different data memory sections of a typical computer.
For this challenge you need a system and language which allows you to allocate variables in all of the following sections (using ELF notation):
- `.rodata` or `.text`
- `.data`
- `.bss`
- `.stack`
- `.heap`
Start by allocate an integer constant value in a read-only section (`.rodata` or `.text` etc).
Print the integer value and its address using the syntax `value <space> address <new line>`. The value should be printed with decimal notation and the address with hex notation.
Any common hex prefix/suffix is allowed, or could be left out: `ABCD`, `0xABCD`, `ABCDh` and `$ABCD` are all valid outputs for the hex part.
Once printed, copy the value to any of the other memory sections above - in any order, then print it again, with the same syntax. Repeat until the value has passed through all memory sections.
**Example in non-golfed standard C (gcc), using the value 5:**
<!-- language-all: lang-c -->
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main (void)
{
static const int a=5;  
printf("%d %p\n",a,&a); // .rodata
 
static int b; b=a;
printf("%d %p\n",b,&b); // .bss
 
int c=b;
printf("%d %p\n",c,&c); // .stack
static int d=1;
d=c;
printf("%d %p\n",d,&d); // .data
 
int* e = malloc(sizeof *e);
*e=d;
printf("%d %p\n",*e,e); // .heap
}
</code></pre>
[Try it online!][TIO-kssq2w7x]
[C (gcc)]: https://gcc.gnu.org/
[TIO-kssq2w7x]: https://tio.run/##bZDBTgMhEIbvPMWkTTe7G9rqwdOKr@ALeBlm2JaIsCnUg8ZXF0FJTJOd4z/f9w@B9ieinLfWk7uygceY2IbD@UncRM7qmgnrE7yh9dC/B8uD@BQAMWGyBBR8TFABVA8TlCm75VKCud/sGHbLi99IlB0OExyPcLgExoTil2sd1dYTaIXTmqxlp5usY/wzq0JKr/IkO2p8OUCv4vYSq/uqsaJVm2XHzf5/aGFGMKDKLzgXqI/2w4QZRjPUjtEoXu0ajTSt62xwEV8i52@aHZ5i3j/f/QA "C (gcc) – Try It Online"
Output on Linux x86_64 (gcc/glibc):
```
5 0x402018
5 0x404034
5 0x7ffe4c9635e4
5 0x40402c
5 0x100de70
```
Output on Windows 86_64 (gcc/mingw/ms crt):
```
5 0000000000404008
5 0000000000407030
5 000000000022FE44
5 0000000000403010
5 0000000000327D90
```
Because of memory mapping, ASLR and similar, no solution is expected to have the same addresses. Yet one should be able to reason that large address differences generally means different sections.