Skip to content

Commit

Permalink
Fix DLL export forwarding
Browse files Browse the repository at this point in the history
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 9675da2,
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
  • Loading branch information
ssbssa committed Dec 4, 2023
1 parent 18e87c1 commit 3d864ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gdb/coff-pe-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 it 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 ();

Expand Down

0 comments on commit 3d864ed

Please sign in to comment.