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]
Other format: [Raw text]

Problem about gcc 4.1 + binutil 2.16.92 + glibc 2.4 + ARM EABI


Hi,
When enable the gcc 4.1 with EABI support for ARM, I met such situation about
the alignment.

Here is my test case:

#include <stdio.h>
#include <stdlib.h>

struct test {
	char c1;
	long long  n;
	char c2;
};

int my_temp(void)
{
	int i;
	int j;
	char str[2];
	long long l1;
	long long l2;
	char str2;

	printf("%s:\tj address:         0x%08x, str address:    0x%08x\n",
__func__, &j, str);
	printf("%s:\tl1 address:        0x%08x, l2 address:     0x%08x\n",
__func__, &l1, &l2);
	printf("%s:\tstr2 address:      0x%08x\n", __func__, &str2);
	return 0;
}

main()
{
	struct test t;

my_temp();

	printf("%s:\ttest.c1 address:   0x%08x\n", __func__, &(t.c1));
	printf("%s:\ttest.n address:    0x%08x\n", __func__, &(t.n));
	printf("%s:\ttest.c2 address:   0x%08x\n", __func__, &(t.c2));
}

With the gcc 4.1 + EABI for ARM(build optioni: -mabi=aapcs-linux -O2),
I get following output:

[root@Linux /test]#./test.gnu.eabi
my_temp:        j address:      0xbea85ac0, str address:        0xbea85abe
my_temp:        l1 address:     0xbea85ab0, l2 address:         0xbea85aa8
my_temp:        str2 address:   0xbea85aa7
main:   test.c1 address:        0xbea85ad8
main:   test.n address:         0xbea85ae0
main:   test.c2 address:        0xbea85ae8

With the gcc 3.4.3 without EABI(build option: -O2), I get following output:
[root@Linux /test]#./test.gnu
my_temp:        j address:      0xbeb69bf8, str address:        0xbeb69bf0
my_temp:        l1 address:     0xbeb69be8, l2 address:         0xbeb69be0
my_temp:        str2 address:   0xbeb69bdf
main:   test.c1 address:        0xbeb69c10
main:   test.n address:         0xbeb69c18
main:   test.c2 address:        0xbeb69c20

Please notice the address of the str and j. there IS NO memory hole
between therm
when using gcc 3.4.3 and there IS memory hole when using gcc 4.1. My question
is: Why there is difference there. And what is the root cause of the
difference (EABI
or gcc update)? Is there any gcc option to make them align?


Thanks & Regards Yin, Fengwei


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