Bug 17467 - .eh_frame_hdr table overlaps
Summary: .eh_frame_hdr table overlaps
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-08 09:19 UTC by Matthias Klose
Modified: 2014-10-28 06:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2014-10-08 09:19:32 UTC
with PR17447 fixed, there are still some build failures with overlapping FDE tables.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763228
building cbmc shows:

g++ -c -MMD -MP -DSTL_HASH_TR1 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -O2 -g -Werror
 -Wno-long-long -Wno-sign-compare -Wno-parentheses -Wno-strict-aliasing -pedantic -I .. -o irep_hash.o irep_hash.cpp
ld -r -o util.a arith_tools.o base_type.o cmdline.o config.o symbol_table.o expr.o expr_util.o i2string.o irep.o lan
guage.o lispexpr.o lispirep.o location.o message.o language_file.o mp_arith.o namespace.o parseoptions.o rename.o re
place_expr.o threeval.o typecheck.o graph.o type.o cnf_simplify.o pointer_predicates.o merge_irep.o bitvector.o pars
er.o map_util.o replace_symbol.o actuals.o get_module.o string_hash.o string_container.o identifier.o rational.o opt
ions.o c_misc.o simplify_expr.o dstring.o find_symbols.o rational_tools.o ui_message.o simplify_utils.o time_stoppin
g.o symbol.o irep_hash_container.o cout_message.o type_eq.o guard.o array_name.o message_stream.o substitute.o decis
ion_procedure.o union_find.o xml.o xml_irep.o xml_expr.o std_types.o std_code.o format_constant.o find_macros.o ref_
expr_set.o std_expr.o irep_serialization.o fixedbv.o rename_symbol.o ieee_float.o signal_catcher.o pointer_offset_si
ze.o bv_arithmetic.o tempdir.o tempfile.o timer.o unicode.o irep_ids.o byte_operators.o string2int.o file_util.o mem
ory_info.o pipe_stream.o irep_hash.o
g++ -c -MMD -MP -DSTL_HASH_TR1 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -O2 -g -Werror
 -Wno-long-long -Wno-sign-compare -Wno-parentheses -Wno-strict-aliasing -pedantic -I .. -o ieee_float_test.o ieee_fl
oat_test.cpp
g++  -o ieee_float_test ieee_float_test.o util.a ../big-int/bigint.o ../big-int/bigint-func.o
/usr/bin/ld: .eh_frame_hdr table[770] FDE at 0000000000491230 overlaps table[771] FDE at 0000000000491eb8.
/usr/bin/ld: .eh_frame_hdr table[771] FDE at 0000000000491eb8 overlaps table[772] FDE at 00000000004921f8.
/usr/bin/ld: .eh_frame_hdr table[772] FDE at 00000000004921f8 overlaps table[773] FDE at 0000000000494258.
/usr/bin/ld: .eh_frame_hdr table[773] FDE at 0000000000494258 overlaps table[774] FDE at 00000000004944a0.
/usr/bin/ld: .eh_frame_hdr table[774] FDE at 00000000004944a0 overlaps table[775] FDE at 0000000000494610.
/usr/bin/ld: .eh_frame_hdr table[775] FDE at 0000000000494610 overlaps table[776] FDE at 0000000000494d98.
/usr/bin/ld: .eh_frame_hdr table[776] FDE at 0000000000494d98 overlaps table[777] FDE at 0000000000495830.

util.a is built using ld -r, building it with ar rcf lets the link succeed.

https://buildd.debian.org/status/package.php?p=arb&suite=unstable
shows one on x86 only, not x86_64, showing:

Target 'bin/arb_ntree' not found
-> rebuilding bin/arb_ntree (Wed Dec 31 23:59:59 1969)
[05:27.169813816] ------------------------------------------------ Link bin/arb_ntree
g++  -Wl,-O2 -Wl,-rpath=/usr/lib/arb/lib -Wl,-z,relro  -rdynamic -Wl,--export-dynamic -o bin/arb_ntree /scratch/pack
ages/tmp/arb-6.0.2/SOURCE_TOOLS/arb_main_cpp.o -L/scratch/packages/tmp/arb-6.0.2/lib NTREE/NTREE.a SL/SEQUENCE/SEQUE
NCE.a SL/ALIVIEW/ALIVIEW.a SL/PRONUC/PRONUC.a  SL/FILTER/FILTER.a SL/ARB_TREE/ARB_TREE.a SL/ROOTED_TREE/ROOTED_TREE.
a  SL/AP_TREE/AP_TREE.a  ARB_GDE/ARB_GDE.a AWTC/AWTC.a AWTI/AWTI.a CONSENSUS_TREE/CONSENSUS_TREE.a GENOM/GENOM.a GEN
OM_IMPORT/GENOM_IMPORT.a MERGE/MERGE.a MULTI_PROBE/MULTI_PROBE.a PRIMER_DESIGN/PRIMER_DESIGN.a PROBE_DESIGN/PROBE_DE
SIGN.a SEQ_QUALITY/SEQ_QUALITY.a SERVERCNTRL/SERVERCNTRL.a SL/AW_NAME/AW_NAME.a SL/DB_UI/DB_UI.a SL/DB_SCANNER/DB_SC
ANNER.a SL/DB_QUERY/DB_QUERY.a SL/SEQIO/SEQIO.a SL/GUI_ALIVIEW/GUI_ALIVIEW.a SL/HELIX/HELIX.a SL/REGEXPR/REGEXPR.a S
L/REFENTRIES/REFENTRIES.a SL/NDS/NDS.a SL/ITEMS/ITEMS.a SL/INSDEL/INSDEL.a SL/LOCATION/LOCATION.a SL/MACROS/MACROS.a
 SL/TRANSLATE/TRANSLATE.a SL/TREEDISP/TREEDISP.a SL/TREE_ADMIN/TREE_ADMIN.a SL/TREE_READ/TREE_READ.a SL/TREE_WRITE/T
REE_WRITE.a STAT/STAT.a XML/XML.a  PROBE_COM/client.a PROBE_COM/common.a  -lARBDB -lCORE  -lm -lglib-2.0 -lAWT -lWIN
DOW -L//lib -lXm -lXpm -lXt -lXext -lX11
/usr/bin/ld: .eh_frame_hdr table[317] FDE at 00000000081f8320 overlaps table[318] FDE at 00000000081f9ad8.
/usr/bin/ld: .eh_frame_hdr table[318] FDE at 00000000081f9ad8 overlaps table[319] FDE at 00000000081fc5e4.
/usr/bin/ld: .eh_frame_hdr table[319] FDE at 00000000081fc5e4 overlaps table[320] FDE at 00000000081ff80c.
/usr/bin/ld: .eh_frame_hdr table[321] FDE at 00000000081f8398 overlaps table[322] FDE at 00000000081f9b20.
/usr/bin/ld: .eh_frame_hdr table[322] FDE at 00000000081f9b20 overlaps table[323] FDE at 00000000081fc67c.
/usr/bin/ld: .eh_frame_hdr table[323] FDE at 00000000081fc67c overlaps table[324] FDE at 00000000081ff87c.
/usr/bin/ld: .eh_frame_hdr table[325] FDE at 00000000081f83fc overlaps table[326] FDE at 00000000081f9c4c.
/usr/bin/ld: .eh_frame_hdr table[326] FDE at 00000000081f9c4c overlaps table[327] FDE at 00000000081fcef4.

again, all the .a files are built using ld -r.
Comment 1 Matthias Klose 2014-10-09 07:12:06 UTC
object files at http://people.canonical.com/~doko/tmp/tst.tar.xz
run run.sh.
Comment 2 Alan Modra 2014-10-12 11:38:10 UTC
We don't do eh_frame editing for ld -r, ever since https://sourceware.org/ml/binutils/2003-02/msg00471.html was applied.

What's happening here is that we have multiple copies of c++ code emitted in comdat groups, the first one I looked at being _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_, but g++ does not emit the .eh_frame info to the group.  If g++ did do this, as it should, then duplicate .eh_frame info would be discarded along with the duplicate code sections.  Instead we get one copy of the group after ld -r and multiple copies of the .eh_frame info for the group.  That's bad because the "duplicate" .eh_frame info may not exactly match the kept group code (it doesn't with the example object files), and the .eh_frame_hdr lookup table will conspire to choose the last set of .eh_frame info rather than the first (which corresponds to the actual code, assuming a stable qsort).  So there is a nasty exception handling bug lurking to bite someone.
Comment 3 Sourceware Commits 2014-10-13 12:30:10 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  5b69e3572d1ee8e8e6e1991fd07f87a96c48746d (commit)
      from  c780cc2f5062451a568458b6ef9b8aef7cc1dd8a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

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

commit 5b69e3572d1ee8e8e6e1991fd07f87a96c48746d
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Oct 13 15:18:21 2014 +1030

    Run eh_frame optimisation for relocatable link
    
    The idea here is to drop .eh_frame FDEs corresponding to dropped
    comdat group sections or linkonce sections, but not perform changes in
    encoding.
    
    bfd/
    	PR 17467
    	* elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
    	(_bfd_elf_parse_eh_frame): When relocatable output, don't set
    	flags enabling conversion of CIEs and FDEs to use relative encoding.
    	(find_merged_cie): Similarly.
    	(_bfd_elf_write_section_eh_frame): Don't edit FDEs when
    	relocatable, except for CIE pointer.
    	* elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
    	relocs against symbols in dropped comdat group sections.
    	(bfd_elf_discard_info): Do some eh_frame optimisation when
    	relocatable.
    ld/
    	* ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
    	relocatable.

-----------------------------------------------------------------------

Summary of changes:
 bfd/ChangeLog      |   14 ++++++++++++++
 bfd/elf-eh-frame.c |   25 +++++++++++++++++--------
 bfd/elflink.c      |   14 +++++++-------
 ld/ChangeLog       |    5 +++++
 ld/ldlang.c        |    3 +--
 5 files changed, 44 insertions(+), 17 deletions(-)
Comment 4 Alan Modra 2014-10-28 06:47:29 UTC
Fixed