リスト13 リスト14 リスト15 リスト16


〔リスト13〕変数のアラインメントを16バイトにしたソース(test92.c)
#include <stdio.h>
//変数属性の指定 aligned (alignment) 
struct foo { int x[20] __attribute__ ((aligned (16))); }foo1;
int main(void)
{
    foo1.x[0]   =   1;
    foo1.x[1]   =   2;
    printf("foo1の境界----%d\n",__alignof__(foo1));
    return 0;
}


〔リスト14〕変数のアラインメントを32バイトにしたソース(test93.c)
#include <stdio.h>
//変数属性の指定 aligned (alignment) 
struct foo { int x[20] __attribute__ ((aligned (32))); }foo1;
int main(void)
{
    foo1.x[0]   =   1;
    foo1.x[1]   =   2;
    printf("foo1の境界----%d\n",__alignof__(foo1));
    return 0;
}


〔リスト15〕変数のアラインメントを16バイトにしたソースをコンパイル後のオブジェクト配置(test92nm.txt)
08048334 t Letext
080494f8 ? _DYNAMIC
080494d8 ? _GLOBAL_OFFSET_TABLE_
080484a0 R _IO_stdin_used
080494cc ? __CTOR_END__
080494c8 ? __CTOR_LIST__
080494d4 ? __DTOR_END__
080494d0 ? __DTOR_LIST__
080494c4 ? __EH_FRAME_BEGIN__
080494c4 ? __FRAME_END__
08049598 A __bss_start
080494b8 D __data_start
         w __deregister_frame_info@@GLIBC_2.0
08048440 t __do_global_ctors_aux
08048360 t __do_global_dtors_aux
         w __gmon_start__
         U __libc_start_main@@GLIBC_2.0
         w __register_frame_info@@GLIBC_2.0
08049598 A _edata
08049610 A _end
08048480 ? _fini
0804849c R _fp_hw
08048298 ? _init
08048310 T _start
08048334 t call_gmon_start
080494c0 d completed.4
080494b8 W data_start
080483b4 t fini_dummy
080495c0 B foo1
080494c4 d force_to_data
080494c4 d force_to_data
080483c0 t frame_dummy
08048334 t gcc2_compiled.
08048360 t gcc2_compiled.
08048440 t gcc2_compiled.
08048480 t gcc2_compiled.
08048400 t gcc2_compiled.
080483e8 t init_dummy
08048468 t init_dummy
08048400 T main
080495a0 b object.11
080494bc d p.3
         U printf@@GLIBC_2.0


〔リスト16〕変数のアラインメントを32バイトにしたソースコンパイル後のオブジェクト配置(test93nm.txt)
08048334 t Letext
080494f8 ? _DYNAMIC
080494d8 ? _GLOBAL_OFFSET_TABLE_
080484a0 R _IO_stdin_used
080494cc ? __CTOR_END__
080494c8 ? __CTOR_LIST__
080494d4 ? __DTOR_END__
080494d0 ? __DTOR_LIST__
080494c4 ? __EH_FRAME_BEGIN__
080494c4 ? __FRAME_END__
08049598 A __bss_start
080494b8 D __data_start
         w __deregister_frame_info@@GLIBC_2.0
08048440 t __do_global_ctors_aux
08048360 t __do_global_dtors_aux
         w __gmon_start__
         U __libc_start_main@@GLIBC_2.0
         w __register_frame_info@@GLIBC_2.0
08049598 A _edata
08049620 A _end
08048480 ? _fini
0804849c R _fp_hw
08048298 ? _init
08048310 T _start
08048334 t call_gmon_start
080494c0 d completed.4
080494b8 W data_start
080483b4 t fini_dummy
080495c0 B foo1
080494c4 d force_to_data
080494c4 d force_to_data
080483c0 t frame_dummy
08048334 t gcc2_compiled.
08048360 t gcc2_compiled.
08048440 t gcc2_compiled.
08048480 t gcc2_compiled.
08048400 t gcc2_compiled.
080483e8 t init_dummy
08048468 t init_dummy
08048400 T main
080495a0 b object.11
080494bc d p.3
         U printf@@GLIBC_2.0