Skip to content

Add special section to any NetBSD assembly programs #344

@postmodern

Description

@postmodern

When the Program is converted back to assembly syntax, and if Program#os is :netbsd, then a special header must be added to the program indicating that it is a legitimate NetBSD program. Otherwise the program will not run and give a generic "cannot execute ELF binary" error message.

NASM/Intel syntax

section .note.netbsd.ident progbits alloc noexec nowrite
    dd 0x00000007 ; Name size
    dd 0x00000004 ; Desc size
    dd 0x00000001 ; value 0x01
    db "NetBSD", 0x00, 0x00 ; "NetBSD\0\0"
    db 400000003 ; __NetBSD_Version__ (please see <sys/param.h>)

GAS/ATT syntax

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

    #  ELF note to identify me as a native NetBSD program
    #  type = 0x01, desc = __NetBSD_Version__ from <sys/param.h>
    ##  
    .int    7           # length of name    
    .int    4           # length of desc
    .int    0x01            # type
    .ascii  "NetBSD\0"      # name
    .ascii  "\0"            # padding
    .int    500000003       # desc

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions