This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: readelf.c won't compile with HP-UX 11.00's cc
- To: Alexandre Oliva <aoliva at redhat dot com>
- Subject: Re: readelf.c won't compile with HP-UX 11.00's cc
- From: Nick Clifton <nickc at redhat dot com>
- Date: 27 Feb 2001 17:11:09 -0800
- Cc: binutils at sources dot redhat dot com
- References: <or7l2bobzy.fsf@guarana.lsd.ic.unicamp.br>
Hi Alexandre,
> Mainline readelf.c contains invalid C code. The result of a type cast
> isn't an lvalue, but we pass the result of a cast to GET_DATA_ALLOC as
> the `var' argument, that is assigned to. This compiles with GCC, as
> an extension, but some other compilers barf. This patch fixes it so
> that it compiles. Ok to install?
I would still like to eliminate the compile time warning message which
the cast was trying to remove. How about this version instead ?
Cheers
Nick
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src//src/binutils/readelf.c,v
retrieving revision 1.91
diff -p -r1.91 readelf.c
*** readelf.c 2001/02/11 23:11:39 1.91
--- readelf.c 2001/02/28 01:10:07
*************** typedef int Elf32_Word;
*** 280,289 ****
return 0; \
} \
\
! if (fread (var, size, 1, file) != 1) \
{ \
error (_("Unable to read in %d bytes of %s\n"), size, reason); \
! free (var); \
var = NULL; \
return 0; \
}
--- 280,289 ----
return 0; \
} \
\
! if (fread ((char *) var, size, 1, file) != 1) \
{ \
error (_("Unable to read in %d bytes of %s\n"), size, reason); \
! free ((char *) var); \
var = NULL; \
return 0; \
}
*************** process_unwind (file)
*** 3392,3398 ****
strsec = section_headers + sec->sh_link;
aux.strtab_size = strsec->sh_size;
GET_DATA_ALLOC (strsec->sh_offset, aux.strtab_size,
! (char *) aux.strtab, char *, "string table");
}
else if (sec->sh_type == SHT_IA_64_UNWIND)
unwsec = sec;
--- 3392,3398 ----
strsec = section_headers + sec->sh_link;
aux.strtab_size = strsec->sh_size;
GET_DATA_ALLOC (strsec->sh_offset, aux.strtab_size,
! aux.strtab, const char *, "string table");
}
else if (sec->sh_type == SHT_IA_64_UNWIND)
unwsec = sec;