[Bug binutils/24891] objdump memory leaks when parsing malformed archive

2019-08-28 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24891

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-08-28
   Assignee|unassigned at sourceware dot org   |amodra at gmail dot com
 Ever confirmed|0   |1

-- 
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/24601] aarch64: local-exec TPREL relocations to weak undefined symbols -> assertion fail

2019-08-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=24601

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

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

commit 6795dba28d531a17a0800d532d555653415702bb
Author: Tamar Christina 
Date:   Thu Aug 22 11:35:35 2019 +0100

AArch64: Fix LD crash on weak and undefined TLS symbols. (PR/24602).

This patch fixes a few linker crashes due to TLS code reaching an assert
when it
shouldn't.

The first scenario is with weak TLS symbols that remain weak during
linking.  In
this case the mid-end would not have seen a TLS symbol and so wouldn't have
allocated the TLS section.  We currently assert here and the linker crashes
with
a not very useful message.

This patch changes this to return the value 0 for the TLS symbol in
question
emulating what lld and gold and other BFD targets do.  However because weak
TLS
is implementation defined and we don't define any behavior for it I also
emit a
warning to the user to inform them of such.

Secondly when a strong TLS reference is undefined. The linker crashes even
after
it correctly reported that there is an undefined reference.  This changes
it so
that it gracefully exits and reports a useful error.

bfd/ChangeLog:

PR ld/24601
* elfnn-aarch64.c (aarch64_relocate): Handle weak TLS and undefined
TLS.
Also Pass input_bfd to _bfd_aarch64_elf_resolve_relocation.
* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Use it.
* elfxx-aarch64.h (_bfd_aarch64_elf_resolve_relocation): Emit warning
for weak TLS.

ld/ChangeLog:

PR ld/24601
* testsuite/ld-aarch64/aarch64-elf.exp (undef-tls, weak-tls): New.
* testsuite/ld-aarch64/undef-tls.d: New test.
* testsuite/ld-aarch64/undef-tls.s: New test.
* testsuite/ld-aarch64/weak-tls.d: New test.
* testsuite/ld-aarch64/weak-tls.s: New test.

(cherry picked from commit 652afeef247770b22c44ca292d1f4c65be40a696)

-- 
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/24601] aarch64: local-exec TPREL relocations to weak undefined symbols -> assertion fail

2019-08-28 Thread tnfchris at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=24601

Tamar Christina  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|2.33|2.32

--- Comment #4 from Tamar Christina  ---
Fixed and backported to 2.32 branch.

-- 
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/24942] objcopy: Add option for setting section alignment

2019-08-28 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24942

Nick Clifton  changed:

   What|Removed |Added

 CC||nickc at redhat dot com

--- Comment #1 from Nick Clifton  ---
Hi Niklas,

  There is an easier way of solving this problem - the assembler's .incbin
  directive.  For example:

  % cat foo.s
.section foo-image, "a", @progbits
.align 4
.global start_of_foo
start_of_foo:
.incbin "foo.jpg"
.global end_of_foo
end_of_foo:

  Assembling this will create an object file called foo.o which contains
  the contents of foo.jpg in a section called foo-image, and which is 
  aligned to 4 bytes.

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


[Bug binutils/24942] objcopy: Add option for setting section alignment

2019-08-28 Thread profclonk at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24942

--- Comment #2 from Niklas Gürtler  ---
Hi Nick,

I knew about "incbin" but needing an (additional) assembly file seems somewhat
clunky. There are even more possibilities: Putting each converted .o file into
its own section, and aligning those sections via the final linker script.
Hacking together a tool that modifies the alignment field in the ELF header. It
might even be possible to do a partial linking step to set the alignment of a
objcopy-produced .o-file using a linker script.

However, if objcopy is capable of converting binary to ELF, then why not make
it actually useful by setting the alignment requirement, especially since it's
a rather simple fix? This would allow us to produce the desired .o file with
one simple step.

Greetings,
Niklas

-- 
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/24931] objdump: print source code as comments

2019-08-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=24931

--- Comment #1 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=a1c110a3fe02f5cb8de18137f6615005288e849e

commit a1c110a3fe02f5cb8de18137f6615005288e849e
Author: Nick Clifton 
Date:   Wed Aug 28 11:39:19 2019 +0100

Add a --source-comment= option to objdump which provides a prefix to
dipslayed source code lines.

PR 24931
* objdump.c (source_comment): New static variable.
(option_values): Add OPTION_SOURCE_COMMENT.
(long_opions): Add --source-comment.
(print_line): If source comment is set, use it as a prefix to the
source code line.
(main): Handle OPTION_SOURCE_COMMENT.
* doc/binutils.texi: Document the new option.
* NEWS: Mention the new feature.
* testsuite/binutils-all/objdump.exp (test_objdump_S): Add tests
of the -S and --source-comment options.

-- 
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/24931] objdump: print source code as comments

2019-08-28 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24931

Nick Clifton  changed:

   What|Removed |Added

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

--- Comment #2 from Nick Clifton  ---
Hi tass3r,

  Changing objdump's default behaviour is bound to cause problems somewhere.
  But instead I have created a patch which adds a new command line option
  to objdump: --source-comment=.  With this you can provide any 
  to be used as a prefix for source code lines.  This also helps with 
  targets whose assemblers do not use the # character for comments...

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


[Bug binutils/24942] objcopy: Add option for setting section alignment

2019-08-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=24942

--- Comment #3 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=fa463e9fc644e7a3bad39aa73bf6be72ea865805

commit fa463e9fc644e7a3bad39aa73bf6be72ea865805
Author: Niklas G?rtler 
Date:   Wed Aug 28 12:33:41 2019 +0100

Add an option to objcopy to change the alignment of sections.

PR 24942
* objcopy.c (SECTION_CONTEXT_SET_ALIGNMENT): New constant.
(struct section_list): Add alignment field.
(command_line_switch): Add OPTION_SET_SECTION_ALIGNMENT.
(copy_options): Add --set-section-alignment.
(copy_usage): Describe --set-section-alignment.
(find_section_list): Initialise the alignment field.
(setup_section): Handle the alignment field.
(copy_main): Handle OPTION_SET_SECTION_ALIGNMENT.
* doc/binutils.texi: Document the new feature.
* NEWS: Mention the new feature.

-- 
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/24942] objcopy: Add option for setting section alignment

2019-08-28 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24942

Nick Clifton  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Nick Clifton  ---
Hi Niklas,

  Very well, since the patch is simple enough to count as obvious, I have gone
  ahead and applied it.

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


[Bug binutils/24942] objcopy: Add option for setting section alignment

2019-08-28 Thread profclonk at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24942

--- Comment #5 from Niklas Gürtler  ---
Hi Nick,

awesome, thank you! Now just to wait for the release... :)

Have a nice day,
Niklas

-- 
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/24406] -Wl,--wrap= incompatible with -flto

2019-08-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=24406

--- Comment #9 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit a78fca7b57c5444ac23110c6d0f80abd966f0e90
Author: Alan Modra 
Date:   Thu Aug 29 00:20:46 2019 +0930

Segfault in ld building SPEC CPU2017 527.cam4_r with -flto

Caused by the PR24406 fix.  unwrap_hash_lookup shouldn't be called
with link_info.wrap_hash NULL.

PR ld/24406
* plugin.c (get_symbols): Test link_info.wrap_hash before calling
unwrap_hash_lookup.

-- 
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/24944] New: gas doesn't read all necessary ditits when parse a floating point number

2019-08-28 Thread jbgg.gnu at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24944

Bug ID: 24944
   Summary: gas doesn't read all necessary ditits when parse a
floating point number
   Product: binutils
   Version: 2.33 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: jbgg.gnu at gmail dot com
  Target Milestone: ---

Created attachment 11966
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11966&action=edit
Patch for this bug

The pseudo instruction .double doesn't work fine parsing some numbers.
The function atof_generic doesn't read all digits of the number.

