* warning fixes
@ 2003-12-04 12:07 Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2003-12-04 12:07 UTC (permalink / raw)
To: binutils
bfd/ChangeLog
* coff-i860.c (coff_i860_reloc_nyi): Return bfd_reloc_not_supported.
* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Warning fixes.
(mn10300_elf_relax_section): Likewise.
* nlm32-alpha.c (ONES): Define.
(nlm32_alpha_howto_table): Use it to avoid warnings.
ld/ChangeLog
* ldlang.c (lang_do_assignments): Function return is void.
* ldlang.h (lang_do_assignments): Ditto.
* emultempl/netbsd.em (gld${EMULATION_NAME}_before_parse): Declare.
* Makefile.am (ens32knbsd.c): Depend on netbsd.em.
* Makefile.in: Regenerate.
Index: bfd/coff-i860.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-i860.c,v
retrieving revision 1.13
diff -u -p -r1.13 coff-i860.c
--- bfd/coff-i860.c 24 Nov 2003 18:06:40 -0000 1.13
+++ bfd/coff-i860.c 4 Dec 2003 11:52:09 -0000
@@ -140,6 +140,7 @@ coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE
{
reloc_howto_type *howto = reloc_entry->howto;
fprintf (stderr, _("Relocation `%s' not yet implemented\n"), howto->name);
+ return bfd_reloc_notsupported;
}
#ifndef PCRELOFFSET
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.45
diff -u -p -r1.45 elf-m10300.c
--- bfd/elf-m10300.c 27 Nov 2003 18:49:37 -0000 1.45
+++ bfd/elf-m10300.c 4 Dec 2003 11:52:16 -0000
@@ -1743,10 +1743,13 @@ elf32_mn10300_finish_hash_table_entry (g
byte_count += 2;
/* Count the insn to allocate stack space too. */
- if (entry->stack_size > 0 && entry->stack_size <= 128)
- byte_count += 3;
- else if (entry->stack_size > 0 && entry->stack_size < 256)
- byte_count += 4;
+ if (entry->stack_size > 0)
+ {
+ if (entry->stack_size <= 128)
+ byte_count += 3;
+ else
+ byte_count += 4;
+ }
/* If using "call" will result in larger code, then turn all
the associated "call" instructions into "calls" instructions. */
@@ -2238,11 +2241,13 @@ mn10300_elf_relax_section (abfd, sec, li
if (sym_hash->movm_args)
bytes += 2;
- if (sym_hash->stack_size && sym_hash->stack_size <= 128)
- bytes += 3;
- else if (sym_hash->stack_size
- && sym_hash->stack_size < 256)
- bytes += 4;
+ if (sym_hash->stack_size > 0)
+ {
+ if (sym_hash->stack_size <= 128)
+ bytes += 3;
+ else
+ bytes += 4;
+ }
/* Note that we've deleted prologue bytes for this
function. */
@@ -2290,11 +2295,13 @@ mn10300_elf_relax_section (abfd, sec, li
if (sym_hash->movm_args)
bytes += 2;
- if (sym_hash->stack_size && sym_hash->stack_size <= 128)
- bytes += 3;
- else if (sym_hash->stack_size
- && sym_hash->stack_size < 256)
- bytes += 4;
+ if (sym_hash->stack_size > 0)
+ {
+ if (sym_hash->stack_size <= 128)
+ bytes += 3;
+ else
+ bytes += 4;
+ }
/* Note that we've deleted prologue bytes for this
function. */
Index: bfd/nlm32-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/nlm32-alpha.c,v
retrieving revision 1.9
diff -u -p -r1.9 nlm32-alpha.c
--- bfd/nlm32-alpha.c 4 Nov 2003 10:41:52 -0000 1.9
+++ bfd/nlm32-alpha.c 4 Dec 2003 11:52:19 -0000
@@ -97,6 +97,8 @@ nlm_alpha_write_prefix (abfd)
return TRUE;
}
\f
+#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1)
+
/* How to process the various reloc types. */
static reloc_howto_type nlm32_alpha_howto_table[] =
@@ -144,8 +146,8 @@ static reloc_howto_type nlm32_alpha_howt
0, /* special_function */
"REFQUAD", /* name */
TRUE, /* partial_inplace */
- 0xffffffffffffffff, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
+ ONES (64), /* src_mask */
+ ONES (64), /* dst_mask */
FALSE), /* pcrel_offset */
/* A 32 bit GP relative offset. This is just like REFLONG except
@@ -304,8 +306,8 @@ static reloc_howto_type nlm32_alpha_howt
0, /* special_function */
"SREL64", /* name */
TRUE, /* partial_inplace */
- 0xffffffffffffffff, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
+ ONES (64), /* src_mask */
+ ONES (64), /* dst_mask */
FALSE), /* pcrel_offset */
/* Push a value on the reloc evaluation stack. */
@@ -336,7 +338,7 @@ static reloc_howto_type nlm32_alpha_howt
"OP_STORE", /* name */
FALSE, /* partial_inplace */
0, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
+ ONES (64), /* dst_mask */
FALSE), /* pcrel_offset */
/* Subtract the reloc address from the value on the top of the
Index: ld/emultempl/netbsd.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/netbsd.em,v
retrieving revision 1.3
diff -u -p -r1.3 netbsd.em
--- ld/emultempl/netbsd.em 27 Jun 2003 00:38:25 -0000 1.3
+++ ld/emultempl/netbsd.em 4 Dec 2003 11:52:53 -0000
@@ -2,6 +2,9 @@ LDEMUL_BEFORE_PARSE=gldnetbsd_before_par
cat >>e${EMULATION_NAME}.c <<EOF
static void
+gld${EMULATION_NAME}_before_parse (void);
+
+static void
gldnetbsd_before_parse (void)
{
gld${EMULATION_NAME}_before_parse ();
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.128
diff -u -p -r1.128 ldlang.c
--- ld/ldlang.c 19 Nov 2003 02:40:55 -0000 1.128
+++ ld/ldlang.c 4 Dec 2003 12:01:39 -0000
@@ -3445,7 +3445,7 @@ lang_do_assignments_1
return dot;
}
-bfd_vma
+void
lang_do_assignments (lang_statement_union_type *s,
lang_output_section_statement_type
*output_section_statement,
Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.31
diff -u -p -r1.31 ldlang.h
--- ld/ldlang.h 21 Oct 2003 15:33:47 -0000 1.31
+++ ld/ldlang.h 4 Dec 2003 12:01:39 -0000
@@ -447,7 +447,7 @@ extern void lang_for_each_file
(void (*dothis) (lang_input_statement_type *));
extern void lang_reset_memory_regions
(void);
-extern bfd_vma lang_do_assignments
+extern void lang_do_assignments
(lang_statement_union_type *, lang_output_section_statement_type *,
fill_type *, bfd_vma);
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.146
diff -u -p -r1.146 Makefile.am
--- ld/Makefile.am 2 Dec 2003 08:14:35 -0000 1.146
+++ ld/Makefile.am 4 Dec 2003 12:04:32 -0000
@@ -1231,7 +1231,8 @@ enews.c: $(srcdir)/emulparams/news.sh \
$(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} news "$(tdir_news)"
ens32knbsd.c: $(srcdir)/emulparams/ns32knbsd.sh \
- $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
+ $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/netbsd.em \
+ $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
${GENSCRIPTS} ns32knbsd "$(tdir_ns32knbsd)"
eor32.c: $(srcdir)/emulparams/or32.sh \
$(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/or32.sc ${GEN_DEPENDS}
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* warning fixes
@ 2010-03-17 7:57 Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2010-03-17 7:57 UTC (permalink / raw)
To: binutils
Silences older versions of gcc. Committed.
bfd/
* elf32-arm.c (cortex_a8_erratum_scan): Warning fix.
binutils/
* readelf.c (dump_arm_unwind): Warning fix.
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.227
diff -u -p -r1.227 elf32-arm.c
--- bfd/elf32-arm.c 4 Mar 2010 17:16:08 -0000 1.227
+++ bfd/elf32-arm.c 17 Mar 2010 07:37:37 -0000
@@ -4080,7 +4080,7 @@ cortex_a8_erratum_scan (bfd *input_bfd,
&& last_was_32bit
&& ! last_was_branch)
{
- bfd_signed_vma offset;
+ bfd_signed_vma offset = 0;
bfd_boolean force_target_arm = FALSE;
bfd_boolean force_target_thumb = FALSE;
bfd_vma target;
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.488
diff -u -p -r1.488 readelf.c
--- binutils/readelf.c 5 Mar 2010 21:04:57 -0000 1.488
+++ binutils/readelf.c 17 Mar 2010 07:37:51 -0000
@@ -6276,7 +6276,7 @@ dump_arm_unwind (struct arm_unw_aux_info
}
else
{
- bfd_vma table, table_offset;
+ bfd_vma table, table_offset = 0;
Elf_Internal_Shdr *table_sec;
fputs ("@", stdout);
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* warning fixes
@ 2007-10-15 3:57 Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2007-10-15 3:57 UTC (permalink / raw)
To: binutils
Fedora 7 spits out a bunch of "warning: ignoring return value of blah,
declared with attribute warn_unused_result" when building binutils.
This patch quiets some of these warnings, and an error due to the
newer glibc headers defining an "fprintf" macro. Libiberty has some
similar warnings, and I didn't bother fixing
"opcodes/mt-opc.c:918: warning: memset used with constant zero length
parameter; this could be due to transposed parameters"
because it's in generated code and the constant and length param of
this particular memset are both zero. ie. it isn't a transposition
error so the glibc warning is a bit daft.
The patch isn't perfect. I left some FIXMEs for someone who cares
more than I do about bfd/vms-misc.c and binutils/srconv.c.
bfd/
* coff-arm.c (arm_emit_base_file_entry): Check fwrite return value.
Return status. Adjust callers.
* coff-mcore.c (mcore_emit_base_file_entry): Likewise.
* coff-ppc.c (write_base_file_entry): New function.
(coff_ppc_relocate_section): Use it.
* elf32-arm.c (find_thumb_glue): Check asprintf return status.
(find_arm_glue): Likewise.
* vms-misc.c (_bfd_vms_output_flush): Check fwrite return value.
bfd/doc/
* chew.c (write_buffer): Check fwrite return value.
binutils/
* objdump.c (print_line): Check fwrite return value.
* srconv.c (checksum, wr_tr, wr_cs): Likewise.
* sysdump.c (fillup): Return zero on getc or fread EOF. Return count
read.
gas/
* read.c (do_s_func): Check asprintf return status.
* stabs.c (stabs_generate_asm_func): Likewise.
(stabs_generate_asm_endfunc): Likewise.
opcodes/
* mcore-dis.c (print_insn_mcore): Protect "fprintf" var against
macro expansion.
Index: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.72
diff -u -p -r1.72 coff-arm.c
--- bfd/coff-arm.c 3 Jul 2007 14:26:39 -0000 1.72
+++ bfd/coff-arm.c 14 Oct 2007 00:33:18 -0000
@@ -939,21 +939,24 @@ coff_arm_link_hash_table_create (bfd * a
return & ret->root.root;
}
-static void
+static bfd_boolean
arm_emit_base_file_entry (struct bfd_link_info *info,
bfd *output_bfd,
asection *input_section,
bfd_vma reloc_offset)
{
- bfd_vma addr = reloc_offset
- - input_section->vma
- + input_section->output_offset
- + input_section->output_section->vma;
+ bfd_vma addr = (reloc_offset
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma);
if (coff_data (output_bfd)->pe)
addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
- fwrite (& addr, 1, sizeof (addr), (FILE *) info->base_file);
+ if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
+ return TRUE;
+ bfd_set_error (bfd_error_system_call);
+ return FALSE;
}
\f
#ifndef ARM_WINCE
@@ -1381,10 +1384,10 @@ coff_arm_relocate_section (bfd *output_b
bfd_put_32 (output_bfd, h_val | a2t3_func_addr_insn,
s->contents + my_offset + 8);
- if (info->base_file)
- arm_emit_base_file_entry (info, output_bfd, s,
- my_offset + 8);
-
+ if (info->base_file
+ && !arm_emit_base_file_entry (info, output_bfd,
+ s, my_offset + 8))
+ return FALSE;
}
BFD_ASSERT (my_offset <= globals->arm_glue_size);
@@ -1486,9 +1489,11 @@ coff_arm_relocate_section (bfd *output_b
bfd_put_32 (output_bfd, h_val,
s->contents + my_offset + 16);
- if (info->base_file)
- arm_emit_base_file_entry (info, output_bfd, s,
- my_offset + 16);
+ if (info->base_file
+ && !arm_emit_base_file_entry (info,
+ output_bfd, s,
+ my_offset + 16))
+ return FALSE;
}
else
{
@@ -1572,13 +1577,13 @@ coff_arm_relocate_section (bfd *output_b
}
}
- if (info->base_file)
- {
- /* Emit a reloc if the backend thinks it needs it. */
- if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
- arm_emit_base_file_entry (info, output_bfd, input_section,
- rel->r_vaddr);
- }
+ /* Emit a reloc if the backend thinks it needs it. */
+ if (info->base_file
+ && sym
+ && pe_data(output_bfd)->in_reloc_p(output_bfd, howto)
+ && !arm_emit_base_file_entry (info, output_bfd, input_section,
+ rel->r_vaddr))
+ return FALSE;
if (done)
rstat = bfd_reloc_ok;
Index: bfd/coff-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-mcore.c,v
retrieving revision 1.38
diff -u -p -r1.38 coff-mcore.c
--- bfd/coff-mcore.c 3 Jul 2007 14:26:39 -0000 1.38
+++ bfd/coff-mcore.c 14 Oct 2007 00:33:18 -0000
@@ -51,8 +51,6 @@ static reloc_howto_type *coff_mcore_rtyp
PARAMS ((bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *, struct internal_syment *,
bfd_vma *));
-static void mcore_emit_base_file_entry
- PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma));
static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
\f
/* The NT loader points the toc register to &toc + 32768, in order to
@@ -221,12 +219,11 @@ mcore_hash_table;
\f
/* Add an entry to the base file. */
-static void
-mcore_emit_base_file_entry (info, output_bfd, input_section, reloc_offset)
- struct bfd_link_info * info;
- bfd * output_bfd;
- asection * input_section;
- bfd_vma reloc_offset;
+static bfd_boolean
+mcore_emit_base_file_entry (struct bfd_link_info *info,
+ bfd *output_bfd,
+ asection *input_section,
+ bfd_vma reloc_offset)
{
bfd_vma addr = reloc_offset
- input_section->vma
@@ -236,7 +233,11 @@ mcore_emit_base_file_entry (info, output
if (coff_data (output_bfd)->pe)
addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
- fwrite (&addr, 1, sizeof (addr), (FILE *) info->base_file);
+ if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
+ return TRUE;
+
+ bfd_set_error (bfd_error_system_call);
+ return FALSE;
}
\f
static bfd_reloc_status_type
@@ -522,12 +523,13 @@ coff_mcore_relocate_section (output_bfd,
break;
}
- if (info->base_file)
- {
- /* Emit a reloc if the backend thinks it needs it. */
- if (sym && pe_data (output_bfd)->in_reloc_p (output_bfd, howto))
- mcore_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr);
- }
+ /* Emit a reloc if the backend thinks it needs it. */
+ if (info->base_file
+ && sym
+ && pe_data (output_bfd)->in_reloc_p (output_bfd, howto)
+ && !mcore_emit_base_file_entry (info, output_bfd, input_section,
+ rel->r_vaddr))
+ return FALSE;
switch (rstat)
{
Index: bfd/coff-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-ppc.c,v
retrieving revision 1.33
diff -u -p -r1.33 coff-ppc.c
--- bfd/coff-ppc.c 3 Jul 2007 14:26:39 -0000 1.33
+++ bfd/coff-ppc.c 14 Oct 2007 00:33:19 -0000
@@ -982,6 +982,18 @@ static bfd_boolean in_reloc_p(abfd, howt
&& (howto->type != IMAGE_REL_PPC_TOCREL16_DEFN) ;
}
+static bfd_boolean
+write_base_file_entry (bfd *obfd, struct bfd_link_info *info, bfd_vma addr)
+{
+ if (coff_data (obfd)->pe)
+ addr -= pe_data (obfd)->pe_opthdr.ImageBase;
+ if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
+ return TRUE;
+
+ bfd_set_error (bfd_error_system_call);
+ return FALSE;
+}
+
/* The reloc processing routine for the optimized COFF linker. */
static bfd_boolean
@@ -1237,10 +1249,8 @@ coff_ppc_relocate_section (output_bfd, i
bfd_vma addr = (toc_section->output_section->vma
+ toc_section->output_offset + our_toc_offset);
- if (coff_data (output_bfd)->pe)
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
-
- fwrite (&addr, 1,4, (FILE *) info->base_file);
+ if (!write_base_file_entry (output_bfd, info, addr))
+ return FALSE;
}
/* FIXME: this test is conservative. */
@@ -1453,15 +1463,13 @@ coff_ppc_relocate_section (output_bfd, i
/* Relocation to a symbol in a section which
isn't absolute - we output the address here
to a file. */
- bfd_vma addr = rel->r_vaddr
- - input_section->vma
- + input_section->output_offset
- + input_section->output_section->vma;
+ bfd_vma addr = (rel->r_vaddr
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma);
- if (coff_data (output_bfd)->pe)
- addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
-
- fwrite (&addr, 1,4, (FILE *) info->base_file);
+ if (!write_base_file_entry (output_bfd, info, addr))
+ return FALSE;
}
}
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.128
diff -u -p -r1.128 elf32-arm.c
--- bfd/elf32-arm.c 28 Sep 2007 08:43:45 -0000 1.128
+++ bfd/elf32-arm.c 14 Oct 2007 00:33:26 -0000
@@ -2520,9 +2520,10 @@ find_thumb_glue (struct bfd_link_info *l
hash = elf_link_hash_lookup
(&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
- if (hash == NULL)
- asprintf (error_message, _("unable to find THUMB glue '%s' for '%s'"),
- tmp_name, name);
+ if (hash == NULL
+ && asprintf (error_message, _("unable to find THUMB glue '%s' for '%s'"),
+ tmp_name, name) == -1)
+ *error_message = (char *) bfd_errmsg (bfd_error_system_call);
free (tmp_name);
@@ -2553,9 +2554,10 @@ find_arm_glue (struct bfd_link_info *lin
myh = elf_link_hash_lookup
(&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
- if (myh == NULL)
- asprintf (error_message, _("unable to find ARM glue '%s' for '%s'"),
- tmp_name, name);
+ if (myh == NULL
+ && asprintf (error_message, _("unable to find ARM glue '%s' for '%s'"),
+ tmp_name, name) == -1)
+ *error_message = (char *) bfd_errmsg (bfd_error_system_call);
free (tmp_name);
Index: bfd/vms-misc.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-misc.c,v
retrieving revision 1.26
diff -u -p -r1.26 vms-misc.c
--- bfd/vms-misc.c 3 Jul 2007 14:26:43 -0000 1.26
+++ bfd/vms-misc.c 14 Oct 2007 00:33:26 -0000
@@ -691,12 +691,17 @@ _bfd_vms_output_flush (bfd * abfd)
if (PRIV (push_level) == 0)
{
+ if (0
#ifndef VMS
- /* Write length first, see FF_FOREIGN in the input routines. */
- fwrite (PRIV (output_buf) + 2, 2, 1, (FILE *) abfd->iostream);
-#endif
- fwrite (PRIV (output_buf), (size_t) real_size, 1,
- (FILE *) abfd->iostream);
+ /* Write length first, see FF_FOREIGN in the input routines. */
+ || fwrite (PRIV (output_buf) + 2, 2, 1,
+ (FILE *) abfd->iostream) != 1
+#endif
+ || (real_size != 0
+ && fwrite (PRIV (output_buf), (size_t) real_size, 1,
+ (FILE *) abfd->iostream) != 1))
+ /* FIXME: Return error status. */
+ abort ();
PRIV (output_size) = 0;
}
Index: bfd/doc/chew.c
===================================================================
RCS file: /cvs/src/src/bfd/doc/chew.c,v
retrieving revision 1.20
diff -u -p -r1.20 chew.c
--- bfd/doc/chew.c 3 Jul 2007 14:26:43 -0000 1.20
+++ bfd/doc/chew.c 14 Oct 2007 00:33:27 -0000
@@ -120,6 +120,7 @@ static void overwrite_string (string_typ
static void catbuf (string_type *, char *, unsigned int);
static void cattext (string_type *, char *);
static void catstr (string_type *, string_type *);
+static void die (char *);
#endif
static void
@@ -162,7 +163,9 @@ write_buffer (buffer, f)
string_type *buffer;
FILE *f;
{
- fwrite (buffer->ptr, buffer->write_idx, 1, f);
+ if (buffer->write_idx != 0
+ && fwrite (buffer->ptr, buffer->write_idx, 1, f) != 1)
+ die ("cannot write output");
}
static void
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.132
diff -u -p -r1.132 objdump.c
--- binutils/objdump.c 10 Jul 2007 13:52:39 -0000 1.132
+++ binutils/objdump.c 14 Oct 2007 00:33:31 -0000
@@ -1130,14 +1130,17 @@ static void
print_line (struct print_file_list *p, unsigned int line)
{
const char *l;
+ size_t len;
--line;
if (line >= p->maxline)
return;
l = p->linemap [line];
- fwrite (l, 1, strcspn (l, "\n\r"), stdout);
- putchar ('\n');
-}
+ /* Test fwrite return value to quiet glibc warning. */
+ len = strcspn (l, "\n\r");
+ if (len == 0 || fwrite (l, len, 1, stdout) == 1)
+ putchar ('\n');
+}
/* Print a range of source code lines. */
Index: binutils/srconv.c
===================================================================
RCS file: /cvs/src/src/binutils/srconv.c,v
retrieving revision 1.23
diff -u -p -r1.23 srconv.c
--- binutils/srconv.c 19 Jul 2007 16:17:38 -0000 1.23
+++ binutils/srconv.c 14 Oct 2007 00:33:32 -0000
@@ -176,7 +176,9 @@ checksum (FILE *file, unsigned char *ptr
/* Glue on a checksum too. */
ptr[bytes] = ~sum;
- fwrite (ptr, bytes + 1, 1, file);
+ if (fwrite (ptr, bytes + 1, 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
@@ -299,7 +301,10 @@ wr_tr (void)
0x03, /* RL */
0xfd, /* CS */
};
- fwrite (b, 1, sizeof (b), file);
+
+ if (fwrite (b, sizeof (b), 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
static void
@@ -1452,7 +1457,10 @@ wr_cs (void)
0x00, /* dot */
0xDE /* CS */
};
- fwrite (b, 1, sizeof (b), file);
+
+ if (fwrite (b, sizeof (b), 1, file) != 1)
+ /* FIXME: Return error status. */
+ abort ();
}
/* Write out the SC records for a unit. Create an SC
Index: binutils/sysdump.c
===================================================================
RCS file: /cvs/src/src/binutils/sysdump.c,v
retrieving revision 1.19
diff -u -p -r1.19 sysdump.c
--- binutils/sysdump.c 5 Jul 2007 16:54:45 -0000 1.19
+++ binutils/sysdump.c 14 Oct 2007 00:33:32 -0000
@@ -119,8 +119,15 @@ fillup (unsigned char *ptr)
int sum;
int i;
- size = getc (file) - 2;
- fread (ptr, 1, size, file);
+ size = getc (file);
+ if (size == EOF
+ || size <= 2)
+ return 0;
+
+ size -= 2;
+ if (fread (ptr, size, 1, file) != 1)
+ return 0;
+
sum = code + size + 2;
for (i = 0; i < size; i++)
@@ -132,7 +139,7 @@ fillup (unsigned char *ptr)
if (dump)
dh (ptr, size);
- return size - 1;
+ return size;
}
static barray
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.131
diff -u -p -r1.131 read.c
--- gas/read.c 4 Oct 2007 17:05:36 -0000 1.131
+++ gas/read.c 14 Oct 2007 00:33:38 -0000
@@ -5671,14 +5671,20 @@ do_s_func (int end_p, const char *defaul
if (*input_line_pointer != ',')
{
if (default_prefix)
- asprintf (&label, "%s%s", default_prefix, name);
+ {
+ if (asprintf (&label, "%s%s", default_prefix, name) == -1)
+ as_fatal ("%s", xstrerror (errno));
+ }
else
{
char leading_char = bfd_get_symbol_leading_char (stdoutput);
/* Missing entry point, use function's name with the leading
char prepended. */
if (leading_char)
- asprintf (&label, "%c%s", leading_char, name);
+ {
+ if (asprintf (&label, "%c%s", leading_char, name) == -1)
+ as_fatal ("%s", xstrerror (errno));
+ }
else
label = name;
}
Index: gas/stabs.c
===================================================================
RCS file: /cvs/src/src/gas/stabs.c,v
retrieving revision 1.30
diff -u -p -r1.30 stabs.c
--- gas/stabs.c 3 Oct 2007 11:35:16 -0000 1.30
+++ gas/stabs.c 14 Oct 2007 00:33:38 -0000
@@ -669,8 +669,9 @@ stabs_generate_asm_func (const char *fun
}
as_where (&file, &lineno);
- asprintf (&buf, "\"%s:F1\",%d,0,%d,%s",
- funcname, N_FUN, lineno + 1, startlabname);
+ if (asprintf (&buf, "\"%s:F1\",%d,0,%d,%s",
+ funcname, N_FUN, lineno + 1, startlabname) == -1)
+ as_fatal ("%s", xstrerror (errno));
input_line_pointer = buf;
s_stab ('s');
free (buf);
@@ -695,7 +696,8 @@ stabs_generate_asm_endfunc (const char *
++label_count;
colon (sym);
- asprintf (&buf, "\"\",%d,0,0,%s-%s", N_FUN, sym, startlabname);
+ if (asprintf (&buf, "\"\",%d,0,0,%s-%s", N_FUN, sym, startlabname) == -1)
+ as_fatal ("%s", xstrerror (errno));
input_line_pointer = buf;
s_stab ('s');
free (buf);
Index: opcodes/mcore-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/mcore-dis.c,v
retrieving revision 1.21
diff -u -p -r1.21 mcore-dis.c
--- opcodes/mcore-dis.c 5 Jul 2007 09:49:02 -0000 1.21
+++ opcodes/mcore-dis.c 14 Oct 2007 00:34:17 -0000
@@ -122,12 +122,12 @@ print_insn_mcore (memaddr, info)
break;
if (op->name == 0)
- fprintf (stream, ".short 0x%04x", inst);
+ (*fprintf) (stream, ".short 0x%04x", inst);
else
{
const char *name = grname[inst & 0x0F];
- fprintf (stream, "%s", op->name);
+ (*fprintf) (stream, "%s", op->name);
switch (op->opclass)
{
@@ -135,42 +135,42 @@ print_insn_mcore (memaddr, info)
break;
case OT:
- fprintf (stream, "\t%d", inst & 0x3);
+ (*fprintf) (stream, "\t%d", inst & 0x3);
break;
case O1:
case JMP:
case JSR:
- fprintf (stream, "\t%s", name);
+ (*fprintf) (stream, "\t%s", name);
break;
case OC:
- fprintf (stream, "\t%s, %s", name, crname[(inst >> 4) & 0x1F]);
+ (*fprintf) (stream, "\t%s, %s", name, crname[(inst >> 4) & 0x1F]);
break;
case O1R1:
- fprintf (stream, "\t%s, r1", name);
+ (*fprintf) (stream, "\t%s, r1", name);
break;
case MULSH:
case O2:
- fprintf (stream, "\t%s, %s", name, grname[(inst >> 4) & 0xF]);
+ (*fprintf) (stream, "\t%s, %s", name, grname[(inst >> 4) & 0xF]);
break;
case X1:
- fprintf (stream, "\tr1, %s", name);
+ (*fprintf) (stream, "\tr1, %s", name);
break;
case OI:
- fprintf (stream, "\t%s, %d", name, ((inst >> 4) & 0x1F) + 1);
+ (*fprintf) (stream, "\t%s, %d", name, ((inst >> 4) & 0x1F) + 1);
break;
case RM:
- fprintf (stream, "\t%s-r15, (r0)", name);
+ (*fprintf) (stream, "\t%s-r15, (r0)", name);
break;
case RQ:
- fprintf (stream, "\tr4-r7, (%s)", name);
+ (*fprintf) (stream, "\tr4-r7, (%s)", name);
break;
case OB:
@@ -182,16 +182,16 @@ print_insn_mcore (memaddr, info)
case OMa:
case OMb:
case OMc:
- fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x1F);
+ (*fprintf) (stream, "\t%s, %d", name, (inst >> 4) & 0x1F);
break;
case I7:
- fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x7F);
+ (*fprintf) (stream, "\t%s, %d", name, (inst >> 4) & 0x7F);
break;
case LS:
- fprintf (stream, "\t%s, (%s, %d)", grname[(inst >> 8) & 0xF],
- name, ((inst >> 4) & 0xF) << isiz[(inst >> 13) & 3]);
+ (*fprintf) (stream, "\t%s, (%s, %d)", grname[(inst >> 8) & 0xF],
+ name, ((inst >> 4) & 0xF) << isiz[(inst >> 13) & 3]);
break;
case BR:
@@ -201,7 +201,7 @@ print_insn_mcore (memaddr, info)
if (inst & 0x400)
val |= 0xFFFFFC00;
- fprintf (stream, "\t0x%lx", (long)(memaddr + 2 + (val << 1)));
+ (*fprintf) (stream, "\t0x%lx", (long)(memaddr + 2 + (val << 1)));
if (strcmp (op->name, "bsr") == 0)
{
@@ -210,7 +210,7 @@ print_insn_mcore (memaddr, info)
if (info->print_address_func && val != 0)
{
- fprintf (stream, "\t// ");
+ (*fprintf) (stream, "\t// ");
info->print_address_func (val, info);
}
}
@@ -221,8 +221,9 @@ print_insn_mcore (memaddr, info)
{
long val;
val = (inst & 0x000F);
- fprintf (stream, "\t%s, 0x%lx",
- grname[(inst >> 4) & 0xF], (long)(memaddr - (val << 1)));
+ (*fprintf) (stream, "\t%s, 0x%lx",
+ grname[(inst >> 4) & 0xF],
+ (long) (memaddr - (val << 1)));
}
break;
@@ -247,11 +248,12 @@ print_insn_mcore (memaddr, info)
| (ibytes[2] << 8) | (ibytes[3]);
/* Removed [] around literal value to match ABI syntax 12/95. */
- fprintf (stream, "\t%s, 0x%lX", grname[(inst >> 8) & 0xF], val);
+ (*fprintf) (stream, "\t%s, 0x%lX", grname[(inst >> 8) & 0xF], val);
if (val == 0)
- fprintf (stream, "\t// from address pool at 0x%lx",
- (long)(memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
+ (*fprintf) (stream, "\t// from address pool at 0x%lx",
+ (long) (memaddr + 2
+ + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
}
break;
@@ -276,17 +278,18 @@ print_insn_mcore (memaddr, info)
| (ibytes[2] << 8) | (ibytes[3]);
/* Removed [] around literal value to match ABI syntax 12/95. */
- fprintf (stream, "\t0x%lX", val);
+ (*fprintf) (stream, "\t0x%lX", val);
/* For jmpi/jsri, we'll try to get a symbol for the target. */
if (info->print_address_func && val != 0)
{
- fprintf (stream, "\t// ");
+ (*fprintf) (stream, "\t// ");
info->print_address_func (val, info);
}
else
{
- fprintf (stream, "\t// from address pool at 0x%lx",
- (long)(memaddr + 2 + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
+ (*fprintf) (stream, "\t// from address pool at 0x%lx",
+ (long) (memaddr + 2
+ + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
}
}
break;
@@ -298,13 +301,13 @@ print_insn_mcore (memaddr, info)
"ee", "ee,ie", "ee,fe", "ee,fe,ie"
};
- fprintf (stream, "\t%s", fields[inst & 0x7]);
+ (*fprintf) (stream, "\t%s", fields[inst & 0x7]);
}
break;
default:
/* If the disassembler lags the instruction set. */
- fprintf (stream, "\tundecoded operands, inst is 0x%04x", inst);
+ (*fprintf) (stream, "\tundecoded operands, inst is 0x%04x", inst);
break;
}
}
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* warning fixes
@ 2003-05-09 11:32 Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2003-05-09 11:32 UTC (permalink / raw)
To: binutils
Fix various warnings, some of which were real problems.
bfd/ChangeLog
* cpu-arm.c (arm_check_note): Warning fix.
* elf32-iq2000.c (iq2000_elf_check_relocs): Warning fixes. Arrange
to keep relocs if edited.
(iq2000_elf_print_private_bfd_data): Return TRUE.
* elfxx-ia64.c (elfNN_ia64_relax_section): Use ELFNN_R_SYM, not
ELF64_R_SYM.
(elfNN_ia64_relax_ldxmov): Warning fix.
* xtensa-isa.c (xtensa_add_isa): Warning fix.
* xtensa-modules.c (get_num_opcodes): Warning fix.
include/ChangeLog
* xtensa-isa-internal.h (struct xtensa_isa_module_struct): Remove
const on gen_num_opcodes_fn return type.
opcodes/ChangeLog
* i386-dis.c (print_insn): Test intel_syntax against (char) -1 in
case char is unsigned.
Index: bfd/cpu-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-arm.c,v
retrieving revision 1.10
diff -u -p -r1.10 cpu-arm.c
--- bfd/cpu-arm.c 1 Apr 2003 13:08:05 -0000 1.10
+++ bfd/cpu-arm.c 9 May 2003 11:18:47 -0000
@@ -260,7 +260,7 @@ arm_check_note (abfd, buffer, buffer_siz
}
else
{
- if (namesz != (strlen (expected_name) + 1 + 3) & ~3)
+ if (namesz != ((strlen (expected_name) + 1 + 3) & ~3))
return FALSE;
if (strcmp (descr, expected_name) != 0)
Index: bfd/elf32-iq2000.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-iq2000.c,v
retrieving revision 1.1
diff -u -p -r1.1 elf32-iq2000.c
--- bfd/elf32-iq2000.c 3 Jan 2003 21:12:27 -0000 1.1
+++ bfd/elf32-iq2000.c 9 May 2003 11:18:52 -0000
@@ -454,8 +454,9 @@ iq2000_elf_check_relocs (abfd, info, sec
{
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *rel_end;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ bfd_boolean changed = FALSE;
if (info->relocateable)
return TRUE;
@@ -499,10 +500,20 @@ iq2000_elf_check_relocs (abfd, info, sec
if (memcmp (sec->name, ".debug", 6) == 0
|| memcmp (sec->name, ".stab", 5) == 0
|| memcmp (sec->name, ".eh_frame", 9) == 0)
- rel->r_info = ELF32_R_INFO (ELF32_R_SYM (rel->r_info), R_IQ2000_32_DEBUG);
+ {
+ ((Elf_Internal_Rela *) rel)->r_info
+ = ELF32_R_INFO (ELF32_R_SYM (rel->r_info), R_IQ2000_32_DEBUG);
+ changed = TRUE;
+ }
break;
}
}
+
+ if (changed)
+ /* Note that we've changed relocs, otherwise if !info->keep_memory
+ we'll free the relocs and lose our changes. */
+ (const Elf_Internal_Rela *) (elf_section_data (sec)->relocs) = relocs;
+
return TRUE;
}
@@ -929,6 +940,7 @@ iq2000_elf_print_private_bfd_data (abfd,
}
fputc ('\n', file);
+ return TRUE;
}
static
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.81
diff -u -p -r1.81 elfxx-ia64.c
--- bfd/elfxx-ia64.c 9 May 2003 02:27:09 -0000 1.81
+++ bfd/elfxx-ia64.c 9 May 2003 11:19:00 -0000
@@ -796,7 +796,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
goto error_return;
}
- isym = isymbuf + ELF64_R_SYM (irel->r_info);
+ isym = isymbuf + ELFNN_R_SYM (irel->r_info);
if (isym->st_shndx == SHN_UNDEF)
continue; /* We can't do anthing with undefined symbols. */
else if (isym->st_shndx == SHN_ABS)
@@ -1089,7 +1089,7 @@ elfNN_ia64_relax_ldxmov (abfd, contents,
case 0: shift = 5; break;
case 1: shift = 14; off += 3; break;
case 2: shift = 23; off += 6; break;
- case 3:
+ default:
abort ();
}
Index: bfd/xtensa-isa.c
===================================================================
RCS file: /cvs/src/src/bfd/xtensa-isa.c,v
retrieving revision 1.1
diff -u -p -r1.1 xtensa-isa.c
--- bfd/xtensa-isa.c 1 Apr 2003 15:50:27 -0000 1.1
+++ bfd/xtensa-isa.c 9 May 2003 11:19:00 -0000
@@ -159,7 +159,7 @@ configuration.\n"
static int
xtensa_add_isa (xtensa_isa_internal *isa, libisa_module_specifier libisa)
{
- const int (*get_num_opcodes_fn) (void);
+ int (*get_num_opcodes_fn) (void);
struct config_struct *(*get_config_table_fn) (void);
xtensa_opcode_internal **(*get_opcodes_fn) (void);
int (*decode_insn_fn) (const xtensa_insnbuf);
Index: bfd/xtensa-modules.c
===================================================================
RCS file: /cvs/src/src/bfd/xtensa-modules.c,v
retrieving revision 1.2
diff -u -p -r1.2 xtensa-modules.c
--- bfd/xtensa-modules.c 2 Apr 2003 16:53:44 -0000 1.2
+++ bfd/xtensa-modules.c 9 May 2003 11:19:01 -0000
@@ -41,7 +41,7 @@ tie_undo_reloc_l (uint32 offset, uint32
}
xtensa_opcode_internal** get_opcodes (void);
-const int get_num_opcodes (void);
+int get_num_opcodes (void);
int decode_insn (const xtensa_insnbuf);
int interface_version (void);
@@ -5463,7 +5463,7 @@ get_opcodes (void)
return &opcodes[0];
}
-const int
+int
get_num_opcodes (void)
{
return 149;
Index: include/xtensa-isa-internal.h
===================================================================
RCS file: /cvs/src/src/include/xtensa-isa-internal.h,v
retrieving revision 1.1
diff -u -p -r1.1 xtensa-isa-internal.h
--- include/xtensa-isa-internal.h 1 Apr 2003 15:50:30 -0000 1.1
+++ include/xtensa-isa-internal.h 9 May 2003 11:19:21 -0000
@@ -104,7 +104,7 @@ typedef struct xtensa_isa_internal_struc
typedef struct xtensa_isa_module_struct
{
- const int (*get_num_opcodes_fn) (void);
+ int (*get_num_opcodes_fn) (void);
xtensa_opcode_internal **(*get_opcodes_fn) (void);
int (*decode_insn_fn) (const xtensa_insnbuf);
struct config_struct *(*get_config_table_fn) (void);
Index: opcodes/i386-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/i386-dis.c,v
retrieving revision 1.38
diff -u -p -r1.38 i386-dis.c
--- opcodes/i386-dis.c 22 Mar 2003 18:56:45 -0000 1.38
+++ opcodes/i386-dis.c 9 May 2003 11:19:49 -0000
@@ -1891,7 +1891,7 @@ print_insn (pc, info)
mode_64bit = (info->mach == bfd_mach_x86_64_intel_syntax
|| info->mach == bfd_mach_x86_64);
- if (intel_syntax == -1)
+ if (intel_syntax == (char) -1)
intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax
|| info->mach == bfd_mach_x86_64_intel_syntax);
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* warning fixes
@ 2002-05-03 18:57 Alan Modra
0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2002-05-03 18:57 UTC (permalink / raw)
To: binutils
* ar.c (replace_members): Remove unused var. Formatting fix.
* binemul.c (ar_emul_default_parse_arg): Add ATTRIBUTE_UNUSED.
Index: binutils/ar.c
===================================================================
RCS file: /cvs/src/src/binutils/ar.c,v
retrieving revision 1.24
diff -u -p -r1.24 ar.c
--- binutils/ar.c 18 Mar 2002 12:45:54 -0000 1.24
+++ binutils/ar.c 4 May 2002 01:54:42 -0000
@@ -1302,7 +1302,6 @@ replace_members (arch, files_to_move, qu
bfd **after_bfd; /* New entries go after this one */
bfd *current;
bfd **current_ptr;
- bfd *temp;
while (files_to_move && *files_to_move)
{
@@ -1331,7 +1330,8 @@ replace_members (arch, files_to_move, qu
}
if (bfd_stat_arch_elt (current, &asbuf) != 0)
/* xgettext:c-format */
- fatal (_("internal stat error on %s"), current->filename);
+ fatal (_("internal stat error on %s"),
+ current->filename);
if (fsbuf.st_mtime <= asbuf.st_mtime)
goto next_file;
Index: binutils/binemul.c
===================================================================
RCS file: /cvs/src/src/binutils/binemul.c,v
retrieving revision 1.1
diff -u -p -r1.1 binemul.c
--- binutils/binemul.c 18 Mar 2002 12:45:54 -0000 1.1
+++ binutils/binemul.c 4 May 2002 01:54:42 -0000
@@ -159,7 +159,7 @@ ar_emul_parse_arg (arg)
boolean
ar_emul_default_parse_arg (arg)
- char *arg;
+ char *arg ATTRIBUTE_UNUSED;
{
return false;
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-17 7:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-04 12:07 warning fixes Alan Modra
-- strict thread matches above, loose matches on Subject: below --
2010-03-17 7:57 Alan Modra
2007-10-15 3:57 Alan Modra
2003-05-09 11:32 Alan Modra
2002-05-03 18:57 Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).