bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/25029] Invalid PE file caused by discarded .rdata section


From: address@hidden
Subject: [Bug ld/25029] Invalid PE file caused by discarded .rdata section
Date: Wed, 13 Nov 2019 08:54:09 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=25029

--- Comment #11 from Florin Saftoiu <address@hidden> ---
Hi Nick,

Sorry it took so long, I finally got some time, so I compiled the msys2
binutils-2.32 package from source and ran it in GDB. Here's my GDB session :

$ gdb --args
/c/work/projects/soft-to-you/osdev/gcc/src/MINGW-packages/mingw-w64-binutils/pkg/mingw-w64-x86_64-binutils/mingw64/bin/ld.exe
-o test_64_broken.exe -L/mingw64/x86_64-w64-mingw32/lib test_64_broken.o
-lkernel32 -luser32
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from
C:/work/projects/soft-to-you/osdev/gcc/src/MINGW-packages/mingw-w64-binutils/pkg/mingw-w64-x86_64-binutils/mingw64/bin/ld.exe...
(gdb) dir
../gcc/src/MINGW-packages/mingw-w64-binutils/src/build-x86_64-w64-mingw32/bfd
Source directories searched:
C:\work\projects\soft-to-you\osdev\src/../gcc/src/MINGW-packages/mingw-w64-binutils/src/build-x86_64-w64-mingw32/bfd;$cdir;$cwd
(gdb) b _bfd_pex64i_swap_aouthdr_out
Breakpoint 1 at 0x471b39: file pex64igen.c, line 631.
(gdb) run
Starting program:
C:\work\projects\soft-to-you\osdev\gcc\src\MINGW-packages\mingw-w64-binutils\pkg\mingw-w64-x86_64-binutils\mingw64\bin\ld.exe
-o test_64_broken.exe -LC:/msys64/mingw64/x86_64-w64-mingw32/lib
test_64_broken.o -lkernel32 -luser32
[New Thread 37688.0x8ab4]
[New Thread 37688.0x74e0]
[New Thread 37688.0xb8a0]

Thread 1 hit Breakpoint 1, _bfd_pex64i_swap_aouthdr_out (abfd=0x5ade490,
    in=0x1c8f130, out=0x5b50920) at pex64igen.c:631
warning: Source file is more recent than executable.
631       struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
(gdb) b 739
Breakpoint 2 at 0x471e73: file pex64igen.c, line 739.
(gdb) c
Continuing.

Thread 1 hit Breakpoint 2, _bfd_pex64i_swap_aouthdr_out (abfd=0x5ade490,
    in=0x1c8f130, out=0x5b50920) at pex64igen.c:739
739               isize = (sec->vma - extra->ImageBase
(gdb) print sec->name
$1 = 0x432bfa0 ".text"
(gdb) print isize
$2 = 0
(gdb) c
Continuing.

Thread 1 hit Breakpoint 2, _bfd_pex64i_swap_aouthdr_out (abfd=0x5ade490,
    in=0x1c8f130, out=0x5b50920) at pex64igen.c:739
739               isize = (sec->vma - extra->ImageBase
(gdb) print sec->name
$3 = 0x5ad34b0 ".data"
(gdb) print isize
$4 = 8192
(gdb) c
Continuing.

Thread 1 hit Breakpoint 2, _bfd_pex64i_swap_aouthdr_out (abfd=0x5ade490,
    in=0x1c8f130, out=0x5b50920) at pex64igen.c:739
739               isize = (sec->vma - extra->ImageBase
(gdb) print sec->name
$5 = 0x5ad41e0 ".idata"
(gdb) print isize
$6 = 12288
(gdb) c
Continuing.

Thread 1 hit Breakpoint 2, _bfd_pex64i_swap_aouthdr_out (abfd=0x5ade490,
    in=0x1c8f130, out=0x5b50920) at pex64igen.c:739
739               isize = (sec->vma - extra->ImageBase
(gdb) print sec->name
$7 = 0x5ad3dd0 ".rdata"
(gdb) print isize
$8 = 16384
(gdb) print sec->vma
$9 = 4206592
(gdb) print extra->ImageBase
$10 = 4194304
(gdb) next
740                        + SA (FA (pei_section_data (abfd,
sec)->virt_size)));
(gdb) next
739               isize = (sec->vma - extra->ImageBase
(gdb) next
715         for (sec = abfd->sections; sec; sec = sec->next)
(gdb) print isize
$11 = 12288
(gdb) c
Continuing.
[Thread 37688.0xb8a0 exited with code 0]
[Thread 37688.0x74e0 exited with code 0]
[Thread 37688.0x8ab4 exited with code 0]
[Inferior 1 (process 37688) exited normally]

As far as I can tell the problem comes from the .rdata section which appears in
the image before the .idata section but is here considered last.

Hope this helps.

Best regards,
Florin

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]