fred.c: static void sfunc(int *p) { *p=1; } static int x;
void fred(void) { ... sfunc(&x); ... }
greg.c: static void sfunc(int *p) { *p=2; } static int x;
void greg(void) { ... sfunc(&x); ... }
Once the object files from fred.c and greg.c are linked, how does ELF distinguish the sfunc's and the x's? I've been trying to RTFM, but it hasn't helped?
On 18 February 2013 01:56, Michael Hennebry hennebry@web.cs.ndsu.nodak.eduwrote:
fred.c: static void sfunc(int *p) { *p=1; } static int x;
void fred(void) { ... sfunc(&x); ... }
greg.c: static void sfunc(int *p) { *p=2; } static int x;
void greg(void) { ... sfunc(&x); ... }
Once the object files from fred.c and greg.c are linked, how does ELF distinguish the sfunc's and the x's? I've been trying to RTFM, but it hasn't helped?
--
Michael hennebry@web.cs.ndsu.NoDak.edu "On Monday, I'm gonna have to tell my kindergarten class, whom I teach not to run with scissors, that my fiance ran me through with a broadsword." -- Lily _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
The variables and functions belong to a block/file, this is their scope. Both functions/variables you mention are actually unique within their respective file scope. Also have a look at name mangling. http://en.wikipedia.org/wiki/Name_mangling. Gcc help @ http://gcc.gnu.org/ml/gcc-help/ IAll the best. Paul
On Mon, 18 Feb 2013, Paul Norton wrote:
On 18 February 2013 01:56, Michael Hennebry hennebry@web.cs.ndsu.nodak.eduwrote:
Once the object files from fred.c and greg.c are linked, how does ELF distinguish the sfunc's and the x's? I've been trying to RTFM, but it hasn't helped?
The variables and functions belong to a block/file, this is their scope. Both functions/variables you mention are actually unique within their respective file scope. ...
How is that scope recorded? According to nm, the names are the same and they are marked local, but there is no mention of the particular locality.
... Also have a look at name mangling. http://en.wikipedia.org/wiki/Name_mangling. Gcc help @
I'm dealing with C, not C++ or Python or Java.
http://gcc.gnu.org/ml/gcc-help/ IAll the best. Paul
Mailing list archives indexed only by month are not really helpful.
Am 19.02.2013 um 01:50 schrieb Michael Hennebry hennebry@web.cs.ndsu.nodak.edu:
On Mon, 18 Feb 2013, Paul Norton wrote:
On 18 February 2013 01:56, Michael Hennebry hennebry@web.cs.ndsu.nodak.eduwrote:
Once the object files from fred.c and greg.c are linked, how does ELF distinguish the sfunc's and the x's? I've been trying to RTFM, but it hasn't helped?
The variables and functions belong to a block/file, this is their scope. Both functions/variables you mention are actually unique within their respective file scope. ...
How is that scope recorded? According to nm, the names are the same and they are marked local, but there is no mention of the particular locality.
... Also have a look at name mangling. http://en.wikipedia.org/wiki/Name_mangling. Gcc help @
I'm dealing with C, not C++ or Python or Java.
http://gcc.gnu.org/ml/gcc-help/ IAll the best. Paul
Mailing list archives indexed only by month are not really helpful.
i would suggest to use a more specific mailing list ... centos is a OS not a formal language :-)
-- LF