Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
8aab67d2
Commit
8aab67d2
authored
Jul 31, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preloader: Properly use the ELF hash table when looking up a symbol.
parent
d4da27ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
preloader.c
loader/preloader.c
+30
-7
No files found.
loader/preloader.c
View file @
8aab67d2
...
...
@@ -745,6 +745,19 @@ static void map_so_lib( const char *name, struct wld_link_map *l)
}
static
unsigned
int
elf_hash
(
const
char
*
name
)
{
unsigned
int
hi
,
hash
=
0
;
while
(
*
name
)
{
hash
=
(
hash
<<
4
)
+
(
unsigned
char
)
*
name
++
;
hi
=
hash
&
0xf0000000
;
hash
^=
hi
;
hash
^=
hi
>>
24
;
}
return
hash
;
}
/*
* Find a symbol in the symbol table of the executable loaded
*/
...
...
@@ -753,8 +766,8 @@ static void *find_symbol( const ElfW(Phdr) *phdr, int num, const char *var )
const
ElfW
(
Dyn
)
*
dyn
=
NULL
;
const
ElfW
(
Phdr
)
*
ph
;
const
ElfW
(
Sym
)
*
symtab
=
NULL
;
const
Elf_Symndx
*
hashtab
=
NULL
;
const
char
*
strings
=
NULL
;
uint32_t
i
,
symtabend
=
0
;
/* check the values */
#ifdef DUMP_SYMS
...
...
@@ -785,7 +798,7 @@ static void *find_symbol( const ElfW(Phdr) *phdr, int num, const char *var )
if
(
dyn
->
d_tag
==
DT_SYMTAB
)
symtab
=
(
const
ElfW
(
Sym
)
*
)
dyn
->
d_un
.
d_ptr
;
if
(
dyn
->
d_tag
==
DT_HASH
)
symtabend
=
*
((
const
uint32_t
*
)
dyn
->
d_un
.
d_ptr
+
1
)
;
hashtab
=
(
const
Elf_Symndx
*
)
dyn
->
d_un
.
d_ptr
;
#ifdef DUMP_SYMS
wld_printf
(
"%x %x
\n
"
,
dyn
->
d_tag
,
dyn
->
d_un
.
d_ptr
);
#endif
...
...
@@ -794,15 +807,25 @@ static void *find_symbol( const ElfW(Phdr) *phdr, int num, const char *var )
if
(
(
!
symtab
)
||
(
!
strings
)
)
return
NULL
;
for
(
i
=
0
;
i
<
symtabend
;
i
++
)
if
(
hashtab
)
{
if
(
(
ELF32_ST_BIND
(
symtab
[
i
].
st_info
)
==
STT_OBJECT
)
&&
(
0
==
wld_strcmp
(
strings
+
symtab
[
i
].
st_name
,
var
)
)
)
Elf_Symndx
nbuckets
=
hashtab
[
0
];
unsigned
int
hash
=
elf_hash
(
var
)
%
nbuckets
;
const
Elf_Symndx
*
buckets
=
hashtab
+
2
;
const
Elf_Symndx
*
chains
=
buckets
+
nbuckets
;
Elf_Symndx
idx
=
buckets
[
hash
];
while
(
idx
!=
STN_UNDEF
)
{
if
(
(
ELF32_ST_BIND
(
symtab
[
idx
].
st_info
)
==
STT_OBJECT
)
&&
!
wld_strcmp
(
strings
+
symtab
[
idx
].
st_name
,
var
))
{
#ifdef DUMP_SYMS
wld_printf
(
"Found %s -> %x
\n
"
,
strings
+
symtab
[
i
].
st_name
,
symtab
[
i
].
st_value
);
wld_printf
(
"Found %s -> %x
\n
"
,
strings
+
symtab
[
idx
].
st_name
,
symtab
[
idx
].
st_value
);
#endif
return
(
void
*
)
symtab
[
i
].
st_value
;
return
(
void
*
)
symtab
[
idx
].
st_value
;
}
idx
=
chains
[
idx
];
}
}
return
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment