[Bug binutils/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

--- Comment #2 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Nick Clifton :

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

commit 4207142d6a5d2359170c5f9a140fc1a2351fbda9
Author: Mark Wielaard 
Date:   Tue Nov 27 11:59:10 2018 +

Handle ELF compressed header alignment correctly by setting up the section
alignment correctly for the Elf32_Chdr or Elf64_Chdr type and respect the
ch_addralign field when decompressing the section data.

PR binutils/23919
binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign
check.
(dump_sections_as_bytes): Likewise.
(load_specific_debug_sections): Likewise.
* testsuite/binutils-all/dw2-3.rS: Adjust alignment.
* testsuite/binutils-all/dw2-3.rt: Likewise.

bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment.
(bfd_check_compression_header): Add uncompressed_alignment_power
argument. Check ch_addralign is a power of 2.
* bfd-in2.h: Regenerated.
* compress.c (bfd_compress_section_contents): Get and set
orig_uncompressed_alignment_pow if section is decompressed.
(bfd_is_section_compressed_with_header): Add and get
uncompressed_align_pow_p argument.
(bfd_is_section_compressed): Add uncompressed_align_power argument
to bfd_is_section_compressed_with_header call.
(bfd_init_section_decompress_status): Get and set
uncompressed_alignment_power.
* elf.c (_bfd_elf_make_section_from_shdr): Add
uncompressed_align_power argument to
bfd_is_section_compressed_with_header call.

-- 
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/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

--- Comment #4 from Mark Wielaard  ---
(In reply to Nick Clifton from comment #3)
>   Thanks very much for the bug report, and especially for a patch to fix it!
>   I have applied the patch, so I hope that this problem is now resolved.

Thanks!

>   One very minor point - in the future, would you mind providing the
>   ChangeLog entries as plain text, rather than a context diff ?  It
>   did not matter this time, but often the diff will not apply because
>   the changelog has changed by the time that the patch is applied.

OK, I will in the future.
Do you have some script that helps you handle separate ChangeLog entries?

Note that gnulib contains some helpers for merging ChangeLog entries that I
have used somewhat successfully with mercurial and git. They work the other way
around though, you explicitly do add the ChangeLog entries in the
commit/ChangeLog file, but when a merge action takes place they handle the
entry specially.

https://gnu.wildebeest.org/blog/mjw/2012/03/16/automagically-merging-changelog-files-with-mercurial-or-git/

-- 
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/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

Nick Clifton  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||nickc at redhat dot com
 Resolution|--- |FIXED

--- Comment #3 from Nick Clifton  ---
Hi Mark,

  Thanks very much for the bug report, and especially for a patch to fix it!
  I have applied the patch, so I hope that this problem is now resolved.

  One very minor point - in the future, would you mind providing the
  ChangeLog entries as plain text, rather than a context diff ?  It
  did not matter this time, but often the diff will not apply because
  the changelog has changed by the time that the patch is applied.

Cheers
  Nick

-- 
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


Re: [Bug binutils/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread Nick Clifton
Hi Mark,

>>   One very minor point - in the future, would you mind providing the
>>   ChangeLog entries as plain text, rather than a context diff ?  It

> OK, I will in the future.
> Do you have some script that helps you handle separate ChangeLog entries?

Nope. :-(

> Note that gnulib contains some helpers for merging ChangeLog entries that I
> have used somewhat successfully with mercurial and git. They work the other 
> way
> around though, you explicitly do add the ChangeLog entries in the
> commit/ChangeLog file, but when a merge action takes place they handle the
> entry specially.
> 
> https://gnu.wildebeest.org/blog/mjw/2012/03/16/automagically-merging-changelog-files-with-mercurial-or-git/

Fantastic - thanks - I have been looking for something like that for ages.
Please consider my request for plain text changelog entries withdrawn!

Cheers
  Nick



___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/23904] [2.31 Regression] internal error, aborting at ../../bfd/elfnn-aarch64.c:5078 in _bfd_aarch64_erratum_843419_branch_to_stub

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23904

--- Comment #6 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_31-branch branch has been updated by Tamar Christina
:

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

commit 513092d696472fc06cf7812e14160e16b2da5286
Author: Tamar Christina 
Date:   Tue Nov 27 12:33:21 2018 +

AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)

The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get
together
with the erratum sequence due to the required BL which would break the
sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on
A53
showing no regressions and no issues.

bfd/ChangeLog:

PR ld/23904
* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
(struct erratum_835769_branch_to_stub_clear_data): New.
(_bfd_aarch64_erratum_843419_clear_stub): New.
(clear_erratum_843419_entry): New.
(elfNN_aarch64_tls_relax): Use it.
(elfNN_aarch64_relocate_section): Pass input_section.
(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

PR ld/23904
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.

(cherry picked from commit 9fca35fc3486283562a7fcd9eb0ff845b0152d98)

-- 
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 ld/23904] [2.31 Regression] internal error, aborting at ../../bfd/elfnn-aarch64.c:5078 in _bfd_aarch64_erratum_843419_branch_to_stub

2018-11-27 Thread tnfchris at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=23904

Tamar Christina  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Tamar Christina  ---
Fixed in mainline and backported to binutils 2.31.

-- 
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 ld/23904] [2.31 Regression] internal error, aborting at ../../bfd/elfnn-aarch64.c:5078 in _bfd_aarch64_erratum_843419_branch_to_stub

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23904

--- Comment #5 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Tamar Christina
:

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

commit 9fca35fc3486283562a7fcd9eb0ff845b0152d98
Author: Tamar Christina 
Date:   Tue Nov 27 12:33:21 2018 +

AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)

The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get
together
with the erratum sequence due to the required BL which would break the
sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on
A53
showing no regressions and no issues.

bfd/ChangeLog:

PR ld/23904
* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
(struct erratum_835769_branch_to_stub_clear_data): New.
(_bfd_aarch64_erratum_843419_clear_stub): New.
(clear_erratum_843419_entry): New.
(elfNN_aarch64_tls_relax): Use it.
(elfNN_aarch64_relocate_section): Pass input_section.
(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

PR ld/23904
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.

-- 
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 ld/22263] -fpie -pie generates dynamic relocations in text section

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22263

--- Comment #18 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Tamar Christina
:

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

commit 9fca35fc3486283562a7fcd9eb0ff845b0152d98
Author: Tamar Christina 
Date:   Tue Nov 27 12:33:21 2018 +

AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)

The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get
together
with the erratum sequence due to the required BL which would break the
sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on
A53
showing no regressions and no issues.

bfd/ChangeLog:

PR ld/23904
* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
(struct erratum_835769_branch_to_stub_clear_data): New.
(_bfd_aarch64_erratum_843419_clear_stub): New.
(clear_erratum_843419_entry): New.
(elfNN_aarch64_tls_relax): Use it.
(elfNN_aarch64_relocate_section): Pass input_section.
(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

PR ld/23904
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.

-- 
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 ld/22263] -fpie -pie generates dynamic relocations in text section

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22263

--- Comment #19 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_31-branch branch has been updated by Tamar Christina
:

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

commit 513092d696472fc06cf7812e14160e16b2da5286
Author: Tamar Christina 
Date:   Tue Nov 27 12:33:21 2018 +

AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)

The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get
together
with the erratum sequence due to the required BL which would break the
sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on
A53
showing no regressions and no issues.

bfd/ChangeLog:

PR ld/23904
* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
(struct erratum_835769_branch_to_stub_clear_data): New.
(_bfd_aarch64_erratum_843419_clear_stub): New.
(clear_erratum_843419_entry): New.
(elfNN_aarch64_tls_relax): Use it.
(elfNN_aarch64_relocate_section): Pass input_section.
(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

PR ld/23904
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.

(cherry picked from commit 9fca35fc3486283562a7fcd9eb0ff845b0152d98)

-- 
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/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

H.J. Lu  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #5 from H.J. Lu  ---
On Linux/x86-64, I got

/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy -O elf32-x86-64
--compress-debug-sections=zlib-gabi tmpdir/dw2-3.o tmpdir/debug_str.copy.o
Executing on host:
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy -O elf32-x86-64
--compress-debug-sections=zlib-gabi tmpdir/dw2-3.o tmpdir/debug_str.copy.o  
(timeout = 300)
spawn -ignore SIGHUP
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy -O elf32-x86-64
--compress-debug-sections=zlib-gabi tmpdir/dw2-3.o tmpdir/debug_str.copy.o^M
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy:
tmpdir/debug_str.copy.o: error: alignment power 32767 of section `.zdebug_line'
is too big^M
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy:tmpdir/debug_str.copy.o[.text]:
file in wrong format^M
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy:
tmpdir/debug_str.copy.o: error: alignment power 32767 of section `.zdebug_line'
is too big
/export/build/gnu/binutils/build-x86_64-linux/binutils/objcopy:tmpdir/debug_str.copy.o[.text]:
file in wrong format

FAIL: objcopy (Convert x86-64 object with zlib-gnu to x32 (2))

-- 
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/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

--- Comment #6 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

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

commit 131a5a648d314cd15811158150573cb40eb3abd0
Author: H.J. Lu 
Date:   Tue Nov 27 06:02:36 2018 -0800

Initialize *uncompressed_align_pow_p to 0

Initialize *uncompressed_align_pow_p to 0 since *uncompressed_align_pow_p
is passed to bfd_is_section_compressed_with_header as uninitialized,

PR binutils/23919
* compress.c (bfd_is_section_compressed_with_header): Initialize
*uncompressed_align_pow_p to 0.

-- 
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/23919] bfd doesn't handle ELF compressed data alignment

2018-11-27 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23919

H.J. Lu  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
Version|unspecified |2.32 (HEAD)
 Resolution|--- |FIXED
   Target Milestone|--- |2.32

--- Comment #7 from H.J. Lu  ---
Fixed for 2.32.

-- 
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