ELF Binary Optimization for size
Jul 26th
The following steps help in reducing the size of a Linux application ELF binary. These operations can be used for application binary as well as shared library.
Use compiler optimization flags
-Os (optimize for size)
-O2
While linking, try to use following options. But do not use ‘-s’ option for kernel modules.
# ld -r -s --discard-local --discard-all testApp.o -o testApp # ld -r -s --discard-local --discard-all testLib1.o testLib2.o -o testLib.so # ld -r --discard-local --discard-all testMod1.o testMod2.o -o testMod
Strip the binary including unnecessary sections
# strip --remove-section=.note --remove-section=.comment testApp # strip --remove-section=.note --remove-section=.comment testLib.so
Parse words in a string
Jul 26th
This function requires an array of character pointers words of size maxWords. Note that the input string line supplied to this function will be modified (precisely placing NULL termination character at each word boundary). Alternately the function can be modified to duplicate strings using strdup to avoid modification of input string line. This function returns the number of words parsed. The return value will never exceed maxWords.
int parseWords(char *line, char *words[], int maxWords)
{
char *p;
int wordCount;
p = line;
wordCount = 0;
while(wordCount < maxWords) {
while(*p && isblank(*p)) p++;
if(!p[0]) return wordCount;
words[wordCount] = p;
wordCount++;
while(*p && !isblank(*p)) p++; More > Welcome to Techpulp Technologies
Jul 26th
ยป Techpulp Technologies is specialized in the area of IP networking, network security and offers services and products related to networking. Please mail us contact@techpulp.com for more details about our services and products.
Find how long a command takes to complete
Jul 25th
Some times it is required to know how long a command is taking to execute, especially in case of huge scripts. The command “time” can be used to determine the time taken by a command or a script. The following example shows how it can be used.
[liz@techpulp ~]# time sleep 3 real 0m3.016s user 0m0.000s sys 0m0.008s [liz@techpulp ~]#
In the above example we attempted to determine time taken by the command “sleep 3” using time command. After the command finishes, time prints the information on standard error. This information contains “real” which is actual time taken by the command from the invocation More >


Recent Comments