[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/21266] New: Unstable qsort in bfd/elf64-ppc.c results in d
From: |
pcarroll at codesourcery dot com |
Subject: |
[Bug binutils/21266] New: Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows |
Date: |
Fri, 17 Mar 2017 17:27:26 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=21266
Bug ID: 21266
Summary: Unstable qsort in bfd/elf64-ppc.c results in
difference in ld's TLS opt 3 test on Windows
Product: binutils
Version: unspecified
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: pcarroll at codesourcery dot com
Target Milestone: ---
The qsort() routine is noted to be unpredictable if 2 compared objects are
considered equal. The 'compare_symbols' function in the bfd/elf64-ppc.c file
compares attributes of various symbols up to a point. Where there can be a
problem is if there are 2 symbols with different names, but identical
attributes. In this case, the current definition of 'compare_symbols' just
does a:
return 0;
at the end of the function. This, however, results in different behavior in
the TLS opt 3 testcase of the linker when the test suite is run on different
OSes. A standard was created for that test case on Linux. When this is run on
a Windows system, however, the test fails:
regexp_diff match failure
regexp "^00000000100000e8 <\.__tls_get_addr>:$"
line "00000000100000e8 <.__tls_get_addr_opt>:"
regexp_diff match failure
regexp "^.*: (4b ff ff ed|ed ff ff 4b) bl 100000e8
<\.__tls_get_addr>$"
line " 100000fc: 4b ff ff ed bl 100000e8 <.__tls_get_addr_opt>"
regexp_diff match failure
regexp "^.*: (4b ff ff e1|e1 ff ff 4b) bl 100000e8
<\.__tls_get_addr>$"
line " 10000108: 4b ff ff e1 bl 100000e8 <.__tls_get_addr_opt>"
To get predictable results between Linux and Windows, the last line of
'compare_symbols' should be changed to be:
return strcmp(a->name,b->name);
With that change, if symbols have different attributes, then they continue to
be handled as before.
If, however, symbols are identical except for having different names (i.e., 2
symbols referring to the same location), then that will allow qsort() to
produce identical output for different OSes.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug binutils/21266] New: Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows,
pcarroll at codesourcery dot com <=
- [Bug binutils/21266] Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows, alfedotov at gmail dot com, 2017/03/18
- [Bug binutils/21266] Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows, amodra at gmail dot com, 2017/03/19
- [Bug binutils/21266] Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows, amodra at gmail dot com, 2017/03/19
- [Bug binutils/21266] Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows, cvs-commit at gcc dot gnu.org, 2017/03/19
- [Bug binutils/21266] Unstable qsort in bfd/elf64-ppc.c results in difference in ld's TLS opt 3 test on Windows, amodra at gmail dot com, 2017/03/19