From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix DLL export forwarding
Date: Mon, 4 Dec 2023 17:50:29 +0100 [thread overview]
Message-ID: <20231204165029.408-1-ssbssa@yahoo.de> (raw)
In-Reply-To: <20231204165029.408-1-ssbssa.ref@yahoo.de>
I noticed it when I was trying to set a breakpoint at ExitProcess:
```
(gdb) b ExitProcess
Breakpoint 1 at 0x14001fdd0
(gdb) r
Starting program: C:\qiewer\heob\heob64.exe
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x3dbf4120
Cannot insert breakpoint 1.
Cannot access memory at address 0x77644120
```
The problem doesn't exist in gdb 13.2, and the difference can easily be
seen when printing ExitProcess.
gdb 14.1:
```
(gdb) p ExitProcess
$1 = {<text variable, no debug info>} 0x77644120 <UserHandleGrantAccess+36128>
```
gdb 13.2:
```
(gdb) p ExitProcess
$1 = {<text variable, no debug info>} 0x77734120 <ntdll!RtlExitUserProcess>
```
The new behavior started with 9675da25357c7a3f472731ddc6eb3becc65b469a,
where VMA was then calculated relative to FORWARD_DLL_NAME, while it was
relative to DLL_NAME before.
Fixed by calculating VMA relative to DLL_NAME again.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31112
---
gdb/coff-pe-read.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 56137ac4dd0..c9d6d86a085 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -210,7 +210,10 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
" \"%s\" in dll \"%s\", pointing to \"%s\"\n"),
sym_name, dll_name, forward_qualified_name.c_str ());
- unrelocated_addr vma = msymbol.minsym->unrelocated_address ();
+ /* Calculate VMA as if if where relative to DLL_NAME/OBJFILE, even though
+ it actually points inside another dll (FORWARD_DLL_NAME). */
+ unrelocated_addr vma = unrelocated_addr(msymbol.value_address ()
+ - objfile->text_section_offset ());
msymtype = msymbol.minsym->type ();
section = msymbol.minsym->section_index ();
--
2.35.1
next parent reply other threads:[~2023-12-04 16:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231204165029.408-1-ssbssa.ref@yahoo.de>
2023-12-04 16:50 ` Hannes Domani [this message]
2023-12-04 17:34 ` Lancelot SIX
2023-12-06 19:31 ` Tom Tromey
2023-12-06 20:16 ` Hannes Domani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231204165029.408-1-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox