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]

Re: Special MIPS relocation - How to?


----- Original Message -----
From: "Alan Modra" <amodra@bigpond.net.au>
To: "Francisco Rodriguez" <prodrig@disca.upv.es>
Cc: <binutils@sources.redhat.com>
Sent: Wednesday, July 10, 2002 2:20 AM
Subject: Re: Special MIPS relocation - How to?


> On Tue, Jul 09, 2002 at 09:59:07PM +0200, Francisco Rodriguez wrote:
> > After all the sections have been relocated,
> > I use a call to bfd_get_section_contents to get .text section contents,
> > but the function call returns error. After tracing, the problem seems
> > to be the file IO: a real fseek and fread are needed because
SEC_CONTENTS
> > flag is not set.
> > The fseek returns ok, but the fread returns 0 bytes read.
> > How can this happen? The bfd_get_section_contents call is made
> > before the output bfd is closed, so it should be ok, shouldn't it?
>
> fflush (output_bfd->iostream) perhaps?
>
> --
> Alan Modra
> IBM OzLabs - Linux Technology Centre
>

Hi

Thanks for the hint.
It's not an fflush problem, but led me to look closer at low level IO
routines.

The problem is I'm working with binutils 2.9.5, and the bfd_open_file
function uses FOPEN_WB (write only mode) the first time the output bfd file
is
created, thus the subsequent fread result of 0 bytes is correct.
Looking at 2.12 sources, I discovered the change from
FOPEN_WB to FOPEN_WUB (write and update mode).

Once this change is made, bfd_get_section_contents works fine.

Regards
    Francisco Rodriguez
====================================================
Francisco Rodriguez Ballester (prodrig@disca.upv.es)
Dept. DISCA, EUI - Univ. Politecnica de Valencia
c/Camino de Vera s/n, E-46022, VALENCIA (SPAIN)
tlf: +(34) 96 387 75 77 - fax: +(34) 96 387 75 79
====================================================



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