This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Why doesn't objdump display assembly code mixed with source code?


1.c
--------------------------------
int half(int x)
{
	return x/2;
}

link.xn
---------------------------------
OUTPUT_ARCH(mips) 
ENTRY(main)

SECTIONS
{
	.text 0x80051000 : 	
	{
	 *(.text)
	 *(.rodata*)
	}
 	 
	.data :
	{
	 *(.data)
	 *(.sdata)	 
	}

	.sbss : 
  	{ 	
  	 *(.sbss) 
 	 *(.scommon)
 	}
 	
 	.bss :
 	{
 	 *(.bss)
  	 *(COMMON)
 	}
} 

building
--------------------
mips-elf-gcc -O0 -g -W -O0 -g -mips32r2 -EL -c -mno-abicalls -fno-pic -G0 -o 1.o 1.c 
1.c:5:2: warning: no newline at end of file
mips-elf-ld  -T link.xn -EL 1.o -o a.out
mips-elf-ld: warning: cannot find entry symbol main; defaulting to 0000000080051000


`mips-elf-objdump -S a.out' shows
----------------------------------------
a.out:     file format elf32-littlemips

Disassembly of section .text:

80051000 <half>:
80051000:	27bdfff8 	addiu	sp,sp,-8
80051004:	afbe0000 	sw	s8,0(sp)
80051008:	03a0f021 	move	s8,sp
8005100c:	afc40008 	sw	a0,8(s8)
80051010:	8fc30008 	lw	v1,8(s8)
80051014:	000317c3 	sra	v0,v1,0x1f
80051018:	000217c2 	srl	v0,v0,0x1f
8005101c:	00621021 	addu	v0,v1,v0
80051020:	00021043 	sra	v0,v0,0x1
80051024:	03c0e821 	move	sp,s8
80051028:	8fbe0000 	lw	s8,0(sp)
8005102c:	27bd0008 	addiu	sp,sp,8
80051030:	03e00008 	jr	ra
80051034:	00000000 	nop

and `mips-elf-objdump -S a.o' shows
----------------------------------------
1.o:     file format elf32-littlemips

Disassembly of section .text:

00000000 <half>:

int half(int x)
{
   0:	27bdfff8 	addiu	sp,sp,-8
   4:	afbe0000 	sw	s8,0(sp)
   8:	03a0f021 	move	s8,sp
   c:	afc40008 	sw	a0,8(s8)
	return x/2;
  10:	8fc30008 	lw	v1,8(s8)
  14:	000317c3 	sra	v0,v1,0x1f
  18:	000217c2 	srl	v0,v0,0x1f
  1c:	00621021 	addu	v0,v1,v0
  20:	00021043 	sra	v0,v0,0x1
}  24:	03c0e821 	move	sp,s8
  28:	8fbe0000 	lw	s8,0(sp)
  2c:	27bd0008 	addiu	sp,sp,8
  30:	03e00008 	jr	ra
  34:	00000000 	nop

But why doesn't objdump display assembly code mixed with souce code for "a.out", as it does to "a.o"?


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