Re: Darwin-dev Digest, Vol 1, Issue 4
Re: Darwin-dev Digest, Vol 1, Issue 4
- Subject: Re: Darwin-dev Digest, Vol 1, Issue 4
- From: Bob Campbell <email@hidden>
- Date: Mon, 13 Sep 2004 14:48:07 -0700
At 12:07 PM -0700 9/13/04, <email@hidden> wrote:
Message: 6
Date: Mon, 13 Sep 2004 14:33:49 -0400
From: "Mike Garey" <email@hidden>
Subject: need help resolving symbols using twolevel hints table
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; format=flowed
I'm having difficulty understanding how to use the twolevel hints table to
resolve undefined symbols.Ý I'm not sure what exactly the itoc member of the
twolevel hints structure represents.
itoc is an index to the symbol in the TOC (which
is a component of the DYSYMTAB loader command),
of the dylib where the symbol is to be found.
For example, if I have an executable image, which has an undefined symbol
such as _printf, after I determine which library image it's located in (from
the n_desc value of the nlist struct), do I then obtain the tocoff value
from the dysymtab_command of this library, and add the itoc to this value,
then read the memory found at this location into a dylib_table_of_contents
struct, and then obtain the symbol_index member, which will indicate the
index of the _printf symbol within the symbol table of the shared library?Ý
Or is this completely wrong?
Looking for a symbol requires looking in several
places, first the SYMTAB from the referring
program:
We will find _printf in the SYMTAB as an undefined symbol (from nm):
9002abe0 (prebound undefined [lazy bound]) external _printf (from libSystem)
Looking at the fields we see n_type == N_PBUD,
n_desc = REFERENCE_FLAG_UNDEFINED_LAZY, and also
the id of the loading framework (in this case
libSystem).
Then we look at the TOC table from the DYSYMTAB,
and find that __printf has isub=0 and itoc=1854,
If isub is 0 then we just look at the
framework/library from the SYMTAB (in this case
libSystem) and at entry 4347 of it's SYMTAB
should be printf.
If isub is not zero it is a bit more complex, as
it indicates a framework so you have to walk the
dylib load commands (from the framework/library
and find the nth one (where n == isub) and then
itoc is the index into that nested frameworks TOC.
This is at least partly explained in the header,
/usr/include/mach-o/loader.h but I also have done
a bit of disassembly over the past 7 years to
track what "ld" was doing.
If anyone has any advice or suggestions, please let me know.Ý Thanks!
Mike
P.S. Sorry if this question has been answered in the lists before, but I
can't seem to find the search option on lists.apple.com.
--
Message Classification
[x] General Business Information
___________________________________________________________________
Bob Campbell email@hidden 408.991.7490
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden