Skip to content

Instantly share code, notes, and snippets.

@fcamel
Created March 5, 2017 07:42
Show Gist options
  • Select an option

  • Save fcamel/fad159983e0d130390b68816448b7e62 to your computer and use it in GitHub Desktop.

Select an option

Save fcamel/fad159983e0d130390b68816448b7e62 to your computer and use it in GitHub Desktop.
multiple address for the same symbol
$ tail -n +1 a.h b.c c.c m.c
==> a.h <==
#include <stdio.h>
static void foo() {
printf("from a.h\n");
}
==> b.c <==
#include <stdio.h>
#include "a.h"
void b_foo() {
printf("from b.c\n");
foo();
}
==> c.c <==
#include <stdio.h>
#include "a.h"
void c_foo() {
printf("from c.c\n");
foo();
}
==> m.c <==
#include <stdio.h>
#include "b.h"
#include "c.h"
int main(void) {
b_foo();
c_foo();
return 0;
}
$ gcc -g b.c c.c m.c -o m
$ ./m
from b.c
from a.h
from c.c
from a.h
$ nm -l m | grep foo
000000000040053d T b_foo /home/fcamel/dev/tmp/b.c:4
0000000000400567 T c_foo /home/fcamel/dev/tmp/c.c:4
000000000040052d t foo /home/fcamel/dev/tmp/a.h:3
0000000000400557 t foo /home/fcamel/dev/tmp/a.h:3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment