I'm just starting out with Assembly languege, having installed NASM on openSUSE 13.1, i386 family processor yesterday. My worry is that a simple program like "Hello World!" has flagged a warning when linking...see line 3 below:

  1. coker.mu@linux-jm54:~/nasm> nasm -f elf helloWorld.asm
  2. coker.mu@linux-jm54:~/nasm> ld -m elf_i386 -s -o helloWorld helloWorld.o

  3. ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080

  4. coker.mu@linux-jm54:~/nasm> ls -l

  5. total 12
  6. -rwxr-xr-x 1 coker.mu users 360 Dec 19 21:06 helloWorld
  7. -rw-r--r-- 1 coker.mu users 429 Dec 19 21:04 helloWorld.asm
  8. -rw-r--r-- 1 coker.mu users 624 Dec 19 21:05 helloWorld.o

Even though the program prints as expected when executed, I worry about how many errors I might get in future as I venture into deeper waters. How do I suppress such frivolous warnings? I mean the program has the "global main" line as well as the "main:" label!!

C.M.

Recommended Answers

All 5 Replies

Hi,

Re: NASM Linker warning..

Forget about my earlier question... A bit of research has just revealed that I should have used "global _start" instead of "global main". Similarly I replaced "main:" with "_start:" and the warning vanished. False alarm!! Otherwise I'm having fun with the assembler!

Good for you in finding the cause of the problem. Note that in line 3 of your post, it indicates that it would use a default entry point, which is why it ran.

How would you fix it if you wanted the entry point of your program to be NewbieChameleon? You would use the -e or --entry command line option for ld:

-eEntryPointLabel
--entry=EntryPointLabel

I use a makefile and used this for an example and 64bit O:
ld -o $(APP) $(APP).o -melf_i386 -eNewbieChameleon -dynamic-linker /lib/ld-linux.so.2

@rubberman && GunnerInc;
Thank you both for your responses. Right now things are going fine, but I know as the waters get murkier I'll be back for more help! The command line option for ld is a bonus....Don't think I could have come up with it using the man page for ld! Thanx.

ld: warning: cannot find entry symbol _start; not setting start address
micro10.o: In function main': micro10.asm:(.txt+0xeb): undefined reference toprintf'
micro10.asm:(.txt+0x111): undefined reference to `printf'
m getting this error... why is it so?

commented: Don't bury your questions under 4+ year old discussions. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.