[openbeos] Assembler and BeOS (tool chain question)

  • From: "Zenja Solaja" <solaja@xxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sun, 21 Jan 2007 06:02:36 +0000

I apologise in advance for asking a dev question on the public mailing list,
but this forum is the most visible for knowledgeable developers.

I'm having difficulties creating a working executable using GNU 'as' and
'ld'.

Sample "Hello World" in GNU assembler:

#file is called example.s
.section .data
output:
   .asciz "Hello World\n"

.section .text
.globl main
main:
   pushl $output
   call printf
   pushl $0
   call exit


Using gcc, the assembly program compiles and runs without any errors.
(~/develop/example)> gcc -o example example.s

However, if I manually assemble and link the program, the executable doesn't
work.
(~/develop/example)> as -o example.o example.s
(~/develop/example)> ld -o example example.o -e main -lroot

(the -e main argument instructs linker to search for main instead of _start)
When executed, I get a segment violation error under Zeta 1.2.

Does anyone know how to manually compile / link the above example?  Thanks
in advance.

Other related posts: