This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA/PATCH] auto-import errors & DWARF 2 (was Re: _cooked_sizeusually set when/where?)
- From: Brian Ford <ford at vss dot fsi dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 14 Apr 2004 13:29:20 -0500 (CDT)
- Subject: Re: [RFA/PATCH] auto-import errors & DWARF 2 (was Re: _cooked_sizeusually set when/where?)
- References: <Pine.GSO.4.58.0403291622130.21204@thing1-200><20040330032212.GF23980@bubble.modra.org> <Pine.GSO.4.58.0403301631220.21204@thing1-200><20040331012904.GH26906@bubble.modra.org> <Pine.GSO.4.58.0403310939250.21204@thing1-200><Pine.GSO.4.58.0404131722140.29901@thing1-200> <20040414091636.GA5665@bubble.modra.org>
On Wed, 14 Apr 2004, Alan Modra wrote:
> Would you mind trying out this patch? The reloc_done fudge isn't
> needed any more.
Great! That's a much nicer patch.
Although I did not test it extensively, I did confirm that it solves my
original problem. If you are confident it will not cause issues with
other targets, please apply.
> * simple.c (bfd_simple_get_relocated_section_contents): Don't
> change reloc_done. Set and restore _cooked_size.
> (RETURN): Delete.
>
> Index: bfd/simple.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/simple.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 simple.c
> --- bfd/simple.c 30 Nov 2003 18:40:41 -0000 1.14
> +++ bfd/simple.c 14 Apr 2004 09:08:10 -0000
> @@ -140,28 +140,7 @@ bfd_simple_get_relocated_section_content
> bfd_byte *contents, *data;
> int storage_needed;
> void *saved_offsets;
> - bfd_boolean saved_reloc_done = sec->reloc_done;
> -
> -#undef RETURN
> -#define RETURN(x) \
> - do \
> - { \
> - sec->reloc_done = saved_reloc_done; \
> - return (x); \
> - } \
> - while (0)
> -
> - /* Foul hack to prevent bfd_section_size aborts. The reloc_done flag
> - only controls that macro (and the related size macros), selecting
> - between _raw_size and _cooked_size. We may be called with relocation
> - done or not, so we need to save the done-flag and mark the section as
> - not relocated.
> -
> - 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_size_type old_cooked_size;
>
> if (! (sec->flags & SEC_RELOC))
> {
> @@ -175,7 +154,7 @@ bfd_simple_get_relocated_section_content
> if (contents)
> bfd_get_section_contents (abfd, sec, contents, 0, size);
>
> - RETURN (contents);
> + return contents;
> }
>
> /* In order to use bfd_get_relocated_section_contents, we need
> @@ -205,7 +184,7 @@ bfd_simple_get_relocated_section_content
> {
> data = bfd_malloc (bfd_section_size (abfd, sec));
> if (data == NULL)
> - RETURN (NULL);
> + return NULL;
> outbuf = data;
> }
>
> @@ -224,7 +203,7 @@ bfd_simple_get_relocated_section_content
> {
> if (data)
> free (data);
> - RETURN (NULL);
> + return NULL;
> }
> bfd_map_over_sections (abfd, simple_save_output_info, saved_offsets);
>
> @@ -239,6 +218,12 @@ bfd_simple_get_relocated_section_content
> else
> storage_needed = 0;
>
> + /* This function might be called before _cooked_size has been set, and
> + bfd_perform_relocation needs _cooked_size to be valid. */
> + old_cooked_size = sec->_cooked_size;
> + if (sec->_cooked_size == 0)
I would have used old_coocked_size here for the test since it is an auto.
But then again, I'm a realtime programmer obsessed with these silly little
"efficiencies", and I've learned not to trust the compiler to optimize
anything :).
> + sec->_cooked_size = sec->_raw_size;
> +
> contents = bfd_get_relocated_section_contents (abfd,
> &link_info,
> &link_order,
> @@ -262,10 +247,11 @@ bfd_simple_get_relocated_section_content
> free (symbol_table);
> #endif
>
> + sec->_cooked_size = old_cooked_size;
> bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets);
> free (saved_offsets);
>
> _bfd_generic_link_hash_table_free (link_info.hash);
>
> - RETURN (contents);
> + return contents;
> }
Thanks again.
--
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax: 314-551-8444