This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Make the compiler do the math 2.
Hans-Peter Nilsson <hp@bitrange.com> writes:
> On Mon, 25 Sep 2006, Andreas Schwab wrote:
>> ../../bfd/elflink.c:10069:47: error: macro "memcpy" requires 3 arguments, but only 2 given
>
> For elflink.c 1.230 it's line 9707:
> memcpy (fn_name, STRING_COMMA_LEN (".text."));
>
> perhaps most easily fixed by simply disabling use of any
> memcpy-macro:
> (memcpy) (fn_name, STRING_COMMA_LEN (".text."));
How about just using strcpy? Also, the surrounding code has too many
occurrences of magic numbers that should be replaced. Like this perhaps:
2006-09-25 Andreas Schwab <schwab@suse.de>
bfd/
* elflink.c (bfd_elf_gc_sections): Don't use STRING_COMMA_LEN as
argument of memcpy. Replace magic numbers.
binutils/
* prdbg.c (tg_class_static_member): Don't use STRING_COMMA_LEN as
argument of memcpy.
--- bfd/elflink.c.~1.230.~ 2006-09-18 10:58:08.000000000 +0200
+++ bfd/elflink.c 2006-09-25 22:34:35.000000000 +0200
@@ -9699,13 +9699,16 @@ bfd_elf_gc_sections (bfd *abfd, struct b
unsigned long len;
char *fn_name;
asection *fn_text;
+ int o_name_prefix_len = strlen (".gcc_except_table.");
+ int fn_name_prefix_len = strlen (".text.");
- len = strlen (o->name + 18) + 1;
- fn_name = bfd_malloc (len + 6);
+ len = strlen (o->name + o_name_prefix_len) + 1;
+ fn_name = bfd_malloc (len + fn_name_prefix_len);
if (fn_name == NULL)
return FALSE;
- memcpy (fn_name, STRING_COMMA_LEN (".text."));
- memcpy (fn_name + 6, o->name + 18, len);
+ strcpy (fn_name, ".text.");
+ memcpy (fn_name + fn_name_prefix_len,
+ o->name + o_name_prefix_len, len);
fn_text = bfd_get_section_by_name (sub, fn_name);
free (fn_name);
if (fn_text == NULL || !fn_text->gc_mark)
--- binutils/prdbg.c.~1.14.~ 2006-09-18 10:58:08.000000000 +0200
+++ binutils/prdbg.c 2006-09-25 22:34:53.000000000 +0200
@@ -2157,7 +2157,7 @@ tg_class_static_member (void *p, const c
if (! full_name)
return FALSE;
memcpy (full_name, info->stack->next->type, len_class);
- memcpy (full_name + len_class, STRING_COMMA_LEN ("::"));
+ strcpy (full_name + len_class, "::");
memcpy (full_name + len_class + 2, name, len_var + 1);
if (! substitute_type (info, full_name))
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."