Fix #1864: Find main() of Fedora 35 x86_64 /bin/ls (#1880)

This commit is contained in:
Khairul Azhar Kasmiran 2021-10-24 01:16:58 +08:00 committed by Anton Kochkov
parent 9a1c402a1c
commit d99205528a
2 changed files with 13 additions and 1 deletions

View file

@ -308,6 +308,10 @@ static ut64 get_main_offset_linux_64_pie(ELFOBJ *bin, ut64 entry, ut8 *buf) {
if (buf[0] == 0xf3 && buf[1] == 0x0f && buf[2] == 0x1e && buf[3] == 0xfa) {
// Change begin offset if binary starts with 'endbr64'
bo = 33;
// double xor for init and fini
if (!memcmp(buf + 19, "\x45\x31\xc0\x31\xc9", 5)) {
bo = 24;
}
}
if (buf[bo] == 0x48) {
ut8 ch = buf[bo + 1];
@ -1873,7 +1877,7 @@ ut64 Elf_(rz_bin_elf_get_init_offset)(RZ_NONNULL ELFOBJ *bin) {
ut64 Elf_(rz_bin_elf_get_main_offset)(RZ_NONNULL ELFOBJ *bin) {
rz_return_val_if_fail(bin, UT64_MAX);
ut8 buf[256];
ut8 buf[256] = { 0 };
ut64 entry = Elf_(rz_bin_elf_get_entry_offset)(bin);
ut64 main_addr;

View file

@ -158,3 +158,11 @@ vaddr paddr
EOF
RUN
NAME=main fedora 35 x86_64 ls (#1864)
FILE=bins/elf/analysis/fedora_35_x86_64bit_ls
CMDS=?v main
EXPECT=<<EOF
0x4d80
EOF
RUN