Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
04c7c203
Commit
04c7c203
authored
Nov 24, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Nov 27, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Simplify code with function to get section size.
parent
3cd3ca68
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
22 deletions
+32
-22
dbghelp_private.h
dlls/dbghelp/dbghelp_private.h
+1
-0
dwarf.c
dlls/dbghelp/dwarf.c
+1
-3
elf_module.c
dlls/dbghelp/elf_module.c
+30
-19
No files found.
dlls/dbghelp/dbghelp_private.h
View file @
04c7c203
...
...
@@ -367,6 +367,7 @@ extern BOOL pcs_callback(const struct process* pcs, ULONG action, void*
extern
void
*
fetch_buffer
(
struct
process
*
pcs
,
unsigned
size
);
/* elf_module.c */
#define ELF_NO_MAP ((const void*)0xffffffff)
typedef
BOOL
(
*
elf_enum_modules_cb
)(
const
char
*
,
unsigned
long
addr
,
void
*
user
);
extern
BOOL
elf_enum_modules
(
HANDLE
hProc
,
elf_enum_modules_cb
,
void
*
);
extern
BOOL
elf_fetch_file_info
(
const
char
*
name
,
DWORD
*
base
,
DWORD
*
size
,
DWORD
*
checksum
);
...
...
dlls/dbghelp/dwarf.c
View file @
04c7c203
...
...
@@ -150,8 +150,6 @@ typedef struct dwarf2_debug_info_s
struct
vector
children
;
}
dwarf2_debug_info_t
;
#define NO_MAP ((const void*)0xffffffff)
typedef
struct
dwarf2_section_s
{
const
unsigned
char
*
address
;
...
...
@@ -1597,7 +1595,7 @@ static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t* sections,
const
char
**
p
;
/* section with line numbers stripped */
if
(
sections
[
section_line
].
address
==
NO_MAP
)
if
(
sections
[
section_line
].
address
==
ELF_
NO_MAP
)
return
FALSE
;
traverse
.
data
=
sections
[
section_line
].
address
+
offset
;
...
...
dlls/dbghelp/elf_module.c
View file @
04c7c203
...
...
@@ -98,7 +98,6 @@ struct elf_info
const
char
*
module_name
;
/* OUT found module name (if ELF_INFO_NAME is set) */
};
#define NO_MAP ((const void*)0xffffffff)
/* structure holding information while handling an ELF image
* allows one by one section mapping for memory savings
*/
...
...
@@ -145,13 +144,13 @@ static const char* elf_map_section(struct elf_file_map* fmap, int sidx)
if
(
sidx
<
0
||
sidx
>=
fmap
->
elfhdr
.
e_shnum
||
fmap
->
sect
[
sidx
].
shdr
.
sh_type
==
SHT_NOBITS
)
return
NO_MAP
;
return
ELF_
NO_MAP
;
/* align required information on page size (we assume pagesize is a power of 2) */
ofst
=
fmap
->
sect
[
sidx
].
shdr
.
sh_offset
&
~
(
pgsz
-
1
);
size
=
(
fmap
->
sect
[
sidx
].
shdr
.
sh_offset
+
fmap
->
sect
[
sidx
].
shdr
.
sh_size
+
pgsz
-
1
)
&
~
(
pgsz
-
1
);
fmap
->
sect
[
sidx
].
mapped
=
mmap
(
NULL
,
size
,
PROT_READ
,
MAP_PRIVATE
,
fmap
->
fd
,
ofst
);
if
(
fmap
->
sect
[
sidx
].
mapped
==
NO_MAP
)
return
NO_MAP
;
if
(
fmap
->
sect
[
sidx
].
mapped
==
ELF_NO_MAP
)
return
ELF_
NO_MAP
;
return
fmap
->
sect
[
sidx
].
mapped
+
(
fmap
->
sect
[
sidx
].
shdr
.
sh_offset
&
(
pgsz
-
1
));
}
...
...
@@ -162,14 +161,26 @@ static const char* elf_map_section(struct elf_file_map* fmap, int sidx)
*/
static
void
elf_unmap_section
(
struct
elf_file_map
*
fmap
,
int
sidx
)
{
if
(
sidx
>=
0
&&
sidx
<
fmap
->
elfhdr
.
e_shnum
&&
fmap
->
sect
[
sidx
].
mapped
!=
NO_MAP
)
if
(
sidx
>=
0
&&
sidx
<
fmap
->
elfhdr
.
e_shnum
&&
fmap
->
sect
[
sidx
].
mapped
!=
ELF_
NO_MAP
)
{
munmap
((
char
*
)
fmap
->
sect
[
sidx
].
mapped
,
fmap
->
sect
[
sidx
].
shdr
.
sh_size
);
fmap
->
sect
[
sidx
].
mapped
=
NO_MAP
;
fmap
->
sect
[
sidx
].
mapped
=
ELF_
NO_MAP
;
}
}
/******************************************************************
* elf_get_map_size
*
* Get the size of an ELF section
*/
static
inline
unsigned
elf_get_map_size
(
struct
elf_file_map
*
fmap
,
int
sidx
)
{
if
(
sidx
<
0
||
sidx
>=
fmap
->
elfhdr
.
e_shnum
)
return
0
;
return
fmap
->
sect
[
sidx
].
shdr
.
sh_size
;
}
/******************************************************************
* elf_map_file
*
* Maps an ELF file into memory (and checks it's a real ELF file)
...
...
@@ -206,7 +217,7 @@ static BOOL elf_map_file(const char* filename, struct elf_file_map* fmap)
for
(
i
=
0
;
i
<
fmap
->
elfhdr
.
e_shnum
;
i
++
)
{
read
(
fmap
->
fd
,
&
fmap
->
sect
[
i
].
shdr
,
sizeof
(
fmap
->
sect
[
i
].
shdr
));
fmap
->
sect
[
i
].
mapped
=
NO_MAP
;
fmap
->
sect
[
i
].
mapped
=
ELF_
NO_MAP
;
}
/* grab size of module once loaded in memory */
...
...
@@ -287,9 +298,9 @@ static void elf_hash_symtab(struct module* module, struct pool* pool,
symp
=
(
const
Elf32_Sym
*
)
elf_map_section
(
fmap
,
symtab_idx
);
strp
=
elf_map_section
(
fmap
,
fmap
->
sect
[
symtab_idx
].
shdr
.
sh_link
);
if
(
symp
==
NO_MAP
||
strp
==
NO_MAP
)
return
;
if
(
symp
==
ELF_NO_MAP
||
strp
==
ELF_
NO_MAP
)
return
;
nsym
=
fmap
->
sect
[
symtab_idx
].
shdr
.
sh_size
/
sizeof
(
*
symp
);
nsym
=
elf_get_map_size
(
fmap
,
symtab_idx
)
/
sizeof
(
*
symp
);
for
(
j
=
0
;
thunks
[
j
].
symname
;
j
++
)
thunks
[
j
].
rva_start
=
thunks
[
j
].
rva_end
=
0
;
...
...
@@ -806,7 +817,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
* table.
*/
shstrtab
=
elf_map_section
(
fmap
,
fmap
->
elfhdr
.
e_shstrndx
);
if
(
shstrtab
==
NO_MAP
)
return
FALSE
;
if
(
shstrtab
==
ELF_
NO_MAP
)
return
FALSE
;
symtab_sect
=
dynsym_sect
=
stab_sect
=
stabstr_sect
=
-
1
;
debug_sect
=
debug_str_sect
=
debug_abbrev_sect
=
debug_line_sect
=
-
1
;
...
...
@@ -862,12 +873,12 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
stab
=
elf_map_section
(
fmap
,
stab_sect
);
stabstr
=
elf_map_section
(
fmap
,
stabstr_sect
);
if
(
stab
!=
NO_MAP
&&
stabstr
!=
NO_MAP
)
if
(
stab
!=
ELF_NO_MAP
&&
stabstr
!=
ELF_
NO_MAP
)
{
/* OK, now just parse all of the stabs. */
lret
=
stabs_parse
(
module
,
module
->
elf_info
->
elf_addr
,
stab
,
fmap
->
sect
[
stab_sect
].
shdr
.
sh_size
,
stabstr
,
fmap
->
sect
[
stabstr_sect
].
shdr
.
sh_size
);
stab
,
elf_get_map_size
(
fmap
,
stab_sect
)
,
stabstr
,
elf_get_map_size
(
fmap
,
stabstr_sect
)
);
if
(
lret
)
/* and fill in the missing information for stabs */
elf_finish_stabs_info
(
module
,
ht_symtab
);
...
...
@@ -894,14 +905,14 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
dw2_debug_abbrev
=
(
const
BYTE
*
)
elf_map_section
(
fmap
,
debug_abbrev_sect
);
dw2_debug_str
=
(
const
BYTE
*
)
elf_map_section
(
fmap
,
debug_str_sect
);
dw2_debug_line
=
(
const
BYTE
*
)
elf_map_section
(
fmap
,
debug_line_sect
);
if
(
dw2_debug
!=
NO_MAP
&&
NO_MAP
!=
dw2_debug_abbrev
&&
dw2_debug_str
!=
NO_MAP
)
if
(
dw2_debug
!=
ELF_NO_MAP
&&
ELF_NO_MAP
!=
dw2_debug_abbrev
&&
dw2_debug_str
!=
ELF_
NO_MAP
)
{
/* OK, now just parse dwarf2 debug infos. */
lret
=
dwarf2_parse
(
module
,
module
->
elf_info
->
elf_addr
,
thunks
,
dw2_debug
,
fmap
->
sect
[
debug_sect
].
shdr
.
sh_size
,
dw2_debug_abbrev
,
fmap
->
sect
[
debug_abbrev_sect
].
shdr
.
sh_size
,
dw2_debug_str
,
fmap
->
sect
[
debug_str_sect
].
shdr
.
sh_size
,
dw2_debug_line
,
dw2_debug_line
!=
NO_MAP
?
fmap
->
sect
[
debug_line_sect
].
shdr
.
sh_size
:
0
);
dw2_debug
,
elf_get_map_size
(
fmap
,
debug_sect
)
,
dw2_debug_abbrev
,
elf_get_map_size
(
fmap
,
debug_abbrev_sect
)
,
dw2_debug_str
,
elf_get_map_size
(
fmap
,
debug_str_sect
)
,
dw2_debug_line
,
elf_get_map_size
(
fmap
,
debug_line_sect
)
);
if
(
!
lret
)
WARN
(
"Couldn't correctly read stabs
\n
"
);
ret
=
ret
||
lret
;
...
...
@@ -923,7 +934,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
* 2/ padding on 4 byte boundary
* 3/ CRC of the linked ELF file
*/
if
(
dbg_link
!=
NO_MAP
&&
elf_map_file
(
dbg_link
,
&
fmap_link
))
if
(
dbg_link
!=
ELF_
NO_MAP
&&
elf_map_file
(
dbg_link
,
&
fmap_link
))
{
fmap_link
.
crc
=
*
(
const
DWORD
*
)(
dbg_link
+
((
DWORD_PTR
)(
strlen
(
dbg_link
)
+
4
)
&
~
3
));
fmap_link
.
with_crc
=
1
;
...
...
@@ -1066,7 +1077,7 @@ static BOOL elf_load_file(struct process* pcs, const char* filename,
if
(
elf_info
->
flags
&
ELF_INFO_DEBUG_HEADER
)
{
const
char
*
shstrtab
=
elf_map_section
(
&
fmap
,
fmap
.
elfhdr
.
e_shstrndx
);
if
(
shstrtab
==
NO_MAP
)
goto
leave
;
if
(
shstrtab
==
ELF_
NO_MAP
)
goto
leave
;
for
(
i
=
0
;
i
<
fmap
.
elfhdr
.
e_shnum
;
i
++
)
{
if
(
strcmp
(
shstrtab
+
fmap
.
sect
[
i
].
shdr
.
sh_name
,
".dynamic"
)
==
0
&&
...
...
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