NetBSD-Users archive

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

Re: Help to run assembly code



Hi,

You don't need to add the note section manually; you can simply link the object file with /usr/lib/sysident.o

Something like this:

ld -static -o hello /usr/lib/sysident.o hello.o

On 3/18/2026 1:51 PM, Martin Husemann wrote:

No idea how to do that with NASM, but for the as(1) that comes with
the base system you can copy the code from src/lib/csu/common/sysident.S.

Main part is:

         .section ".note.netbsd.ident", "a"
         .p2align 2

         .long   ELF_NOTE_NETBSD_NAMESZ
         .long   ELF_NOTE_NETBSD_DESCSZ
         .long   ELF_NOTE_TYPE_NETBSD_TAG
         .ascii  "NetBSD\0\0"    /* ELF_NOTE_NETBSD_NAME */
         .long   __NetBSD_Version__

Compare the file(1) output for your binary with e.g.

	file /bin/ls

Martin



Home | Main Index | Thread Index | Old Index