Pages

Wednesday, September 29, 2010

GCC dead code removing

Compile할 때 -ffunction-sections -fdata-sections 를 붙여서 컴파일 한 후
Link할 때 -Wl,--gc-sections를 붙여서 link한다.

예)
$ gcc -O3 -ffunction-sections -fdata-sections -c example1.cpp -o example1.o 
$ gcc -O3 -ffunction-sections -fdata-sections -c example2.cpp -o example2.o
$ gcc -Wl,--gc-sections example1.o example2.o -o example

확인은

$ nm example

0 개의 덧글:

Post a Comment