Last active
August 29, 2015 14:15
-
-
Save corecode/875124f1716b77ff6a36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern int __attribute__((section(".data.foo"))) x; | |
int __attribute__((section(".text.foo"))) foo(int); | |
int __attribute__((section(".text.bar"), noinline)) bar(int y) { | |
return foo(x + y); | |
} | |
extern "C" void _start(void) { | |
volatile int i; | |
volatile int v = bar(i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flags="-O2 -W -Wall -fPIE -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -ffreestanding -nostdlib -std=gnu++11 -fno-exceptions -flto -nostartfiles" | |
arm-none-eabi-g++ $flags -c -o foo.o foo.c | |
arm-none-eabi-g++ $flags -c -o bar.o bar.c | |
arm-none-eabi-g++ $flags foo.o bar.o -o test.elf | |
arm-none-eabi-objdump -d test.elf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int __attribute__((section(".data.foo"))) a = 0; | |
int __attribute__((section(".data.foo"))) x = 0; | |
int __attribute__((section(".data.foo"))) b = 0; | |
int __attribute__((section(".text.foo"))) foo(int x) { | |
return x; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.elf: file format elf32-littlearm | |
Disassembly of section .text: | |
00008000 <_start>: | |
8000: e52de004 push {lr} ; (str lr, [sp, #-4]!) | |
8004: e24dd00c sub sp, sp, #12 | |
8008: e59d0004 ldr r0, [sp, #4] | |
800c: eb000002 bl 801c <_Z3bari.4016> | |
8010: e58d0000 str r0, [sp] | |
8014: e28dd00c add sp, sp, #12 | |
8018: e49df004 pop {pc} ; (ldr pc, [sp], #4) | |
0000801c <_Z3bari.4016>: | |
801c: e59f300c ldr r3, [pc, #12] ; 8030 <_Z3bari.4016+0x14> | |
8020: e08f3003 add r3, pc, r3 | |
8024: e5933000 ldr r3, [r3] | |
8028: e0800003 add r0, r0, r3 | |
802c: e12fff1e bx lr | |
8030: 0000800c .word 0x0000800c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment