size_t gnu_nbucket_
=
0
;
/
/
skip symndx
uint32_t gnu_maskwords_
=
0
;
uint32_t gnu_shift2_
=
0
;
ElfW(Addr)
*
gnu_bloom_filter_
=
nullptr;
uint32_t
*
gnu_bucket_
=
nullptr;
uint32_t
*
gnu_chain_
=
nullptr;
int
phof
=
0
;
Elf64_Ehdr header;
memcpy(&header, startr, sizeof(Elf64_Ehdr));
uint64 rel
=
0
;
size_t size
=
0
;
long
*
plt
=
nullptr;
char
*
strtab_
=
nullptr;
Elf64_Sym
*
symtab_
=
nullptr;
Elf64_Phdr cc;
memcpy(&cc, ((char
*
) (startr)
+
header.e_phoff), sizeof(Elf64_Phdr));
for
(
int
y
=
0
; y < header.e_phnum; y
+
+
) {
memcpy(&cc, (char
*
) (startr)
+
header.e_phoff
+
sizeof(Elf64_Phdr)
*
y,
sizeof(Elf64_Phdr));
if
(cc.p_type
=
=
6
) {
phof
=
cc.p_paddr
-
cc.p_offset;
/
/
改用程序头的偏移获得首段偏移用之前的方法也行
}
}
for
(
int
y
=
0
; y < header.e_phnum; y
+
+
) {
memcpy(&cc, (char
*
) (startr)
+
header.e_phoff
+
sizeof(Elf64_Phdr)
*
y,
sizeof(Elf64_Phdr));
if
(cc.p_type
=
=
2
) {
Elf64_Dyn dd;
for
(y
=
0
; y
=
=
0
|| dd.d_tag !
=
0
; y
+
+
) {
memcpy(&dd, (char
*
) (startr)
+
cc.p_offset
+
y
*
sizeof(Elf64_Dyn)
+
0x1000
,
sizeof(Elf64_Dyn));
if
(dd.d_tag
=
=
0x6ffffef5
) {
/
/
0x6ffffef5
为导出表项
gnu_nbucket_
=
reinterpret_cast<uint32_t
*
>((char
*
) startr
+
dd.d_un.d_ptr
-
phof)[
0
];
/
/
skip symndx
gnu_maskwords_
=
reinterpret_cast<uint32_t
*
>((char
*
) startr
+
dd.d_un.d_ptr
-
phof)[
2
];
gnu_shift2_
=
reinterpret_cast<uint32_t
*
>((char
*
) startr
+
dd.d_un.d_ptr
-
phof)[
3
];
gnu_bloom_filter_
=
reinterpret_cast<ElfW(Addr)
*
>((char
*
) startr
+
dd.d_un.d_ptr
+
16
-
phof);
gnu_bucket_
=
reinterpret_cast<uint32_t
*
>(gnu_bloom_filter_
+
gnu_maskwords_);
/
/
amend chain
for
symndx
=
header[
1
]
gnu_chain_
=
reinterpret_cast<uint32_t
*
>( gnu_bucket_
+
gnu_nbucket_
-
reinterpret_cast<uint32_t
*
>(
(char
*
) startr
+
dd.d_un.d_ptr
-
phof)[
1
]);
}
if
(dd.d_tag
=
=
5
) {
strtab_
=
reinterpret_cast< char
*
>((char
*
) startr
+
dd.d_un.d_ptr
-
phof);
}
if
(dd.d_tag
=
=
6
) {
symtab_
=
reinterpret_cast<Elf64_Sym
*
>((
(char
*
) startr
+
dd.d_un.d_ptr
-
phof));
}
}
}
}