Discussion:
Assembly Language Programs
(too old to reply)
Alessandro Coppelli
2006-04-12 07:22:49 UTC
Permalink
Raw Message
Hi to all.
I am interested to developing a little
assembly language programs.

I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation

as -o <name>.o <name>.s
ld -o <name> <name>.o

what I have is

#./<name>
#ksh: Operation not permitted


Someone knows what is happenig ?

Ale
Julien Cabillot
2006-04-12 07:33:13 UTC
Permalink
Raw Message
chmod +x <name> ?
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
Ale
--
Julien Cabillot
Ash Williams
2006-04-12 07:45:30 UTC
Permalink
Raw Message
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
I've not done any ASM on OpenBSD although i have a bit of experience
with FreeBSD. Have you looked at the syscalls located in
/usr/src/sys/kern/syscalls.master - these may differ from the syscalls
FreeBSD uses.
Post by Alessandro Coppelli
Ale
David Terrell
2006-04-12 08:14:33 UTC
Permalink
Raw Message
Post by Ash Williams
Post by Alessandro Coppelli
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
I've not done any ASM on OpenBSD although i have a bit of experience
with FreeBSD. Have you looked at the syscalls located in
/usr/src/sys/kern/syscalls.master - these may differ from the syscalls
FreeBSD uses.
You're correct. If you really feel like continuing to waste your time
with this nonsense, skip to step two which uses the C library to call
functions instead of hardcoded sytem call numbers.
Stefan Kell
2006-04-12 08:45:55 UTC
Permalink
Raw Message
--- Urspr|ngliche Nachricht ---
Betreff: Re: Assembly Language Programs
Datum: Wed, 12 Apr 2006 03:14:33 -0500
Post by Ash Williams
Post by Alessandro Coppelli
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
I've not done any ASM on OpenBSD although i have a bit of experience
with FreeBSD. Have you looked at the syscalls located in
/usr/src/sys/kern/syscalls.master - these may differ from the syscalls
FreeBSD uses.
You're correct. If you really feel like continuing to waste your time
with this nonsense, skip to step two which uses the C library to call
functions instead of hardcoded sytem call numbers.
Hi,

and most likely cause of ksh-error message is that the current directory is
mounted with noexec option. Thus you cannot start the executable.

Regards

Stefan Kell
Nick Guenther
2006-04-12 07:38:50 UTC
Permalink
Raw Message
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
One guess is that it's trying to call something besides write().
Another is that perhaps you are giving it the wrong file descriptor to
write() to.

Try disassembling the program to see if it matches what you typed in.

If using the # is just for show and it's actually $, then try sudo
./<name> and see if it was a permissions problem.

-Nick
Janne Johansson
2006-04-12 08:02:13 UTC
Permalink
Raw Message
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
Ale
Either you haven't set the x-flag on the binary, or the partition
where you are is mounted with noexec, is my guess.
ren
2006-04-12 23:22:42 UTC
Permalink
Raw Message
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
Ale
add the following section:

.section ".note.openbsd.ident", "a"
.p2align 2
.long 8
.long 4
.long 1
.ascii "OpenBSD\0"
.long 0
.p2align 2

see elf(5) or google for ".note.openbsd.ident"
--
ren
Tobias Ulmer
2006-04-12 23:30:17 UTC
Permalink
Raw Message
Post by Alessandro Coppelli
Hi to all.
I am interested to developing a little
assembly language programs.
I rode the article written by Thomas Sommers
( http://user.nj.net/~tms/hello.html )
I followed author's instructions but at the end of compilation
as -o <name>.o <name>.s
ld -o <name> <name>.o
what I have is
#./<name>
#ksh: Operation not permitted
Someone knows what is happenig ?
Ale
Yes, your file is not recognized as valid OpenBSD ELF executable.

Try this:

-- 8< -- (hello.s)
section .text
global _start

msg db "Hello, world!",0xa
len equ $ - msg

_syscall:
int 0x80
ret

_start:
push dword len
push dword msg
push dword 1 ; stdout
mov eax,0x4 ; write
call _syscall

add esp,12

push dword 0
mov eax,0x1
call _syscall


Valid OpenBSD elf header :)
-- 8< -- (obsd-elf.s)
.section ".note.openbsd.ident", "a"
.p2align 2
.long 8
.long 4
.long 1
.ascii "OpenBSD\0"
.long 0
.p2align 2

Compile and link it...

$ as obsd-elf.s -o obsd-elf.o
$ nasm -f elf -o hello.o hello.s
$ ld -s -o hello hello.o obsd-elf.o
$ ./hello
Hello, world!


Tobias

Loading...