[go: nahoru, domu]

Bug 31112 - DLL export forwarding is broken
Summary: DLL export forwarding is broken
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: 14.1
: P2 normal
Target Milestone: 14.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-04 16:33 UTC by Hannes Domani
Modified: 2023-12-06 20:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hannes Domani 2023-12-04 16:33:26 UTC
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 difference can easily be found 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>
```

I tracked the new behavior to this commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=9675da25357c7a3f472731ddc6eb3becc65b469a

Now the calculated VMA that's used in record_with_info() is an address relative to forward_dll_name, when before it was relative to dll_name.
Comment 1 Sourceware Commits 2023-12-06 19:57:52 UTC
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2574cd903dd84e7081506e24c2e232ecda11a736

commit 2574cd903dd84e7081506e24c2e232ecda11a736
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Wed Dec 6 20:52:06 2023 +0100

    Fix DLL export forwarding
    
    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
    Approved-By: Tom Tromey <tom@tromey.com>
Comment 2 Sourceware Commits 2023-12-06 20:14:17 UTC
The gdb-14-branch branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=43a608adb04251be8999304cf724f55b2d840ac3

commit 43a608adb04251be8999304cf724f55b2d840ac3
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Wed Dec 6 20:52:06 2023 +0100

    Fix DLL export forwarding
    
    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
    Approved-By: Tom Tromey <tom@tromey.com>
    
    (cherry picked from commit 2574cd903dd84e7081506e24c2e232ecda11a736)
Comment 3 Hannes Domani 2023-12-06 20:17:24 UTC
Fixed.