While learning how to write assembly code on NetBSD, I decided to extend readelf.c (from GNU binutils) to show the NT_VERSION value in an ELF header, which is the NetBSD version in the format of the __NetBSD_Version__ macro from sys/param.h. The value comes out as a 32-bit integer: for example 601000500 for 6.1.5. How do I handle that value in a C program? If I follow the logic of the __NetBSD_Prereq__ macro, only the first digit of each field (MMmmrrpp major/minor/0/patch level) can be used so major version 6 is represented as 60. What if it goes to 10 or higher? While researching the source code for this issue, I found out that the file utility in src/external/bsd/file/dist/src/readelf.c handles it the old way still:
* M = major version * m = minor version * r = release ["",A-Z,Z[A-Z] but numeric] * p = patchlevel ...which I understand was depreciated in 2004, so if I fake the value 99 for minor version (to indicate current) in the assembler section note, the file command shows "...for NetBSD 6.9ZZZL...". If I put in a major version 10 in the assembly source, then my current binutils readelf.c changes (based on the prereq macro's logic) shows version 1 instad of 10.