0vercl0k / rp

rp++ is a fast C++ ROP gadget finder for PE/ELF/Mach-O x86/x64/ARM/ARM64 binaries.
MIT License
1.75k stars 250 forks source link

Support build on arm64 hosts (Apple M1) #44

Closed HexRabbit closed 2 years ago

HexRabbit commented 2 years ago
0vercl0k commented 2 years ago

Awesome! Do you happen to know the various different possible value for ${CMAKE_HOST_SYSTEM_PROCESSOR} by any chance? Cheers

HexRabbit commented 2 years ago

Cmake's docs says that it use uname -m on GNU, Linux, Cygwin, Android, OpenBSD (arch is an alias) and macOS to get machine architecture.

Inside uname it's using glibc uname() wrapper which further invokes olduname or uname or newuname syscall on linux to get architecture, no matter which one glibc choose, user will get machine architecture from utsname()->machine which inherent from parent namespace.

In init_uts_ns, the machine field is initialized by UTS_MACHINE, it's defined in Makefile and equals to $ARCH, so the value could be any folder name under the arch/ of linux source code, however, some arch/<ARCH>/Makefile may overwrite the UTS_MACHINE value, and there's also COMPAT_UTS_MACHINE which overwrite the machine field before uname syscall returns.

So here's the list: (even though I cannot assure whether I'm right or not..lol)

HexRabbit commented 2 years ago

I'm curious is there any dependency that forces you to limit the host architecture?

0vercl0k commented 2 years ago

Awesome! I don't think so at least for little endian architectures. I think this looks good, thank you for sending this out 🙏🏽

HexRabbit commented 2 years ago

@0vercl0k if we check the endianness first, maybe we could take this out? https://github.com/0vercl0k/rp/blob/7a2ffb789c0bf8803b31840304bc66768f56e6cf/src/rp/platform.h#L11

0vercl0k commented 2 years ago

I think I'm more comfortable failing the build if this is an environment that I haven't tried / hasn't been tried. Is there a relevant architecture / platform that is big that you think I am missing?

Cheers

On Tue, May 10, 2022 at 8:34 AM HexRabbit @.***> wrote:

@0vercl0k https://github.com/0vercl0k if we check the endianness first, maybe we could take this out?

https://github.com/0vercl0k/rp/blob/7a2ffb789c0bf8803b31840304bc66768f56e6cf/src/rp/platform.h#L11

— Reply to this email directly, view it on GitHub https://github.com/0vercl0k/rp/pull/44#issuecomment-1122552856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALIOROVA7XGAKR67W5HAJDVJJ6ZVANCNFSM5VKBOUUQ . You are receiving this because you were mentioned.Message ID: @.***>

HexRabbit commented 2 years ago

Yeah, you are right, without testing it could lead to bugs.