[Bug binutils/29038] New: Debug info for function in Windows PE binary on wrong instruction

2022-04-07 Thread charlespigott at googlemail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29038

Bug ID: 29038
   Summary: Debug info for function in Windows PE binary on wrong
instruction
   Product: binutils
   Version: 2.39 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: charlespigott at googlemail dot com
  Target Milestone: ---

Compiling the following code:

```
void leaf1 (void) {  }
int main (void)
{
return 0;
}
```


with gcc (8.3.0) on Windows (MinGW) with debug symbols (`gcc contexts.c -g -o
roca.exe`) results in the following output from `objdump -dl roca.exe` :

```
C:\Users\cpigott\dev/contexts/contexts.c:1
  40154f:   90  nop

00401550 :
  401550:   55  push   %rbp
  401551:   48 89 e5mov%rsp,%rbp
  401554:   90  nop
  401555:   5d  pop%rbp
  401556:   c3  retq
```

with the debug info being attached to the instruction before the start of the
function, rather than the expected:

```
00401550 :
C:\Users\cpigott\dev/contexts/contexts.c:1
  401550:   55  push   %rbp
  401551:   48 89 e5mov%rsp,%rbp
  401554:   90  nop
  401555:   5d  pop%rbp
  401556:   c3  retq
```

Some git bisecting suggests this to be the first bad commit:

commit e643cb45bf85fa5c8c49a89ff177de246af4212e (HEAD, refs/bisect/bad)
Author: Nick Clifton 
Date:   Wed Mar 29 12:27:44 2017 +0100

Improve the speed of scanning PE binaries for line number information.

PR binutils/18025
* coff-bfd.h (struct coff_section_data): Add new fields:
saved_bias and bias.
* coffgen.c (coff_find_nearest_line_with_names): Cache the bias
computed for PE binaries.
* dwarf2.c (scan_unit_for_symbols): Only warn once about each
missing abbrev.


Which looks suitably suspicious.

Only the first function in each file (including C runtime) is affected, all
subsequent functions are fine.

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


[Bug binutils/29038] Debug info for function in Windows PE binary on wrong instruction

2022-04-08 Thread charlespigott at googlemail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29038

--- Comment #2 from CP  ---
Created attachment 14054
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14054&action=edit
roca.exe

Attached as requested

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


[Bug binutils/29038] Debug info for function in Windows PE binary on wrong instruction

2022-04-08 Thread charlespigott at googlemail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29038

--- Comment #5 from CP  ---
Wonderful! Confirmed fixed, thanks very much.

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