NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Assembly example (nasm) for amd64 in NetBSD



On Fri, 14 Apr 2023, Rocky Hotas wrote:

On apr 14  1:46, RVP wrote:

+section .note.netbsd.ident
+
+   dd 7			; ELF_NOTE_NETBSD_NAMESZ
+   dd 4			; ELF_NOTE_NETBSD_DESCSZ
+   dd 1			; ELF_NOTE_TYPE_NETBSD_TAG
+   db 'NetBSD',0,'$'	; NetBSD string
+   dq 903000000		; NetBSD version 9.3.0

It works, thank you!


Ah, the `version' should be int32 not int64. And, looking at the
nasm docs. suggests that sections can be annotated to match what
the toolchain adds, This is better:

```
--- testcpu.s.orig	2023-04-14 08:28:30.834209346 +0000
+++ testcpu.s	2023-04-14 08:33:27.461564949 +0000
@@ -23,3 +23,11 @@
     mov rax, 1
     mov rbx, 0
     syscall
+
+section .note.netbsd.ident note alloc noexec nowrite align=4
+
+   dd 7		; ELF_NOTE_NETBSD_NAMESZ
+   dd 4		; ELF_NOTE_NETBSD_DESCSZ
+   dd 1		; ELF_NOTE_TYPE_NETBSD_TAG
+   dd 'NetBSD'	; NetBSD string (8 bytes)
+   dd 903000000	; NetBSD version 9.3.0
```

-RVP


Home | Main Index | Thread Index | Old Index