[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-10-16 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #8 from Sourceware Commits  ---
The master branch has been updated by Alan Modra :

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

commit 76eab8f47a743bde86be410bce8fd8382eaea6c2
Author: Alan Modra 
Date:   Sun Oct 13 15:11:59 2024 +1030

PR32266, segv when linking libclang_rt.asan-powerpc64.so

Change the mmap support added with commit 9ba56acee518 to always mmap
memory with PROT_READ | PROT_WRITE.  Prior to that commit most file
contents were read into a buffer allocated with bfd_alloc or
bfd_malloc and thus the memory was read/write.  Even after that commit
any section contents with relocations must be read/write to apply the
relocs.  Making them all read/write is not a major change, and it
should not introduce any measurable linker slowdown for contents that
are not modified.  More importantly, it removes a BFD behaviour
difference that only triggers when large files are involved.

PR 32266
PR 32109
* libbfd.c (bfd_mmap_local): Remove prot param.  Always mmap
with PROT_READ | PROT_WRITE.  Adjust all calls.
(_bfd_mmap_temporary): Rename from _bfd_mmap_readonly_temporary.
(_bfd_munmap_temporary): Rename from
_bfd_munmap_readonly_temporary.
_bfd_mmap_persistent): Rename from _bfd_mmap_readonly_persistent.
(_bfd_generic_get_section_contents): Use PROT_READ | PROT_WRITE
regardless of relocs.
* libbfd-in.h: Update decls to suit.  Make non-USE_MMAP variants
static inline functions.
* elflink.c: Update all uses of _bfd_mmap functions.
* elf.c: Likewise.
(bfd_elf_get_str_section): Revert commit 656f8fbaae.
* libbfd.h: Regenerate.

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-09-30 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #7 from Sourceware Commits  ---
The binutils-2_43-branch branch has been updated by Alan Modra
:

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

commit 95ed7cf1be25d86ca455b09ffee4f129f1857f1d
Author: Alan Modra 
Date:   Tue Oct 1 07:53:55 2024 +0930

segv in bfd_elf_get_str_section

Attempting to write a termination NUL to PROT_READ mmap'd memory was
a silly idea.

PR 32109
* elf.c (bfd_elf_get_str_section): Don't write terminating NUL
if missing.
* libbfd.c (_bfd_munmap_readonly_temporary): Correct comment.

(cherry picked from commit 656f8fbaae34cb37bda5110cbc8c79c6a2aaa847)

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-09-30 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #6 from Sourceware Commits  ---
The master branch has been updated by Alan Modra :

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

commit 656f8fbaae34cb37bda5110cbc8c79c6a2aaa847
Author: Alan Modra 
Date:   Tue Oct 1 07:53:55 2024 +0930

segv in bfd_elf_get_str_section

Attempting to write a termination NUL to PROT_READ mmap'd memory was
a silly idea.

PR 32109
* elf.c (bfd_elf_get_str_section): Don't write terminating NUL
if missing.
* libbfd.c (_bfd_munmap_readonly_temporary): Correct comment.

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-25 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

Alan Modra  changed:

   What|Removed |Added

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

--- Comment #5 from Alan Modra  ---
Pushed to the branch as well since this is an internal error.  My policy is to
not apply release branch fixes for bugs triggered by fuzzed object files, but
in this case there doesn't seem much risk that the fix will introduce some
other failure.

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-25 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #4 from Sourceware Commits  ---
The binutils-2_43-branch branch has been updated by Alan Modra
:

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

commit cd3e2b58f2c42197737e5f24943a74c394d04b05
Author: Alan Modra 
Date:   Sun Aug 25 15:20:21 2024 +0930

PR32109, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

Since bfd_section for .strtab isn't set, print the section index
instead.  Also, don't return NULL on this error as that results in
multiple mmap/read of the string table.  (We could return NULL if we
arranged to set sh_size zero first, but just what we do with fuzzed
object files is of no concern, and terminating the table might make a
faulty object file usable.)

PR 32109
* elf.c (bfd_elf_get_str_section): Remove outdated comment, and
tweak shstrtabsize test to suit.  Don't use string tab bfd_section
in error message, use index instead.  Don't return NULL on
unterminated string section, terminate it.
(_bfd_elf_get_dynamic_symbols): Similarly terminate string table
section.

