In article <20151023214718.cd1b12e...@panix3.panix.com>,
Stephen Fisher <sfis...@panix.com> wrote:
>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.

$ readelf -n /bin/ls

Notes at offset 0x000001dc with length 0x00000018:
  Owner                 Data size       Description
  NetBSD                0x00000004      IDENT 799000400 (7.99.4)

Notes at offset 0x000001f4 with length 0x00000014:
  Owner                 Data size       Description
  NetBSD                0x00000004      PaX <>

$ readelf -v
GNU readelf (NetBSD Binutils nb1) 2.23.2
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

christos

Reply via email to