[Bug ld/14718] New: ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 Bug #: 14718 Summary: ld crashes on ARMv5 due to unaligned memory access Product: binutils Version: 2.22 Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassig...@sourceware.org ReportedBy: ambr...@gmail.com Classification: Unclassified Created attachment 6686 --> http://sourceware.org/bugzilla/attachment.cgi?id=6686 hackish fix See Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=433669 With binutils 2.22, gcc 4.5.4 on an ARMv5 system, ld crashes when static linking a program: # gcc -static hello.c collect2: ld terminated with signal 11 [Segmentation fault] The input can be anything, like "int main () { return 0; }". I've tracked it down to misaligned memory accesses in bfd/elf32-arm.c. The attached patch fixes the misaligned access, the crash no longer occurs and the resulting program runs. Note that this patch uses a gcc-only feature (attribute packed which makes the compiler handle misalignment in software). It's probably not suitable for inclusion into binutils as-is if binutils is to compile with something other than gcc. Instead of this, memcpy() can be used to read and write misaligned memory in a standard way. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #1 from Andreas Schwab 2012-10-14 17:08:37 UTC --- Why is objalloc_alloc returning unaligned memory? -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 Mike Frysinger changed: What|Removed |Added Target||armv5-linux-gnueabi URL||https://bugs.gentoo.org/433 ||669 CC||toolchain at gentoo dot org -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #2 from Ambroz Bizjak 2012-10-14 20:17:01 UTC --- Created attachment 6687 --> http://sourceware.org/bugzilla/attachment.cgi?id=6687 non-hackish fix This fixes the misalignment by properly aligning pointers. Note that it is only correct if the layout of the structure allocated in elf32_arm_allocate_local_sym_info() is irrelevant, and this seems to be the case. Tested, compiles and runs a hello world. Note: Yes, the fix is actually correct, at least according to the C11 standard. It is a consequence of the standard that the alignment of a type always divides its size (and this makes an object aligned to its size correctly aligned). If that was not the case, the second element of an array of such objects could be misaligned even when the first element is aligned. But note that there seem to be other instances of misaligned access involving bfd_vma* and bfd_signed_vma* which were not triggered by what I have tested and may be for architectures other than ARM. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #3 from Ambroz Bizjak 2012-10-14 20:28:34 UTC --- Andreas: the allocation function (bfd_zalloc, not objalloc_alloc) is not returning unaligned memory. The problem is that the code is trying to manually place multiple arrays into a single memory block, without making sure the extra (non-first) arrays are aligned. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #4 from Andreas Schwab 2012-10-14 20:34:17 UTC --- You cannot pass a pointer for an integral argument. How did you manage to suppress the warning? It'll be simpler to just allocate each array separately. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 Siarhei Siamashka changed: What|Removed |Added CC||siarhei.siamashka at gmail ||dot com --- Comment #5 from Siarhei Siamashka 2012-10-14 20:57:41 UTC --- Or maybe changing the order like this: diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 633bb64..0efcf1d 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3061,12 +3061,12 @@ elf32_arm_allocate_local_sym_info (bfd *abfd) elf_local_got_refcounts (abfd) = (bfd_signed_vma *) data; data += num_syms * sizeof (bfd_signed_vma); - elf32_arm_local_iplt (abfd) = (struct arm_local_iplt_info **) data; - data += num_syms * sizeof (struct arm_local_iplt_info *); - elf32_arm_local_tlsdesc_gotent (abfd) = (bfd_vma *) data; data += num_syms * sizeof (bfd_vma); + elf32_arm_local_iplt (abfd) = (struct arm_local_iplt_info **) data; + data += num_syms * sizeof (struct arm_local_iplt_info *); + elf32_arm_local_got_tls_type (abfd) = data; } return TRUE; Because in the current code bfd_signed_vma array (64-bit elements) is followed by arm_local_iplt_info * array (32-bit elements) and then followed by bfd_vma array (64-bit elements again). If num_syms is odd, then the last array is not 64-bit aligned. Just swapping the order of the second and third arrays might help. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 Ambroz Bizjak changed: What|Removed |Added Attachment #6687|0 |1 is obsolete|| --- Comment #6 from Ambroz Bizjak 2012-10-14 21:16:50 UTC --- Created attachment 6688 --> http://sourceware.org/bugzilla/attachment.cgi?id=6688 non-hackish fix, fixed oops, that was indeed casting pointers to size_t and back :) This fixes it by working with offsets from the base of the malloc block. I would be very careful with swapping because the size of the arm_local_iplt_info* is unknown (could be 64-bit or anything). It would still work, but just by accident, because we would allocate 2*num_syms of 32-bit objects first, making sure the 64-bit pointers that follow are aligned. So I strongly prefer the manual alignment approach; it's unlikely that a small change in the code would break it. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #7 from Siarhei Siamashka 2012-10-14 22:32:12 UTC --- (In reply to comment #5) > Because in the current code bfd_signed_vma array (64-bit elements) is followed > by arm_local_iplt_info * array (32-bit elements) and then followed by bfd_vma > array (64-bit elements again). If num_syms is odd, then the last array is not > 64-bit aligned. Just swapping the order of the second and third arrays might > help. Hmm, this is beginning to be really funny. My gentoo arm system has "#define BFD_ARCH_SIZE 64" line in /usr/include/bfd.h, resulting in 64-bit vma typedefs. I guess such weird configuration is a prerequisite for triggering this alignment issue. The culprit is gentoo toolchain-binutils.eclass which is forcing --enable-64-bit-bfd configure option. The architectures like ARM surely have lots of spare RAM to waste... Looks like at least this part of the problem needs to be solved on gentoo side. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #8 from Ambroz Bizjak 2012-10-14 22:49:24 UTC --- (In reply to comment #7) > Hmm, this is beginning to be really funny. My gentoo arm system has "#define > BFD_ARCH_SIZE 64" line in /usr/include/bfd.h, resulting in 64-bit vma > typedefs. > I guess such weird configuration is a prerequisite for triggering this > alignment issue. The culprit is gentoo toolchain-binutils.eclass which is > forcing --enable-64-bit-bfd configure option. The architectures like ARM > surely > have lots of spare RAM to waste... Looks like at least this part of the > problem > needs to be solved on gentoo side. Yeah, that seems to have triggered it, but the bug is still entirely in binutils. Even if you don't pass --enable-64-bit-bfd for ARM toolchain, this will still happen for an ARM->x86_64 cross toolchain (for whatever reason someone would need that). -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14718] ld crashes on ARMv5 due to unaligned memory access
http://sourceware.org/bugzilla/show_bug.cgi?id=14718 --- Comment #9 from Siarhei Siamashka 2012-10-14 22:50:44 UTC --- (In reply to comment #6) > I would be very careful with swapping because the size of the > arm_local_iplt_info* is unknown (could be 64-bit or anything). It would still > work, but just by accident, because we would allocate 2*num_syms of 32-bit > objects first, making sure the 64-bit pointers that follow are aligned. Thanks for pointing this. Indeed, the sizes of vma typedefs and the sizes of pointers can make some really weird combinations. > So I strongly prefer the manual alignment approach; it's unlikely that > a small change in the code would break it. This or the suggestion from Andreas Schwab with separate allocations. One nitpick about your patch is the unnecessary realignment for the char array (sizeof(char) is always 1). -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14720] New: FAIL: ar long file names (bfdtest1)
http://sourceware.org/bugzilla/show_bug.cgi?id=14720 Bug #: 14720 Summary: FAIL: ar long file names (bfdtest1) Product: binutils Version: 2.24 (HEAD) Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassig...@sourceware.org ReportedBy: dang...@gcc.gnu.org Classification: Unclassified Host: hppa2.0w-hp-hpux11.11 Target: hppa2.0w-hp-hpux11.11 Build: hppa2.0w-hp-hpux11.11 Running target unixUsing /opt/gnu/share/dejagnu/baseboards/unix.exp as board description file for t arget. Using /opt/gnu/share/dejagnu/config/unix.exp as generic interface file for targe t.Using /xxx/gnu/binutils/src/binutils/testsuite/config/default.exp as tool-and-ta rget-specific interface file. Running /xxx/gnu/binutils/src/binutils/testsuite/binutils-all/ar.exp ... /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdir/abcdefghijklmnopqrstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 Executing on host: /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdi r/abcdefghijklmnopqrstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 (timeout = 30 0) spawn /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdir/abcdefghijk lmnopqrstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdir/abcdefghijklmnopq rstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 Executing on host: /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdi r/abcdefghijklmnopqrstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 (timeout = 30 0) spawn /xxx/gnu/binutils/objdir/binutils/ar rc tmpdir/artest.a tmpdir/abcdefghijklmnopqrstuvwxyz1 tmpdir/abcdefghijklmnopqrstuvwxyz2 /xxx/gnu/binutils/objdir/binutils/ar t tmpdir/artest.a Executing on host: /xxx/gnu/binutils/objdir/binutils/ar t tmpdir/artest.a (timeout = 300) spawn /xxx/gnu/binutils/objdir/binutils/ar t tmpdir/artest.a abcdefghijklmnopqrstuvwxyz1 abcdefghijklmnopqrstuvwxyz2 abcdefghijklmnopqrstuvwxyz1 abcdefghijklmnopqrstuvwxyz2 /xxx/gnu/binutils/objdir/binutils/ar x tmpdir/artest.a Executing on host: /xxx/gnu/binutils/objdir/binutils/ar x tmpdir/artest.a (timeout = 300) spawn /xxx/gnu/binutils/objdir/binutils/ar x tmpdir/artest.a /xxx/gnu/binutils/objdir/binutils/bfdtest1 tmpdir/artest.a Executing on host: /xxx/gnu/binutils/objdir/binutils/bfdtest1 tmpdir/artest.a (timeout = 300) spawn /xxx/gnu/binutils/objdir/binutils/bfdtest1 tmpdir/artest.a /xxx/gnu/binutils/objdir/binutils/bfdtest1 exited with status 1 /xxx/gnu/binutils/objdir/binutils/bfdtest1 exited with status 1 FAIL: ar long file names (bfdtest1) Similar fails: FAIL: ar thin archive (bfdtest1) FAIL: ar thin archive with nested archive (bfdtest1) -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14721] New: FAIL: Multibyte symbol names
http://sourceware.org/bugzilla/show_bug.cgi?id=14721 Bug #: 14721 Summary: FAIL: Multibyte symbol names Product: binutils Version: 2.24 (HEAD) Status: NEW Severity: normal Priority: P2 Component: gas AssignedTo: unassig...@sourceware.org ReportedBy: dang...@gcc.gnu.org Classification: Unclassified Host: hppa64-hp-hpux11.11 Target: hppa64-hp-hpux11.11 Build: hppa64-hp-hpux11.11 ../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsuite/gas/elf/syms.sExecuting on host: sh -c {../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsu ite/gas/elf/syms.s 2>&1} /dev/null gas.out (timeout = 300)spawn [open ...] /xxx/gnu/binutils/objdir/gas/testsuite/../../binutils/readelf -S -s -p .strtab dump.oExecuting on host: sh -c {/xxx/gnu/binutils/objdir/gas/testsuite/../../binutils/ readelf -S -s -p .strtab dump.o >dump.out 2>gas.stderr} /dev/null (timeout = 300) spawn [open ...] extra regexps in /xxx/gnu/binutils/src/gas/testsuite/gas/elf/syms.d starting wit h "^ \[..\] sy.*mbol$"EOF from dump.out FAIL: Multibyte symbol names -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14722] New: FAIL: weak and common directives
http://sourceware.org/bugzilla/show_bug.cgi?id=14722 Bug #: 14722 Summary: FAIL: weak and common directives Product: binutils Version: 2.24 (HEAD) Status: NEW Severity: normal Priority: P2 Component: gas AssignedTo: unassig...@sourceware.org ReportedBy: dang...@gcc.gnu.org Classification: Unclassified Host: hppa64-hp-hpux11.11 Target: hppa64-hp-hpux11.11 Build: hppa64-hp-hpux11.11 ../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.sExecuting on host: sh -c {../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsu ite/gas/elf/common1.s 2>&1} /dev/null gas.out (timeout = 300) spawn [open ...] /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s: Assembler messages:/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: bad or irreducib le absolute expression/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: junk at end of l ine, first unrecognized character is `,' /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s: Assembler messages:/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: bad or irreducib le absolute expression/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: junk at end of l ine, first unrecognized character is `,' regexp_diff match failure regexp "^[^:]*: Error: symbol `foobar' can not be both weak and common$"line "/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: bad or i rreducible absolute expression"extra lines in dump.stderr starting with "^/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.s:2: Error: junk at end of line, first unrecognized character is `,'$" EOF from /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common1.l FAIL: weak and common directives -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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/14722] FAIL: weak and common directives
http://sourceware.org/bugzilla/show_bug.cgi?id=14722 --- Comment #1 from John David Anglin 2012-10-15 01:27:41 UTC --- Also: ../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s Executing on host: sh -c {../as-new -o dump.o /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s 2>&1} /dev/null gas.out (timeout = 300) spawn [open ...] /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s: Assembler messages:/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s:1: Error: bad or irreducib le absolute expression/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s:1: Error: junk at end of l ine, first unrecognized character is `,'/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s: Assembler messages: /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s:1: Error: bad or irreducib le absolute expression /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s:1: Error: junk at end of line, first unrecognized character is `,' regexp_diff match failureregexp "^[^:]*: Error: symbol `foobar' can not be both weak and common$"line "/xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.s:1: Error: bad or i rreducible absolute expression" extra lines in dump.stderr starting with "^/xxx/gnu/binutils/src/gas/testsuite/g as/elf/common2.s:1: Error: junk at end of line, first unrecognized character is `,'$"EOF from /xxx/gnu/binutils/src/gas/testsuite/gas/elf/common2.l FAIL: common and weak directives -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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 admin/14723] New: bug-binutils notices have extra newlines
http://sourceware.org/bugzilla/show_bug.cgi?id=14723 Bug #: 14723 Summary: bug-binutils notices have extra newlines Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: admin AssignedTo: unassig...@sourceware.org ReportedBy: vap...@gentoo.org Classification: Unclassified this started recently. example e-mail from bug-binutils: Bug #: 14721 Summary: FAIL: Multibyte symbol names Product: binutils when it should look like: Bug #: 14721 Summary: FAIL: Multibyte symbol names Product: binutils -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- 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