リスト23 リスト24


〔リスト23〕section属性を指定したソース(test98.c)
#include <stdio.h>
//変数属性の指定 section   
struct foo
{
    char a;
    int x[2] ;
}foo_  __attribute__ ((section ("foo1_section") ));
struct foo2
{
    char a;
    int x[2];
}foo2_  __attribute__ ((section ("foo2_section") ));
int data __attribute__ ((section ("data_section") ));
int main(void)
{
    data    =   1;
    return 0;
}


〔リスト24〕section属性を指定したソースから生成されたアセンブラ(test98.s)
    .file       "test98.c"
    .version    "01.01"
gcc2_compiled.:
.text
    .align  4
.globl  main
    .type   main,@function
main:
    pushl   %ebp
    movl    %esp,%ebp
    movl    $1,data
    xorl    %eax,%eax
    jmp .L2
    .p2align    4,,7
.L2:
    movl    %ebp,%esp
    popl    %ebp
    ret
.Lfe1:
    .size   main,.Lfe1-main
.globl  foo_
.section    foo1_section,"aw",@progbits
    .align  4
    .type   foo_,@object
    .size   foo_,12
foo_:
    .zero   12
.globl  foo2_
.section    foo2_section,"aw",@progbits
    .align  4
    .type   foo2_,@object
    .size   foo2_,12
foo2_:
    .zero   12
.globl  data
.section    data_section,"aw",@progbits
    .align  4
    .type   data,@object
    .size   data,4
data:
    .zero   4
    .ident  "GCC: (GNU) 2.95.3 20010315 (release)"