リスト56 リスト57


〔リスト56〕weak属性を使用した例(test78.c)
	#include <stdio.h>
	void init_proc1()  __attribute__ ((weak   ));
	void init_proc();
	int main(void)
	{
	 printf("start\n");
	 return;
	}
	void init_proc1()
	{
	}
	void init_proc()
	{
	}


〔リスト57〕test78.cから生成されたアセンブラ(test78.s)
	 .file "test78.c"
	 .version "01.01"
	gcc2_compiled.:
	.section .rodata
	.LC0:
	 .string "start\n"
	.text
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $8,%esp
	 addl $-12,%esp
	 pushl $.LC0
	 call printf
	 addl $16,%esp
	 jmp .L2
	 .p2align 4,,7
	.L2:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  main,.Lfe1-main
	 .align 4
	 .weak init_proc1
	 .type  init_proc1,@function
	init_proc1:
	 pushl %ebp
	 movl %esp,%ebp
	.L3:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe2:
	 .size  init_proc1,.Lfe2-init_proc1
	 .align 4
	.globl init_proc
	 .type  init_proc,@function
	init_proc:
	 pushl %ebp
	 movl %esp,%ebp
	.L4:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe3:
	 .size  init_proc,.Lfe3-init_proc
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"