POC:
$ cat << EOF | as -o tmp && objdump -s tmp
.data
.double 37778931862957165903873.0
EOF

Output of previous command is:

tmp: file format elf64-x86-64

Contents of section .data:
  a044...D

We note that number N=37778931862957165903873.0 is calculated with bc with
command:

$echo 'e=75; 2^e + 2^(e-53) + 1' | bc

Then the numbers a=2^75 and b=(1+2^-52)*2^75 are the below and above
approximation of N to a double floating number. The output of previous
command shows that .double instruction chooses 2^75 as double aproximation,
although floating number (1+2^-52)*2^75 is closest to N since N=(a+b)/2 + 1.

This is due to a variable called ``maximum_useful_digits'' which limits the
number of read digits.

We can replace the variable ``maximum_useful_digits'' by the variable
``number_of_digits_available''.


gas/Changelog:
* atof-generic.c: Delete the variable maximum_useful_digits.
* testsuite/gas/i386/fp.s: add numbers where this bugs ocurrs.
* testsuite/gas/i386/fp.d: correct output.

-- 
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/24945] New: as/objdump accepting invalid default destination mask.

2019-08-28 Thread hgreving at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24945

Bug ID: 24945
   Summary: as/objdump accepting invalid default destination mask.
   Product: binutils
   Version: 2.32
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: hgreving at google dot com
  Target Milestone: ---

A %k0 default mask is not allowed for all scatter/gather instructions in
AVX-512. Looks like as/objdump accept it, for example:

cat test.s
.byte 0x62
.byte 0xf2
.byte 0x7d
.byte 0x08
.byte 0x90
.byte 0x04
.byte 0x48

as test.s
objdump -d a.out 

a.out: file format elf64-x86-64


Disassembly of section .text:

 <.text>:
   0:   62 f2 7d 08 90 04 48vpgatherdd (%rax,%xmm1,2),%xmm0

-- 
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/24891] objdump memory leaks when parsing malformed archive

2019-08-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=24891

--- Comment #1 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit 83cf0d04dcdc9a4e7f105a517390e4c1af444340
Author: Alan Modra 
Date:   Wed Aug 28 16:34:34 2019 +0930

PR24891, objdump memory leaks when parsing malformed archive

BFD was leaking memory in bfd_check_format_matches.  As part of
deciding the proper format of an archive, BFD looks at the format of
the first file stored.  That file's bfd was left open for reasons
given in a comment removed in git commit 0e71e4955cd1 that said:
 /* We ought to close `first' here, but we can't, because
we have no way to remove it from the archive cache.
It's close to impossible to figure out when we can
release bfd_ardata.  FIXME.  */
Well, things have changed since that comment was true and we now can
remove files from the archive cache.  Closing the first file is good
and cures some of the leaks.  Other leaks are caused by
bfd_check_format_matches throwing away bfd tdata before trying a new
match.  That lost the element cache set up when format checking the
first element in the archive.  The easiest and cleanest fix is to
simply disable the caching when checking the first element.

PR 24891
* bfd.c (struct bfd): Add no_element_cache.
* archive.c (_bfd_get_elt_at_filepos): Don't add element to
archive cache when no_element_cache.
(bfd_generic_archive_p): Set no_element_cache when opening first
element to check format.  Close first element too.
(do_slurp_bsd_armap): Don't zero ardata->cache here.
* bfd-in2.h: Regenerate.

-- 
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/24891] objdump memory leaks when parsing malformed archive

2019-08-28 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24891

Alan Modra  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |2.33

--- Comment #2 from Alan Modra  ---
Fixed.

-- 
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/24891] objdump memory leaks when parsing malformed archive

2019-08-28 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24891

Alan Modra  changed:

   What|Removed |Added

   Priority|P3  |P2
   Severity|minor   |normal

--- Comment #3 from Alan Modra  ---
Since the leak can and does occur on archives without any fuzzing, putting the
importance and priority back to normal.

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