switchbrew / libnx

Library for Switch Homebrew

Home Page:https://switchbrew.github.io/libnx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MOD0 section missing an offset

khang06 opened this issue · comments

right now the mod0 section looks like this in switch_crt0.s

.global __nx_mod0
__nx_mod0:
    .ascii "MOD0"
    .word  _DYNAMIC             - __nx_mod0
    .word  __bss_start__        - __nx_mod0
    .word  __bss_end__          - __nx_mod0
    .word  __eh_frame_hdr_start - __nx_mod0
    .word  __eh_frame_hdr_end   - __nx_mod0
    .word  0 // "offset to runtime-generated module object" (??)

since the last part (offset to runtime-generated module object) is missing, official rtld crashes when trying to load a homebrew nso. switchbrew says it's "typically equal to .bss base", so i just copied the bss start offset value into it and the game fine booted with a homebrew nso loaded. of course, this probably causes some issues (i haven't tried actually executing code in the nso yet), but it might be helpful for figuring out what this offset is actually for. it's also worth noting that i noticed that the bss start offset and the runtime-generated module object offset have the same value in official nsos, too

commented

Why are you using official rtld in the first place? Are you doing raw NSO replacement with atmosphere? If so, you can add a dummy rtld.stub file to disable rtld.

We will not support official rtld at all in libnx.

right now i'm trying to load a homebrew nso as a sdk/subsdkX in an official game to hook stuff and run my own compiled code. it's really hacky and it's probably the only use for needing rtld for homebrew (even then there are probably better alternatives), so i can understand not wanting to support it

commented

If your goal is modifying game memory at runtime/other similar use cases (for e.g. cheating purposes), let me inform you that a cleaner solution is being worked on in AMS.