[Bug ld/17826] ld dies with "corrupted double-linked list" when trying to link ELF objects both -pie and -static

2015-01-11 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17826

H.J. Lu  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
Version|2.26 (HEAD) |2.24
 Resolution|--- |DUPLICATE

--- Comment #3 from H.J. Lu  ---
Dup

*** This bug has been marked as a duplicate of bug 16428 ***

-- 
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/17826] ld dies with "corrupted double-linked list" when trying to link ELF objects both -pie and -static

2015-01-11 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17826

H.J. Lu  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|WORKSFORME  |---

--- Comment #2 from H.J. Lu  ---
Reopen for dup.

-- 
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/16428] autoconf tests don't terminate on ix86-linux-gnu with -static -fPIE -pie on glibc-2.18 based systems

2015-01-11 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16428

H.J. Lu  changed:

   What|Removed |Added

 CC||blueness at gentoo dot org

--- Comment #7 from H.J. Lu  ---
*** Bug 17826 has been marked as a duplicate of this bug. ***

-- 
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/17827] New: PIE copy relocations are broken with pointers

2015-01-11 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17827

Bug ID: 17827
   Summary: PIE copy relocations are broken with pointers
   Product: binutils
   Version: 2.25
Status: NEW
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: hjl.tools at gmail dot com

On Linux/x86-64 with GCC 5:

[hjl@gnu-tools-1 pr17689-2]$ cat x.c 
#if 0
#include 
extern char *program_invocation_name;
int
main ()
{
  printf ("%s\n", program_invocation_name);
  return 0;
}
#else
extern char *bar_alias;
extern void foo (char *);
char **ptr = &bar_alias;

int
main ()
{
  foo (bar_alias);
  foo (*ptr);
  return 0;
}
#endif

[hjl@gnu-tools-1 pr17689-2]$ cat bar.c
#include 

char *bar = "PASS";
extern char *bar_alias __attribute__ ((weak, alias ("bar")));

