[PATCH] Make the compiler do the math 2.

Pedro Alves pedro_alves@portugalmail.pt
Mon Sep 25 23:53:00 GMT 2006


Hans-Peter Nilsson escreveu:
> 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."));
>
> brgds, H-P
>
>   
Or simply replace with:

-memcpy (fn_name, STRING_COMMA_LEN (".text."));

+CONST_STRNCPY (fn_name, ".text.")

Although all cases of CONST_STRNCPY would
be better replaced with something using memcpy,
since strncpy has to check if the null terminator arrives before the 
specified len, and memcpy,
obviously doesn't. That is, if the compiler doesn't optimize this away.
Also the return of CONST_STRNCPY is nowhere used, so this should be safe.

How about the attached patch?
I named the new macro LITCPY, since I think it serves more the purpose 
of the
macro.

Please (call me stubborn ;) , ) review, and commit.

Cheers,
Pedro Alves

---

bfd/ChangeLog

2006-09-25 Pedro Alves <pedro_alves@portugalmail.pt>

    * bfd-in.h (CONST_STRNCPY) : Delete.
    (LITCPY) : New.
    * bfd-in2.h : Regenerate.
    * elflink.c  (bfd_elf_gc_sections) : Use LITCPY. Don't manually 
calculate string lengths.
    * nlmcode.h (nlm_swap_auxiliary_headers_in) : Use LITCPY.

binutils/ChangeLog

2006-09-25 Pedro Alves <pedro_alves@portugalmail.pt>

    * nlmconv.c (main) : Use LITCPY.
    * prdbg.c (tg_class_static_member) : Likewise.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: litcpy.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20060925/2c8bfbda/attachment.ksh>


More information about the Binutils mailing list