mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-06 19:32:15 +02:00
Compare commits
3 Commits
e8f4096b15
...
915add4f75
Author | SHA1 | Date | |
---|---|---|---|
|
915add4f75 | ||
|
8cff58d5af | ||
|
03461c9304 |
8
nx/external/bsd/include/netinet/in.h
vendored
8
nx/external/bsd/include/netinet/in.h
vendored
@ -684,6 +684,14 @@ struct sockaddr_in6 {
|
|||||||
uint32_t sin6_scope_id; /* Scope ID */
|
uint32_t sin6_scope_id; /* Scope ID */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
|
||||||
|
*/
|
||||||
|
struct ipv6_mreq {
|
||||||
|
struct in6_addr ipv6mr_multiaddr;
|
||||||
|
unsigned int ipv6mr_interface;
|
||||||
|
};
|
||||||
|
|
||||||
extern const struct in6_addr in6addr_any;
|
extern const struct in6_addr in6addr_any;
|
||||||
extern const struct in6_addr in6addr_loopback;
|
extern const struct in6_addr in6addr_loopback;
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ static void _dynProcessRela(uintptr_t base, const Elf64_Rela* rela, size_t relas
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case R_AARCH64_NONE: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case R_AARCH64_RELATIVE: {
|
case R_AARCH64_RELATIVE: {
|
||||||
u64* ptr = (u64*)(base + rela->r_offset);
|
u64* ptr = (u64*)(base + rela->r_offset);
|
||||||
*ptr = base + rela->r_addend;
|
*ptr = base + rela->r_addend;
|
||||||
@ -45,6 +49,25 @@ static void _dynProcessRela(uintptr_t base, const Elf64_Rela* rela, size_t relas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _dynProcessRelr(uintptr_t base, const Elf64_Relr* relr, size_t relrsz)
|
||||||
|
{
|
||||||
|
u64* ptr = NULL;
|
||||||
|
for (; relrsz--; relr++) {
|
||||||
|
if ((*relr & 1) == 0) {
|
||||||
|
ptr = (u64*)(base + *relr);
|
||||||
|
*ptr++ += base;
|
||||||
|
} else {
|
||||||
|
u64 bitmap = *relr >> 1;
|
||||||
|
while (bitmap) {
|
||||||
|
unsigned id = __builtin_ffsl(bitmap)-1;
|
||||||
|
bitmap &= ~(1UL << id);
|
||||||
|
ptr[id] += base;
|
||||||
|
}
|
||||||
|
ptr += 63;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void __nx_dynamic(uintptr_t base, const Mod0Header* mod0)
|
void __nx_dynamic(uintptr_t base, const Mod0Header* mod0)
|
||||||
{
|
{
|
||||||
// Return early if MOD0 header has been invalidated
|
// Return early if MOD0 header has been invalidated
|
||||||
@ -65,6 +88,8 @@ void __nx_dynamic(uintptr_t base, const Mod0Header* mod0)
|
|||||||
// Extract relevant information from the ELF dynamic section
|
// Extract relevant information from the ELF dynamic section
|
||||||
const Elf64_Rela* rela = NULL;
|
const Elf64_Rela* rela = NULL;
|
||||||
size_t relasz = 0;
|
size_t relasz = 0;
|
||||||
|
const Elf64_Relr* relr = NULL;
|
||||||
|
size_t relrsz = 0;
|
||||||
for (; dyn->d_tag != DT_NULL; dyn++) {
|
for (; dyn->d_tag != DT_NULL; dyn++) {
|
||||||
switch (dyn->d_tag) {
|
switch (dyn->d_tag) {
|
||||||
case DT_RELA:
|
case DT_RELA:
|
||||||
@ -74,6 +99,14 @@ void __nx_dynamic(uintptr_t base, const Mod0Header* mod0)
|
|||||||
case DT_RELASZ:
|
case DT_RELASZ:
|
||||||
relasz = dyn->d_un.d_val / sizeof(Elf64_Rela);
|
relasz = dyn->d_un.d_val / sizeof(Elf64_Rela);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DT_RELR:
|
||||||
|
relr = (const Elf64_Relr*)(base + dyn->d_un.d_ptr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DT_RELRSZ:
|
||||||
|
relrsz = dyn->d_un.d_val / sizeof(Elf64_Relr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +115,11 @@ void __nx_dynamic(uintptr_t base, const Mod0Header* mod0)
|
|||||||
_dynProcessRela(base, rela, relasz);
|
_dynProcessRela(base, rela, relasz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply RELR relocations if present
|
||||||
|
if (relr && relrsz) {
|
||||||
|
_dynProcessRelr(base, relr, relrsz);
|
||||||
|
}
|
||||||
|
|
||||||
// Return early if LNY0/LNY1 extensions are not present
|
// Return early if LNY0/LNY1 extensions are not present
|
||||||
if (mod0->magic_lny0 != 0x30594e4c || mod0->magic_lny1 != 0x31594e4c) { // LNY0, LNY1
|
if (mod0->magic_lny0 != 0x30594e4c || mod0->magic_lny1 != 0x31594e4c) { // LNY0, LNY1
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
*link:
|
*link:
|
||||||
+ -T %:getenv(DEVKITPRO /libnx/switch.ld) -pie --no-dynamic-linker --spare-dynamic-tags=0 --gc-sections -z text -z now -z nodynamic-undefined-weak --build-id=sha1 --nx-module-name
|
+ -T %:getenv(DEVKITPRO /libnx/switch.ld) -pie --no-dynamic-linker --spare-dynamic-tags=0 --gc-sections -z text -z now -z nodynamic-undefined-weak -z pack-relative-relocs --build-id=sha1 --nx-module-name
|
||||||
|
|
||||||
*startfile:
|
*startfile:
|
||||||
crti%O%s crtbegin%O%s --require-defined=main
|
crti%O%s crtbegin%O%s --require-defined=main
|
||||||
|
Loading…
Reference in New Issue
Block a user