DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 11th May 2021
dnslc's Avatar
dnslc dnslc is offline
Port Guard
 
Join Date: Jun 2020
Location: Australia
Posts: 24
Default help with GNU as/ld on BSD arm64

I am trying to test a simple Hello World program on my Raspberry Zero running NetBSD 9.1 with the GNU assembler. I am not actually sure if it is Arm64 or Armv7 or if there is a difference or if that matters.

Here is my code:
Code:
$ cat hllwrld.s
.global _start

_start: mov     r0, #1
        ldr     r1, =helloworld
        mov     r2, #13
        mov     r8, #64
        svc     0

        mov     r0, #0
        mov     r8, #93
        svc     0

.data
helloworld:     .ascii  "Hello World!\n"
Code:
$ as -o hllwrld.o hllwrld.s
$ ld -o hllwrld hllwrld.o
$ ./hllwrld
-sh: Cannot execute ELF binary ./hllwrld
Could someone tell me what arguments I need to add to ether as or ld or could you point me in the right direction.

Also in case this is relevant:
Code:
NetBSD rpi 9.1 NetBSD 9.1 (RPI) #0: Sun Oct 18 19:24:30 UTC 2020  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/RPI evbarm
Thanks.

Last edited by dnslc; 11th May 2021 at 03:57 PM.
Reply With Quote
  #2   (View Single Post)  
Old 13th May 2021
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

You'll need a good bit of flags with ld(1) in order to get a working binary.

To see all the flags needed, try linking with:
Code:
$ cc -v -o hllwrld hllwrld.o
Reply With Quote
Reply

Tags
arm, arm64, bsd, gas

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenBSD 6.8 arm64 Raspberry Pi 4 4GB xenodm Xfce TheTKS OpenBSD General 6 15th November 2020 06:02 PM
I can't install php-gd on OpenBSD 6.5 arm64 joancatala OpenBSD Packages and Ports 5 20th August 2019 07:54 AM


All times are GMT. The time now is 09:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick