Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Created August 28, 2022 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Trass3r/3c77d9d4c780eb8c3a6998b49c9f0cd4 to your computer and use it in GitHub Desktop.
Save Trass3r/3c77d9d4c780eb8c3a6998b49c9f0cd4 to your computer and use it in GitHub Desktop.
static void foo() asm("myfoo") __attribute__((section("mysect")));
static void foo() {}
static void bar() {}
const void* data[] = {
(void*)&foo,
(void*)&bar
};
struct Data {
void* mine;
unsigned int theirs;
};
#include <utility>
template <typename T>
static auto h(T& t)
{
return &t;
}
struct S1 {
void foo();
[[gnu::section("mapping"), gnu::used]]
static const inline Data dummy1 = {(void*)&S1::foo, 0x401000};
};
#define OW(address, method) \
_Pragma("GCC diagnostic ignored \"-Wpmf-conversions\"") \
[[gnu::section("mapping"), gnu::used]] \
static const Data dummy21 = {(void*)&method, 0x ## address}
OW(401000, S1::foo);
void S1::foo()
{
}
[[gnu::section("mydatarray")]]
int a1 = 1;
[[gnu::section("mydatarray")]]
int a2 = 2;
extern int __start_mydatarray;
extern int __stop_mydatarray;
#include <cstdio>
int main()
{
/*
printf("%p, %p\n", &__start_mydatarray, &__stop_mydatarray);
for (auto start = &__start_mydatarray, end = &__stop_mydatarray;
start < end; ++start)
{
printf("%x\n", *start);
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment