// When the kernel starts the dynamic linker, it passes a pointer to a block // of memory containing argc, the argv array, the environment variable array, // and the array of ELF aux vectors. This class breaks that block up into its // constituents for easy access. class KernelArgumentBlock { public:
__attribute__((no_sanitize("hwaddress"))) explicit KernelArgumentBlock(void* raw_args) {
uintptr_t* args = reinterpret_cast<uintptr_t*>(raw_args);
argc = static_cast<int>(*args);
argv = reinterpret_cast<char**>(args + 1);
envp = argv + argc + 1;
// Skip over all environment variable definitions to find the aux vector. // The end of the environment block is marked by a NULL pointer. char** p = envp; while (*p != nullptr) {
++p;
}
++p; // Skip the NULL itself.
auxv = reinterpret_cast<ElfW(auxv_t)*>(p);
}
// Similar to ::getauxval but doesn't require the libc global variables to be set up, // so it's safe to call this really early on.
__attribute__((no_sanitize("hwaddress"))) unsignedlong getauxval(unsignedlong type) { for (ElfW(auxv_t)* v = auxv; v->a_type != AT_NULL; ++v) { if (v->a_type == type) { return v->a_un.a_val;
}
} return0;
}
int argc; char** argv; char** envp;
ElfW(auxv_t)* auxv;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.