This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: 3.0.1 Freeze


At 20:04 07.08.2001, Mark Mitchell wrote:
>>If you could look at
>><http://gcc.gnu.org/ml/gcc-bugs/2001-08/msg00180.html> and advise me a
>>bit I'll happily produce a patch fixing this high priority bug producing
>>buggy linux kernels on PPC.
>
>I do not understand why this is a bug.  The code that is emitted
>on an x86, for:
>
>  void f() {
>    strcpy(c, "test string" + u);
>  }
>
>is:
>
>         movl    u, %edx
>         movl    $12, %eax
>         subl    %edx, %eax
>         addl    $.LC0, %edx
>         pushl   %eax
>         movl    c, %eax
>         pushl   %edx
>         pushl   %eax
>         call    memcpy
>
>or, in C:
>
>  memcpy (c, "test string" + u, 12 - u);

If U is used as a pointer relocation, the above is wrong, we would have to 
generate:

memcpy (c, "test string" + u, 12);

to get what's intended.
Because if U is used as a pointer relocation it is most probably a very 
large pos/neg number. Then instead of a strcpy of a relocated small 
constant string you get a memcpy of a large block. I have the feeling that 
c_strlen was coded to be called by builtin_strlen, but then the code was 
reused by builtin_strcpy and friends, without taking all possibilities into 
consideration.

Franz.


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