This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to turn a glibc internal variable into an external resolvable symbol


Hi, all:

I am posting to ask a question about the glibc external interface. I need to turn a few glibc internal variables and functions into external resolvable symbols. I know this generally is not a good practice, but I need to do it.

The following is my question posted to the gcc mailling list. It seems that here is a better choice for me.
BTW, I added a few new variables to the glibc, although I declare them as external, the compiled libc.so takes them as local. Same problem as when I turn an existing glibc internal variable to external.


Can anybody here give me a hint? How can I achieve it?

Thanks a lot.
Haizhi


> I have a glibc internal variable named "__libc_missing_32bit_uids"
> declared in getuid.c
> The original delcaration is
> int __libc_missing_32bit_uids attribute_hidden = -1;
>
> Now I NEED to turn it into an external symbol. So I changed the above
> code to
> int __libc_missing_32bit_uids = 1;
> weak_extern (__libc_missing_32bit_uids);
>
> After compile, it does not work as I expected.
> From getuid.os, it seems right...
> 00000000    w   O   .data   00000004 __libc_missing_32bit_uids
>
> But in libc.so, it is changed to a local variable..
> 001166d8  l    O  .data 00000004  __libc_missing_32bit_uids
>
> Can anybody tell me what I need to do?  what does the 'O' mean in the
> 3rd column output of objdump?


This is probably not a gcc question. It sounds more like a glibc question or a binutils question.

My guess is that it became a local variable in libc.so because glibc
uses a linker script which forces all symbols other than ones which
are explicitly named to be local symbols.  But I don't know for sure.
It's an issue of how glibc is built.

The 'O' in the objdump output means that the symbol names an object,
as opposed to a function.

Ian



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]