This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 3.0.1 Freeze
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: 3.0.1 Freeze
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Tue, 07 Aug 2001 20:28:35 +0200
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- References: <5.1.0.14.2.20010807130521.04aaa728@mail.lauterbach.com>
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.