LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2010, 02:44 AM   #1
gozlemci
Member
 
Registered: Mar 2010
Location: Turkey
Posts: 35

Rep: Reputation: 0
ld: warning: cannot find entry symbol _start


Hi there;
I am writing a sample nasm program via terminal.It's a basic one ,it only demonstrates the usage of the zero and sign flags and print relevant message to the output. Here are the code:
Code:
	SECTION .data		; data section
		errMsg:	db "Error !",10
		errLen:	equ $-errMsg
		zeroMsg: db "Zero flag",10
		zeroLen: equ $-zeroMsg
		signMsg: db "Sign flag",10
		signLen: equ $-signMsg
 
	SECTION .text		; code section
        global main		; make label available to linker 

main:				; standard  gcc  entry point
	
	;Zero Check Module
	;---------------------------------
;	mov cx,1
;	sub cx,1
;	jz zero
	;If flow reached here, an error has been done.
;	jmp error
	;---------------------------------

	;Signed Check Module
	;---------------------------------
	mov cx,0
	sub cx,1	;CX = -1, SF = 1;
	js sign
	;If flow reached here, an error has been done.
	jmp error
	;---------------------------------

zero: 
	;If flow reached here, zero flag has set.It prints "Zero Flag" message to the screen.
	mov edx,zeroLen
	mov ecx,zeroMsg
	jmp print
endZero:

error:
	;If flow reached here, an error has occured.
	mov edx,errLen
	mov ecx,errMsg
	jmp print
endError:

sign:
	;If flow reached here, sign flag has set.It prints "Sign Flag" message to the screen.
	mov edx,signLen
	mov ecx,signMsg
	jmp print
endSign:

print:
	mov	ebx,1		; arg1, where to write, screen
	mov	eax,4		; write sysout command to int 80 hex
	int	0x80		; interrupt 80 hex, call kernel
	
	mov	ebx,0		; exit code, 0=normal
	mov	eax,1		; exit command to kernel
	int	0x80		; interrupt 80 hex, call kernel
endprint:
I made ready this code with these commands:
assemble:nasm -f elf zs.asm
link:ld zs.o -o zs
At that point, I 've got such a warning:

Quote:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
compile : gcc -g zs.o -o zs
run:./zs

Even it ran properly, I wonder the reason of this warning. What does it mean? My gcc version is:
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
I suspect that it is related with the crt0.o,(http://docs.hp.com/en/B2355-90694/crt0.3.html) but I can not handle this.Thanks in advance.
 
Old 09-23-2010, 03:20 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by gozlemci View Post
I made ready this code with these commands:
assemble:nasm -f elf zs.asm
link:ld zs.o -o zs
At that point, I 've got such a warning:

Quote:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
main() is not the real entry point of a program; _start() is. I know, I know - I'm aghast that you've been lied to all these years as well! Truth is, the compiler/C library provides a _start function and tells the operating system to start execution at _start, which the OS does, and then the code that runs from there sets up the basic execution environment for you and calls your main() function for you.

So fix this error by changing "main:" to "_start:".

Last edited by JohnGraham; 09-23-2010 at 03:22 AM.
 
1 members found this post helpful.
Old 09-26-2010, 03:24 PM   #3
gozlemci
Member
 
Registered: Mar 2010
Location: Turkey
Posts: 35

Original Poster
Rep: Reputation: 0
Thank you JohnGraham. But lying is not a fair behaviour even the people who listen lies are noob learners
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048184 ravig Programming 5 11-01-2010 08:22 AM
_start, _init and frame_dummy functions jveleg Programming 5 06-09-2010 10:46 AM
WARNING: Symbol version dump /usr/src/linux-2.6.25/Module.symvers is missing gauravholey Linux - Kernel 2 06-21-2009 12:28 AM
Python warning:incomplete entry line 43 /etc/mailcap kinematic Debian 1 01-22-2007 02:56 AM
warning : /usr/lib64/libavcodec.so: undefined symbol: awt586 SUSE / openSUSE 2 07-19-2005 04:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration