cgcc

netcat gcc compile option so that IDA pro can show function name


I want IDApro show functions name and variables, like: _readwrite, _dolisten but it only shows sub_40xxxx in function window.

How can I edit the compile option to achieve it?

The original Makefile is:

CC=gcc

CFLAGS=-DNDEBUG -DWIN32 -D_CONSOLE -DTELNET -DGAPING_SECURITY_HOLE
LDFLAGS=-s -lkernel32 -luser32 -lwsock32 -lwinmm

all: nc.exe

nc.exe: getopt.c doexec.c netcat.c
    $(CC) $(CFLAGS) getopt.c doexec.c netcat.c $(LDFLAGS) -o nc.exe

Solution

  • You are probably using mingw on Windows. So, the -s option in the LDFLAGS means that the final binary will be stripped. Just remove this option.

    Moreover, you can try to add more debug information in order to help IDAPro to recover as much as possible from the program by adding -g3 to the CFLAGS and by replacing -DNDEBUG by -DDEBUG (it will also probably add more insightful messages from the software).

    At the end you should have something like this:

    CFLAGS=-g3 -DDEBUG -DWIN32 -D_CONSOLE -DTELNET -DGAPING_SECURITY_HOLE
    LDFLAGS=-lkernel32 -luser32 -lwsock32 -lwinmm
    

    Just as a side note, you may be answered much more efficiently about question on IDAPro on RE.