Created
August 28, 2022 18:54
-
-
Save Trass3r/3c77d9d4c780eb8c3a6998b49c9f0cd4 to your computer and use it in GitHub Desktop.
This file contains 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
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() | |
{ | |
} |
This file contains 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
[[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