(cherry picked from commit db856d41004301b3a56438efd957ef5cabb91530)

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-25 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #3 from Sourceware Commits  ---
The master branch has been updated by Alan Modra :

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

commit db856d41004301b3a56438efd957ef5cabb91530
Author: Alan Modra 
Date:   Sun Aug 25 15:20:21 2024 +0930

PR32109, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

Since bfd_section for .strtab isn't set, print the section index
instead.  Also, don't return NULL on this error as that results in
multiple mmap/read of the string table.  (We could return NULL if we
arranged to set sh_size zero first, but just what we do with fuzzed
object files is of no concern, and terminating the table might make a
faulty object file usable.)

PR 32109
* elf.c (bfd_elf_get_str_section): Remove outdated comment, and
tweak shstrtabsize test to suit.  Don't use string tab bfd_section
in error message, use index instead.  Don't return NULL on
unterminated string section, terminate it.
(_bfd_elf_get_dynamic_symbols): Similarly terminate string table
section.

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-24 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

Alan Modra  changed:

   What|Removed |Added

   Assignee|unassigned at sourceware dot org   |amodra at gmail dot com
 Status|NEW |ASSIGNED

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-23 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

--- Comment #2 from Tom Tromey  ---
This seems to be a bug in BFD:

  if (sec == NULL)
/* Invoking %pA with a null section pointer is an
   internal error.  */
abort ();
coming from:

#0  _bfd_doprnt (print=print@entry=0xf3fa73 , stream=stream@entry=0x7fffd780, 
format=format@entry=0x2600780 "%pB(%pA): string table is corrupt",
args=args@entry=0x7fffd690) at ../../binutils-gdb/bfd/bfd.c:1237
#1  0x016088e7 in _bfd_print (ap=0x7fffd7f8, fmt=0x2600780
"%pB(%pA): string table is corrupt", stream=0x7fffd780, 
print_func=0xf3fa73 ) at
../../binutils-gdb/bfd/bfd.c:1497
#2  bfd_print_error (print_func=0xf3fa73 , stream=0x7fffd780, fmt=0x2600780 "%pB(%pA): string table is
corrupt", ap=0x7fffd7f8)
at ../../binutils-gdb/bfd/bfd.c:1523
#3  0x00f3fba2 in gdb_bfd_error_handler(const char *, typedef
__va_list_tag __va_list_tag *) (fmt=0x2600780 "%pB(%pA): string table is
corrupt", ap=0x7fffd7f8)
at ../../binutils-gdb/gdb/gdb_bfd.c:1246
#4  0x01608876 in _bfd_error_handler (fmt=) at
../../binutils-gdb/bfd/bfd.c:1726
#5  0x0162d327 in bfd_elf_get_str_section (abfd=abfd@entry=0x31c0db0,
shindex=shindex@entry=30) at ../../binutils-gdb/bfd/elf.c:303
#6  0x0162d3cd in bfd_elf_string_from_elf_section (abfd=0x31c0db0,
shindex=30, strindex=771778675) at ../../binutils-gdb/bfd/elf.c:341
#7  0x0162d829 in bfd_elf_string_from_elf_section (strindex=, shindex=, abfd=) at
../../binutils-gdb/bfd/elf.c:560
#8  bfd_elf_sym_name (abfd=abfd@entry=0x31c0db0,
symtab_hdr=symtab_hdr@entry=0x31c0f90, isym=isym@entry=0x31c23f0,
sym_sec=sym_sec@entry=0x0) at ../../binutils-gdb/bfd/elf.c:553
#9  0x0166e0b2 in bfd_elf32_slurp_symbol_table (abfd=0x31c0db0,
symptrs=0x308eee0, dynamic=false) at ../../binutils-gdb/bfd/elfcode.h:1358

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-23 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

Tom Tromey  changed:

   What|Removed |Added

   Last reconfirmed||2024-08-23
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

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


[Bug binutils/32109] internal error, aborting at bfd/bfd.c:1236 in int _bfd_doprnt

2024-08-23 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32109

Tom Tromey  changed:

   What|Removed |Added

  Component|gdb |binutils
 CC||tromey at sourceware dot org
Version|15.1|unspecified
Product|gdb |binutils

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