Re: RFC: String cleanup
- From: Xavier Bestel <xavier bestel free fr>
- To: Benoît Dejean <benoit placenet org>
- Cc: gtk-devel-list gnome org, Daniel Marjamäki <daniel marjamaki comhem se>
- Subject: Re: RFC: String cleanup
- Date: Fri, 16 Dec 2005 17:04:14 +0100
On Fri, 2005-12-16 at 16:49, Xavier Bestel wrote:
> On Fri, 2005-12-16 at 16:37, Benoît Dejean wrote:
> > compile something with */[] : i get exactly the same asm output
>
> I don't.
> In both cases the string is sotred in .rodata, but in the * case I have
> a pointer in .data (and access goes through that pointer).
FYI:
static const char *str1 = "azerty";
static const char str2[] = "azerty";
void f(const char *x);
void try(void)
{
f(str1);
f(str2);
}
=> str2 is a straight char array
str2:
.string "azerty"
=> str1 is a pointer to a char array
.LC0:
.string "azerty"
str1:
.long .LC0
=> the code for f(str1) dereferences a pointer
movl str1, %eax
pushl %eax
call f
=> the code for f(str2) just computes an adress
movl $str2, (%esp)
call f
compiled with gcc 4.0.3, with -O2
Xav
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]