void
foo (char *x)
{
  printf ("%s\n", x);
}
[hjl@gnu-tools-1 pr17689-2]$ make
gcc -pie -o x x.o libbar.so -Wl,-rpath,.
/usr/local/bin/ld: x.o(.data.rel+0x0): reloc against `bar_alias': error 4
/usr/local/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [x] Error 1
[hjl@gnu-tools-1 pr17689-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/17531] readelf crashes on fuzzed samples

2015-01-11 Thread cherepan at mccme dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=17531

--- Comment #63 from Alexander Cherepanov  ---
Created attachment 8060
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8060&action=edit
Problems with `readelf -agteAruhlsSdIncVWw --dyn-syms -D`

Files: 1
Errors:
  4 Conditional jump or move depends on uninitialised value(s)
  1 Invalid read of size ...
  1 Process terminating with default action of signal 11 (SIGSEGV)
  1 Use of uninitialised value of size ...

-- 
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/17531] readelf crashes on fuzzed samples

2015-01-11 Thread cherepan at mccme dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=17531

--- Comment #64 from Alexander Cherepanov  ---
Created attachment 8061
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8061&action=edit
Problems with `readelf -agteAruhlsSdIncVWw --dyn-syms -D`

Files: 1
Errors:
  6 Conditional jump or move depends on uninitialised value(s)
  8 Invalid read of size ...
  1 Process terminating with default action of signal 11 (SIGSEGV)
  1 Use of uninitialised value of size ...

-- 
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/17219] ld/mips: can no longer build libstdc++ (gcc 4.8/4.9)

2015-01-11 Thread matthew.fortune at imgtec dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17219

Matthew Fortune  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at sourceware dot org   |matthew.fortune at 
imgtec dot com

--- Comment #4 from Matthew Fortune  ---
(In reply to Aaro Koskinen from comment #3)
> I get similar errors with release 2.25 binutils. Trying to cross-build MIPS
> GCC configured with --with-float=soft fails miserably. With hard float there
> is no issues (or binutils 2.24 with soft float). Apparently 2.25 binutils
> require some additional flags which GCC 4.9 fails to pass?
> 
> Is there any simple workaround for this?

This is a compiler driver issue. The LD failures relating to relocations are
somewhat strange but I believe they are not the important part here. The ABI
problems from the assembler warnings are the root cause.

I've put together a backport of minimal GCC driver changes for the GCC 4.9
branch and that is pretty much the only way to resolve this. The new
floating-point ABI checks in the assembler unfortunately couldn't be seamless
for everything and soft-float is the case that takes most of the pain.

With the GCC patch in place I managed to build a GCC 4.9 (branch) + binutils
2.25 (branch) soft-float toolchain. I'll post the patch to GCC at some point
tomorrow and try to remember and update this ticket with a link. The patch
should apply cleanly to any GCC 4.9 release so will have to be ported by a
distribution maintainer if anyone wants any of the already released GCC 4.9.x
compilers alongside binutils 2.25 onwards.

I will look at a similar patch for GCC 4.8 if there is sufficient call for that
alongside binutils 2.25.

Sorry for not getting to the GCC 4.9 patch sooner, I knew about it and never
quite got to doing it.

-- 
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/17827] PIE copy relocations are broken with pointers

2015-01-11 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=17827

--- Comment #1 from cvs-commit at gcc dot gnu.org  ---
commit 9d1d54d5a7e3b634895e6e434646c706eb55c082
Author: H.J. Lu 
Date:   Sun Jan 11 08:04:27 2015 -0800

Only discard space for pc-relative relocs symbols

When building PIE, we should only discard space for pc-relative relocs
symbols which turn out to need copy relocs.

bfd/

PR ld/17827
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): For PIE,
only discard space for pc-relative relocs symbols which turn
out to need copy relocs.

ld/testsuite/

PR ld/17827
* ld-x86-64/pr17689.out: Updated.
* ld-x86-64/pr17689b.S: Likewise.

* ld-x86-64/pr17827.rd: New file.

* ld-x86-64/x86-64.exp: Run PR ld/17827 test.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 70b138b..234d559 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-11  H.J. Lu  
+
+PR ld/17827
+* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): For PIE,
+only discard space for pc-relative relocs symbols which turn
+out to need copy relocs.
+
 2015-01-09  Nick Clifton  

 * tekhex.c (getvalue): Fix thinko in test for correct extraction
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 581ee17..6b7d3c9 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2742,13 +2742,23 @@ elf_x86_64_allocate_dynrelocs (struct
elf_link_hash_entry *h, void * inf)
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
 return FALSE;
 }
-  /* For PIE, discard space for relocs against symbols which
- turn out to need copy relocs.  */
+  /* For PIE, discard space for pc-relative relocs against
+ symbols which turn out to need copy relocs.  */
   else if (info->executable
&& (h->needs_copy || eh->needs_copy)
&& h->def_dynamic
&& !h->def_regular)
-eh->dyn_relocs = NULL;
+{
+  struct elf_dyn_relocs **pp;
+
+  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+{
+  if (p->pc_count != 0)
+*pp = p->next;
+  else
+pp = &p->next;
+}
+}
 }
 }
   else if (ELIMINATE_COPY_RELOCS)
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 229e006..e6903f7 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2015-01-11  H.J. Lu  
+
+PR ld/17827
+* ld-x86-64/pr17689.out: Updated.
+* ld-x86-64/pr17689b.S: Likewise.
+
+* ld-x86-64/pr17827.rd: New file.
+
+* ld-x86-64/x86-64.exp: Run PR ld/17827 test.
+
 2015-01-08  Jan Beulich  

 * ld-x86-64/pr14207.d: Adjust expecations to cover the
diff --git a/ld/testsuite/ld-x86-64/pr17689.out
b/ld/testsuite/ld-x86-64/pr17689.out
index 7ef22e9..38e0352 100644
--- a/ld/testsuite/ld-x86-64/pr17689.out
+++ b/ld/testsuite/ld-x86-64/pr17689.out
@@ -1 +1,2 @@
 PASS
+PASS
diff --git a/ld/testsuite/ld-x86-64/pr17689b.S
b/ld/testsuite/ld-x86-64/pr17689b.S
index c95f891..64485c7 100644
--- a/ld/testsuite/ld-x86-64/pr17689b.S
+++ b/ld/testsuite/ld-x86-64/pr17689b.S
@@ -5,8 +5,18 @@ main:
 subq$8, %rsp
 movqbar_alias(%rip), %rdi
 callfoo@PLT
+movqptr(%rip), %rax
+movq(%rax), %rdi
+callfoo@PLT
 xorl%eax, %eax
 addq$8, %rsp
 ret
 .sizemain, .-main
+.globlptr
+.section.data.rel,"aw",@progbits
+.align 8
+.typeptr, @object
+.sizeptr, 8
+ptr:
+.quadbar_alias
 .section.note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr17827.rd
b/ld/testsuite/ld-x86-64/pr17827.rd
new file mode 100644
index 000..d78ea2f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr17827.rd
@@ -0,0 +1,4 @@
+#failif
+#...
+[0-9a-f ]+R_X86_64_NONE.*
+#...
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp
b/ld/testsuite/ld-x86-64/x86-64.exp
index aa8555f..5b49bff 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -432,6 +432,14 @@ if { [isnative] && [which $CC] != 0 } {
 {{readelf {-Wr} pr17689.rd}} \
 "pr17689" \
 ] \
+[list \
+"Build pr17827 with PIE without -fPIE" \
+"tmpdir/pr17689.so -pie" \
+"" \
+{ pr17689b.S } \
+{{readelf {-Wr} pr17827.rd}} \
+"pr17827" \
+] \
 ]

 run_ld_link_exec_tests [] [list \

-- 
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/17827] PIE copy relocations are broken with pointers

2015-01-11 Thread brobecker at gnat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17827

Joel Brobecker  changed:

   What|Removed |Added

 CC||brobecker at gnat dot com

--- Comment #2 from Joel Brobecker  ---
Sorry about the diff. I was trying to reproduce, and forgot to exclude the diff
from the call to the script that fails those commits. It's a one-off.

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