Techpulp
  • Register
  •   | Log in   

  • Articles
  • Questions
  • TechNews

ELF Binary Optimization for size

Jul 26th

Posted by Nick in C/C++

2 comments

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
How to reduce size of a Linux application ELF binary, Linux Applications, Optimization, Optimize Linux Applications, Size Optimization, strip command, Tricks to reduce size of Linux ELF binary

Parse words in a string

Jul 26th

Posted by Nick in C/C++

No comments

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 >
C/C++, Parsing, String, String Parsing

Welcome to Techpulp Technologies

Jul 26th

Posted by WebMaster in Uncategorized

No comments

ยป 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.

Welcome

Find how long a command takes to complete

Jul 25th

Posted by liz in Linux

No comments

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 >

command line, how long script taken, time, time spent, time taken by command, time taken by process, time taken by script, unix, Unix/Linux
« First...1020«2627282930
  • Categories

    • Linux
    • Bash
    • Command Line
    • C/C++
    • Networking
    • Administration
    • Fedora
    • HTML

Recent Articles

  • How to enable/disable/start/stop a service in Fedora 16
  • How to switch between threads in GDB
  • How to improve performance of Linux application
  • How to find size of code and data segments of a program
  • How to catch signals in a bash script

Recent Comments

  • Svetlana on How to access command line arguments in a bash script
  • Sergey on How to mount file system using SSH in Linux
  • Mufliah on How to open a new window on click of a button in Java Script
  • 6kgxiRC on Show files by size in ls command
  • Gildas on How to disable directory listing by Apache web server

Copyright © 2007-2011 Techpulp
Login

Lost your password?

Reset Password

Log in