[comp.unix.microport] Interpretation of values reported by nm

richardh@killer.UUCP (Richard Hargrove) (06/30/88)

This one has me stumped. I was playing around with a program to read
the process table out of the kernel via the /dev/kmem device but when
I nm /system5, ALL of the addresses, except for u, begin with 0x02.
Specifically, proc is 0x0228365a, v is 0x022027ec, etc. These then produce 
garbage when used as offsets into /dev/kmem. Does anyone know what these 
values represent and how I would need to transform them to make them useful 
as /dev/kmem offsets?

I inadvertently discovered that sdb takes hex addresses in the form
<selector> prepended to <offset>. Is that the case here? If so, these
seem like very large selectors.

thanks,
richard hargrove
...!{ihnp4 | codas | cbosgd}!killer!richardh
--------------------------------------------

mp1@sdcc12.UUCP (07/01/88)

In article <4650@killer.UUCP>, richardh@killer.UUCP (Richard Hargrove) writes:
> I nm /system5, ALL of the addresses, except for u, begin with 0x02.
> Specifically, proc is 0x0228365a, v is 0x022027ec, etc.
                          ^^^^
			  ----  Segment selector
			      ^^^^
			      -------  Offset in selector.
You can't use these directly as offsets into physical memory
device.

You need to find the GDT (Global Descriptor Table) and use
selector as an index into it to find the _physical_ address of
the segment, then add the offset. THAT should be the location to
lseek to. This isin't a feature! :-)

These numbers may look big, but the lower 3 bits mean special
things to the system (which table and the privledge level).
There's actually only 8192 segments in the GDT (Maximum. Some
get gobbled up by process table entries and buffer cache selectors)

Advise you get a book on the 80286 that has a section on
PVA (Protected Virtual Addressing) mode. This will tell what
these all mean.

> <selector> prepended to <offset>. Is that the case here?
Yes.
> richard hargrove
> ...!{ihnp4 | codas | cbosgd}!killer!richardh

Eric Dorman				Kirk- "Wheels, Mr. Spock"
University of California, San Diego	Spock- "A flivver, Captain"
Scripps Institution of Oceanography	  From-"A Piece of the Action"
 siolmd!eric@sdsioa.ucsd.edu
 mp1@sdcc12.ucsd.edu  Attn: eric
 dorman@mplvax.nosc.mil  Attn: eric

Holgi@altger.UUCP (Holgi) (07/12/88)

In article <1025@sdcc12.ucsd.EDU> mp1@sdcc12.ucsd.EDU (Leroy Dorman) writes:
>In article <4650@killer.UUCP>, richardh@killer.UUCP (Richard Hargrove) writes:
>> I nm /system5, ALL of the addresses, except for u, begin with 0x02.
>> Specifically, proc is 0x0228365a, v is 0x022027ec, etc.
>                          ^^^^
>			  ----  Segment selector
>			      ^^^^
>			      -------  Offset in selector.
>You can't use these directly as offsets into physical memory
>device.

Right, but if you use /dev/kmem (as richardh) you access the kernel virtual
memory (different to /dev/mem) and that works.
I've done it that way and I've got the uid, pid, ppid out of that 'garbage'
but does anyone know the right format to interpret all values ??