By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,010 Members | 2,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,010 IT Pros & Developers. It's quick & easy.

How reliable preprocessor output is?

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Vittal <vs*********@yahoo.com> scribbled the following:
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 (pa*****@cc.helsinki.fi) ---------------------------\
| 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
Nov 13 '05 #2

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> scribbled the following:
Vittal <vs*********@yahoo.com> scribbled the following:
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.


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 (pa*****@cc.helsinki.fi) ---------------------------\
| 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
Nov 13 '05 #3

P: n/a
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

Joona I Palaste <pa*****@cc.helsinki.fi> wrote in message news:<bf**********@oravannahka.helsinki.fi>...
Vittal <vs*********@yahoo.com> scribbled the following:
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.

Nov 13 '05 #4

P: n/a
Vittal <vs*********@yahoo.com> scribbled the following:
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 (pa*****@cc.helsinki.fi) ---------------------------\
| 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
Nov 13 '05 #5

P: n/a
>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
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.