[Bug binutils/24321] Objcopy "--only-keep-debug" generates Bad Offset in LOAD sections for lld built binaries

2019-03-11 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24321

--- Comment #4 from Manoj Gupta  ---
Thanks,

Looks like the internal tooling had an incorrect assumption. Sorry for the
noise.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug binutils/24321] Objcopy "--only-keep-debug" generates Bad Offset in LOAD sections for lld built binaries

2019-03-11 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24321

Manoj Gupta  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #2 from Manoj Gupta  ---
Here is the problem: --only-keep-debug is supposed  to preserve the section
headers. But it is not doing so. Our tooling and public tools like Linux perf
relies on section headers in splitdebug files to match original binary.

Linking to  the documentation of --only-keep-debug in objcopy at
https://sourceware.org/binutils/docs/binutils/objcopy.html where it says that
sections headers are preserved.

"
--only-keep-debug
Strip a file, removing contents of any sections that would not be stripped by
--strip-debug and leaving the debugging sections intact. In ELF files, this
preserves all note sections in the output.

Note - the section headers of the stripped sections are preserved, including
their sizes, but the contents of the section are discarded. The section headers
are preserved so that other tools can match up the debuginfo file with the real
executable, even if that executable has been relocated to a different address
space.
"

Note: Sorry about causing the in --keep-debug". I just wanted to illustrate
that eu-strip preserves the headers correctly. eu-strip however does not
support --only-keep-debug" and has a different way of generating splitdebug
files which is via "--kep-debug" -f  option. I am NOT using
"--keep-debug" option with GNU strip when generating the splitdebug files.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug binutils/24321] Objcopy "--only-keep-debug" generates Bad Offset in LOAD sections for lld built binaries

2019-03-11 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24321

Manoj Gupta  changed:

   What|Removed |Added

 CC||ruiu at google dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug binutils/24321] New: Objcopy "--only-keep-debug" generates Bad Offset in LOAD sections for lld built binaries

2019-03-11 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24321

Bug ID: 24321
   Summary: Objcopy "--only-keep-debug" generates Bad Offset in
LOAD sections for lld built binaries
   Product: binutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: manojgupta at google dot com
  Target Milestone: ---

We discovered that objcopy creates bad Offsets in LOAD section when generating
split-debug files for lld built binaries. This is breaking tools e.g Linux Perf
and more tools that rely on the splitdebug file for symbolization.

The shared file has a tblgen binary that was built with LLD.

https://drive.google.com/file/d/1PTlbzG7nqdu_TLRlpMdKasuBcG0r0LIu/view?usp=sharing

  Type   Offset VirtAddr   PhysAddr
$ readelf -l tblgen/tblgen|grep LOAD
  LOAD   0x 0x0020 0x0020
  LOAD   0x00722000 0x00922000 0x00922000

# Generate a split-debug debug info file with objcopy
$objcopy --only-keep-debug tblgen tblgen.dbg

$ readelf -l tblgen.dbg|grep LOAD
  LOAD   0x 0x0020 0x0020
  LOAD   0x1000 0x00922000 0x00922000

The Offset field for second LOAD entry is BAD, it should have been
0x00722000.

If I use eu-strip from elfutils, the offsets are correct.

$ eu-strip --strip-debug tblgen -f tblgen.debug

$ readelf -l tblgen.debug |grep LOAD
  LOAD   0x 0x0020 0x0020
  LOAD   0x00722000 0x00922000 0x00922000

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug binutils/24321] Objcopy "--only-keep-debug" generates Bad Offset in LOAD sections for lld built binaries

2019-03-11 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24321

Manoj Gupta  changed:

   What|Removed |Added

 CC||amodra at gmail dot com,
   ||manojgupta at google dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-14 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

--- Comment #6 from Manoj Gupta  ---
Thanks a lot!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

Manoj Gupta  changed:

   What|Removed |Added

 CC||matthew.wahab at arm dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

Manoj Gupta  changed:

   What|Removed |Added

 CC||ramana.radhakrishnan at foss 
dot a
   ||rm.com

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

Manoj Gupta  changed:

   What|Removed |Added

 CC||rahulchaudhry at chromium dot 
org,
   ||ramana.radhakrishnan@codito
   ||.com, ramana at sourceware dot 
org

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

--- Comment #3 from Manoj Gupta  ---
Created attachment 10129
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10129=edit
Original glibc clone.S file

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

--- Comment #2 from Manoj Gupta  ---
Created attachment 10128
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10128=edit
Good assembly from 2.25

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

Manoj Gupta  changed:

   What|Removed |Added

 CC||manojgupta at google dot com

--- Comment #1 from Manoj Gupta  ---
Created attachment 10127
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10127=edit
Bad assembly file generated

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/21590] New: Arm assembler generates incorrect transformation from ldr to movs

2017-06-13 Thread manojgupta at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21590

Bug ID: 21590
   Summary: Arm assembler generates incorrect transformation from
ldr to movs
   Product: binutils
   Version: 2.27
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: manojgupta at google dot com
  Target Milestone: ---

Created attachment 10126
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10126=edit
Arm input assembly

The attached file clone.S from glibc-2.23/sysdeps/unix/sysv/linux/arm/clone.S
is incorrectly handled in assembler from binutils 2.27.

In the good version:

  3e:   f41c 7f80   tst.w   ip, #256; 0x100
  42:   4f08ldr r7, [pc, #32]   ; (64 <__clone+0x64>)
  44:   bf14ite ne
  46:   f04f 30ff   movne.w r0, #4294967295 ; 0x

Note that ite/movnew instructions depend on condition codes generated by tst.w.

bad version, ldr is replaced by movs:

  3e:   f41c 7f80   tst.w   ip, #256; 0x100
  42:   2714movsr7, #20
  44:   bf14ite ne
  46:   f04f 30ff   movne.w r0, #4294967295 ; 0x

According to ARM assembly docs for MOV:

If S is specified, the instruction:
Updates the N and Z flags according to the result.
Can update the C flag during the calculation of Operand2.
Does not affect the V flag.

So movs incorrectly changes the condition flags generated by tst.w.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils