[Bug ld/22756] Linker relaxation miscalculates symbol addresses on riscv

2018-06-01 Thread wilson at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22756

--- Comment #8 from Jim Wilson  ---
Linker relaxation that deletes code is O(m*n) where m is the number of
relocations and n is the number of symbols.  There have been complaints about
this.  This makes the RISC-V linker slower than other targets that don't have
this feature.  Checking for duplicate symbols makes this O(m*n^2) which is even
worse, so I want to only check for duplicates when necessary.

The only significant difference between my patch and yours is that you are
checking for duplicates unconditionally, where I check for them only when
wrapped symbols are present.  Debugging the run-time differences between your
patch and mine, I see that all of the affected symbols are versioned_hidden. 
This happens in the nondeflt_vers code in elflink.c, where it makes the
sym_hash entry for foo point to the sym_hash entry for foo@BAR.  This would
explain why none of the other ports that delete code during linker relaxation
have seen this problem, as they are almost all embedded targets, and symbol
versioning is not common outside glibc.

Here is the patch I propose to add to fix this

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index b82e655b7b..a0bdee54b2 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2708,9 +2708,12 @@ riscv_relax_delete_bytes (bfd *abfd, asection *sec,
bfd_vma addr, size_t count,
 call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference
 the same symbol (which is __wrap_SYMBOL), but still exist as two
 different symbols in 'sym_hashes', we don't want to adjust
-the global symbol __wrap_SYMBOL twice.
-This check is only relevant when symbols are being wrapped.  */
-  if (link_info->wrap_hash != NULL)
+the global symbol __wrap_SYMBOL twice.  */
+  /* The same problem occurs with symbols that are versioned_hidden, as
+foo becomes an alias for foo@BAR, and hence they need the same
+treatment.  */
+  if (link_info->wrap_hash != NULL
+ || sym_hash->versioned == versioned_hidden)
{
  struct elf_link_hash_entry **cur_sym_hashes;

-- 
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/22756] Linker relaxation miscalculates symbol addresses on riscv

2018-06-01 Thread sch...@linux-m68k.org
https://sourceware.org/bugzilla/show_bug.cgi?id=22756

--- Comment #7 from Andreas Schwab  ---
This simpler patch instead of #c3 fixes both the original problem and the
preceding test case.

diff --git c/bfd/elfnn-riscv.c w/bfd/elfnn-riscv.c
index 5f66f4f2d9..9c2b48baf5 100644
--- c/bfd/elfnn-riscv.c
+++ w/bfd/elfnn-riscv.c
@@ -2653,6 +2653,14 @@ riscv_relax_delete_bytes (bfd *abfd, asection *sec,
bfd_vma addr, size_t count)
   for (i = 0; i < symcount; i++)
 {
   struct elf_link_hash_entry *sym_hash = sym_hashes[i];
+  unsigned j;
+
+  /* Check for symbol aliases, don't adjust the same symbol twice.  */
+  for (j = 0; j < i; j++)
+   if (sym_hashes[j] == sym_hash)
+ break;
+  if (j < i)
+   continue;

   if ((sym_hash->root.type == bfd_link_hash_defined
   || sym_hash->root.type == bfd_link_hash_defweak)

-- 
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/18616] oprofile fails with "BFD: Dwarf Error: found dwarf version '64617', this reader only handles version 2, 3 and 4 information"

2018-06-01 Thread Nick Clifton
Hi Marco,

>> I doubt if this is the same as oprofile will produce, but both tools
>> will be displaying processed DWARF line number information so they
>> should be roughly equivalent.
> 
> The objdump output looks fine. Does that mean the issue has to be in Oprofile?

Not "has to", but it is definitely the current most likely suspect.

I am not familiar with oprofile, so I cannot help debug it, but if
someone else is able to delve into it that would be a great help.

Cheers
  Nick



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