How reliable preprocessor output is?

V

Vittal

Hello All,

I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do

$ nm -A registry_servd.o | grep __sigismember

I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???

Can somebody explain me how this can happen.

Thanks
-Raju
 
J

Joona I Palaste

Vittal said:
Hello All,
I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do
$ nm -A registry_servd.o | grep __sigismember
I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???
Can somebody explain me how this can happen.

What *exactly* is the "defination" of __sigismember? If it's something
like:
#define __sigismember aWeirdFunctionSomewhereWhoseNameYouDoNotKnow
then of course you won't find the __sigismember symbol anywhere in the
object file.

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"As we all know, the hardware for the PC is great, but the software sucks."
- Petro Tyschtschenko
 
J

Joona I Palaste

What *exactly* is the "defination" of __sigismember? If it's something
like:
#define __sigismember aWeirdFunctionSomewhereWhoseNameYouDoNotKnow
then of course you won't find the __sigismember symbol anywhere in the
object file.

Also, C does not specify the format of the object files. It might very
well be that your linker is using something else than symbol names to
do the symbol matching. Weird - very weird - but certainly possible.

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"To err is human. To really louse things up takes a computer."
- Anon
 
V

Vittal

Here is what I see in the preprocessor output.

extern int __sigismember (__const __sigset_t *__set, int __sig) {
unsigned long int __mask = (((unsigned long int)
1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned
long int __word = (((__sig) - 1) / (8 * sizeo
f (unsigned long int))); return (__set->__val[__word] & __mask) ? 1 :
0; }

Actually this piece of code comes from <socket.h> header file and also
the same header file has the DEFINATION of __sigismember function.

Regards
-Raju
 
J

Joona I Palaste

Vittal said:
Here is what I see in the preprocessor output.
extern int __sigismember (__const __sigset_t *__set, int __sig) {
unsigned long int __mask = (((unsigned long int)
1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned
long int __word = (((__sig) - 1) / (8 * sizeo
f (unsigned long int))); return (__set->__val[__word] & __mask) ? 1 :
0; }
Actually this piece of code comes from <socket.h> header file and also
the same header file has the DEFINATION of __sigismember function.

Hmm, I spot several things which might be problems, but could be just
oddities, or a sign of cluelessness on my part.
First, why is that function __sigismember labelled as extern when code
is supplied for it?
Second, you say it comes from a header file. Are you sure this header
file is included anywhere? If it's not, then no wonder it's not going
to the object file. But since you say it comes from preprocessor
output, not input, I am fairly sure it is being included. Just checking
though.
And lastly, as I said before, it just might be that your linker does
not use symbol names in object files at all.

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Life without ostriches is like coffee with milk."
- Mika P. Nieminen
 
G

Gordon Burditt

I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I

ANSI C does not define "the preprocessor" as a separate program nor
as something that has output you can see.
see the "defination" of __sigismember function. But when I do

Is it a static function? That doesn't have external linkage.
$ nm -A registry_servd.o | grep __sigismember

I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???

There is no guarantee that *ANY* function names appear in an object file
in a way that a program called "nm" can see them.

Gordon L. Burditt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top