Prepending underscores to symbol names in dlsym() (commit 20613)

Mike Frysinger vapier at gentoo.org
Tue Jan 8 16:58:00 UTC 2008


On Tuesday 08 January 2008, Will Newton wrote:
> On Jan 8, 2008 4:06 PM, Daniel Jacobowitz <drow at false.org> wrote:
> > On Tue, Jan 08, 2008 at 03:58:00PM +0000, Will Newton wrote:
> > > Agreed, my question is whether or not adding the underscore is the
> > > correct thing to do even if your architecture prepends an underscore
> > > to symbol names? Is there a particular reason why this was done for
> > > Blackfin, to make a particular app work? I am trying to find out what
> > > the correct behaviour of dlsym is, for example does it behave like
> > > this on other Unixes that have leading underscores on symbols.
> >
> > There are pretty much no Unixes that do this; a few embedded Linux
> > ports are the only exceptions I've ever encountered.
>
> I think I got the impression from the Levine "Linkers and Loaders"
> book (my copy of which seems to have vanished) that prepending an
> underscore to symbol names was common practice. Perhaps it was an
> a.out thing, that's rather before my time though...

an excellent book that could do with some freshening up to things done 
$today ... but until that happens, you'll have to mentally tweak the details 
so they apply exactly to today's conventions.

> > If you have underscores, dlsym had better know about it, or
> > cross-platform code will break.  Consider dlsym (libc_handle,
> > "printf"); every caller should not need to know about _printf.
>
> Thanks for clearing that up. My concern is that I've never seen this
> documented anywhere, but it does seem to be something of a corner
> case.

as Daniel indicates, ABI symbol prefixes are the way of the dinosaur, so this 
sort of thing doesnt get documented.  but if you apply some grease to the 
concepts, dlsym() looks for C symbols which means it needs to find symbols 
named exactly the same as the C compiler produces -- ABI symbol prefixes 
included.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20080108/9e118086/attachment-0002.pgp 


More information about the uClibc mailing list