7.6

/*
 * swap.c
 */

extern int buf[];

int* bufp0 = &buf[0];
static int* bufp1;

static void incr() {
  static int count=0;
  count++;
}

void swap() {
  int temp;

  incr();
  bufp1 = &buf[1];
  temp = *bufp0;
  *bufp0 = *bufp1;
  *bufp1 = temp;
}
in .symtab?typemodulesection
bufYesexternalm.data
bufp0Yesglobalswap.data
bufp1Yeslocalswap.bss
swapYesglobalswap.text
tempNo———–——
incrYeslocalswap.text
countYeslocalswap.bss
(cd ./site/content/chapter7/code/7.6; make && make sym)

output:

gcc -c swap.c
objdump -t swap.o

swap.o:     文件格式 elf64-x86-64

SYMBOL TABLE:
0000000000000000 l     O .bss	0000000000000008 bufp1
0000000000000000 l     F .text	0000000000000015 incr
0000000000000008 l     O .bss	0000000000000004 count.1747
0000000000000000 g     O .data	0000000000000008 bufp0
0000000000000000         *UND*	0000000000000000 buf
0000000000000015 g     F .text	0000000000000049 swap
comments powered by Disqus