[llvm-dev] How to distinguish two static functions with the same name?

Peng Yu via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 9 21:04:12 PST 2019

llvm-nm does show the difference between two static functions (e.g.,
_print  n the following example) with the same name. Is there a way of
allowing it to show their differences (for example, the file where
they are from)? Thanks.

$ gcc -Wall -pedantic -g -c -o print1.o print1.c
$ ar cr ./libprint1.a print1.o
$ gcc -Wall -pedantic -g -fPIC -shared -o ./libprint3.so print3.c
$ gcc -Wall -pedantic -g -c -o main.o main.c
$ gcc -Wall -pedantic -g -c -o print2.o print2.c
$ gcc -L. -lprint1 -lprint3 -o ./main.exe main.o print2.o
$ nm ./main.exe
0000000100000000 T __mh_execute_header
0000000100000ef0 T _main
0000000100000f10 t _print
0000000100000f40 t _print
0000000100000ec0 T _print1
0000000100000f20 T _print2
                 U _print3
                 U _puts
                 U dyld_stub_binder

==> main.c <==
/* vim: set noexpandtab tabstop=2: */
#include <stdio.h>
void print1();
static void print() {

int main() {
    return 0;

==> print1.c <==
/* vim: set noexpandtab tabstop=2: */
#include <stdio.h>
void print2();

void print1() {
    puts("Hello World1!");

==> print2.c <==
/* vim: set noexpandtab tabstop=2: */
#include <stdio.h>
void print3();

static void print() {
    puts("Hello World2!");

void print2() {

==> print3.c <==
/* vim: set noexpandtab tabstop=2: */
#include <stdio.h>

void print3() {
    puts("Hello World3!");


More information about the llvm-dev mailing list