Created
May 11, 2017 07:07
-
-
Save gabrielschulhof/02fa140c2c4f93c82ee83e7773bdeb90 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
#include <stdio.h> | |
typedef struct { | |
int x; | |
int y; | |
} something_t; | |
static something_t a __attribute((used, section("foo_data"), aligned(sizeof (void *)))) = { .x = 5, .y = 6 }; | |
static something_t b __attribute((used, section("foo_data"), aligned(sizeof (void *)))) = { .x = 7, .y = 8 }; | |
static something_t c __attribute((used, section("bar_data"), aligned(sizeof (void *)))) = { .x = 1, .y = 2 }; | |
static something_t d __attribute((used, section("bar_data"), aligned(sizeof (void *)))) = { .x = 3, .y = 4 }; | |
extern something_t __start_foo_data[] __attribute__((weak)); | |
extern something_t __stop_foo_data[] __attribute__((weak)); | |
extern something_t *__start_bar_data __attribute__((weak)); | |
extern something_t *__stop_bar_data __attribute__((weak)); | |
int | |
main() | |
{ | |
printf("__start_foo_data: %p\n", __start_foo_data); | |
printf("__stop_foo_data: %p\n", __stop_foo_data); | |
printf("__start_bar_data: %p\n", __start_bar_data); | |
printf("__stop_bar_data: %p\n", __stop_bar_data); | |
return 0; | |
} |
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
$ ./tmp | |
__start_foo_data: 0x601028 | |
__stop_foo_data: 0x601038 | |
__start_bar_data: 0x200000001 | |
__stop_bar_data: (nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment