This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA:] bfd/simple.c: fix NOCROSSREFS for not-pure-ELF targets.


NOCROSSREFS 1 and 2 (run only when gcc for target is found)
fail for mmix-knuth-mmixware (linking from ELF64 to mmo) as
below (ld.log).

y/ld/ld-new  -o tmpdir/cross1 -T x/ld/testsuite/ld-scripts/cross1.t tmpdir/cross1.o tmpdir/cross2.o
tmpdir/cross1.o(.text+0x4)y/ld/ld-new: BFD 2.14.90 20030728 internal error, aborting at x/bfd/simple.c
 line 178 in bfd_simple_get_relocated_section_contents

/home/hp/builds2/mmixf/ld/ld-new: Please report this bug.

FAIL: NOCROSSREFS 1

It's bfd_section_size that aborts relocating .debug_info for the
location info for the error message tested by that test, and the
reason is that the section is already relocated (sec->reloc_done
!= 0) when bfd_section_size is called: bfd_section_size is to be
used only before relocation is done.  You may ask why this bug
isn't seen for "pure" ELF linking.  That's because there's a bug
in ELF linking: sec->reloc_done is *never* set.  Ugh.  To make
bfd_simple_get_relocated_section_contents independently callable
before and after relocation (taking non-relocated input), the
best fix seems to be to move the existing kludge to before the
first bfd_section_size call.

Also checked on i586-pc-linux-gnu (with gcc-2.95.3) and arm-elf
(gcc CVS).

Ok to commit?

	* simple.c (bfd_simple_get_relocated_section_contents): Move
	reloc_done hack to before first bfd_section_size call.

Index: simple.c
===================================================================
RCS file: /cvs/src/src/bfd/simple.c,v
retrieving revision 1.10
diff -p -c -r1.10 simple.c
*** simple.c	29 Jun 2003 10:06:39 -0000	1.10
--- simple.c	2 Aug 2003 14:35:32 -0000
*************** bfd_simple_get_relocated_section_content
*** 141,146 ****
--- 141,154 ----
    int storage_needed;
    void *saved_offsets;

+   /* Foul hack to prevent bfd_section_size aborts.  This flag only controls
+      that macro (and the related size macros), selecting between _raw_size
+      and _cooked_size.  Debug sections won't change size while we're only
+      relocating.  There may be trouble here someday if it tries to run
+      relaxation unexpectedly, so make sure.  */
+   BFD_ASSERT (sec->_raw_size == sec->_cooked_size);
+   sec->reloc_done = 0;
+
    if (! (sec->flags & SEC_RELOC))
      {
        bfd_size_type size = bfd_section_size (abfd, sec);
*************** bfd_simple_get_relocated_section_content
*** 242,255 ****

    bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets);
    free (saved_offsets);
-
-   /* Foul hack to prevent bfd_section_size aborts.  This flag only controls
-      that macro (and the related size macros), selecting between _raw_size
-      and _cooked_size.  Debug sections won't change size while we're only
-      relocating.  There may be trouble here someday if it tries to run
-      relaxation unexpectedly, so make sure.  */
-   BFD_ASSERT (sec->_raw_size == sec->_cooked_size);
-   sec->reloc_done = 0;

    bfd_link_hash_table_free (abfd, link_info.hash);

--- 250,255 ----

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]