ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I runned it under gdb too, but program receives signal SIGEGV (Segmentation fault), as soon as the first item after _start label gets to be executed.
Example:
Code:
...
_start:
operation1
operation2
...
After running into operation1, it crashes.
Output I receive in GDB:
Quote:
Program received signal SIGSEGV, Segmentation fault.
_start () at cpuid.s:line_number
line_number operation1
After googling pretty much, I found out I should disable SVR4 emulation. source
Then, I expected like my programs to run normally, but, unfortunately, it didn't happen. For example, the program below should return 0, but it returns 20 in sh and 16 in bash.
Code:
header to force netbsd to recognise program as a netbsd binary
.section .data
.section .text
.globl _start
_start:
movl $1, %eax
movl $0, %ebx
int $0x80
I'm forwarding this little "journal" to the mailing list in case others want to adapt the "Hello World" that's all over the place in the NASM/Linux/FreeBSD assembly howtos and tutorials to NetBSD. Currently their instructions are incorrect, as are all the other tutorials that lump NetBSD in with the rest of the rabble with their sample hello world routines. Looks like there was a change recently in the "way" to use syscalls in NetBSD, because on the older kernels (around 1.5) the routine works fine without pushing a return address onto the stack.
OK, now if you could help me it would be just great! How can I make the program generated by the code above to act in NetBSD as if it's runned on Linux? One of my ideas is to "convince" NetBSD to run it in emulation mode, but how do I accomplish that?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.